iio: accel: mma8452: use pm_ptr() for dev_pm_ops
PATCH 1/1 iio: accel: mma8452: use pm_ptr() for dev_pm_ops
From: Sanjay Chitroda <[email protected]>
Use pm_ptr() so the PM ops pointer is automatically set to NULL when CONFIG_PM is disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.
--- drivers/iio/accel/mma8452.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/accel/mma8452.c +1 -3
@@ -1744,7 +1744,6 @@ static void mma8452_remove(struct i2c_client *client)regulator_disable (data->vdd_reg); } -#ifdef CONFIG_PM static int mma8452_runtime_suspend (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));
@@ -1812,7 +1811,6 @@ static int mma8452_runtime_resume(struct device *dev)return ret; } -#endif static const struct dev_pm_ops mma8452_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, pm_runtime_force_resume)
@@ -1835,7 +1833,7 @@ static struct i2c_driver mma8452_driver = { .driver = { .name = "mma8452", .of_match_table = mma8452_dt_ids, - .pm = &mma8452_pm_ops, + .pm = pm_ptr(&mma8452_pm_ops), }, .probe = mma8452_probe, .remove = mma8452_remove,
Signature · 1 line
2.34.1
Quoted 3 lines · Sanjay Chitroda
Use
pm_ptr()so the PM ops pointer is automatically set to NULL whenCONFIG_PMis disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.
...
Quoted 2 lines
static const struct
dev_pm_opsmma8452_pm_ops= {
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
You also want to change this to DEFINE_RUNTIME_DEV_PM_OPS().
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Sanjay Chitroda
Use
pm_ptr()so the PM ops pointer is automatically set to NULL whenCONFIG_PMis disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.
Quoted 7 lines
...
Quoted 2 lines
static const struct
dev_pm_opsmma8452_pm_ops= {
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)You also want to change this to
DEFINE_RUNTIME_DEV_PM_OPS().
Hi Andy,
Thank you for the review and feedback.
I will update changes in next version.
Thank,
Sanjay Chitroda
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Sanjay,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v7.0 next-20260415] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sanjay-Chitroda/iio-accel-mma8452-use-pm_ptr-for-dev_pm_ops/20260416-061819 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20260414192045.3598010-1-sanjayembedded%40gmail.com patch subject: [PATCH] iio: accel: mma8452: use pm_ptr() for dev_pm_ops config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260416/[email protected]/config) compiler: m68k-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260416/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/iio/accel/mma8452.c:1776:12: warning: 'mma8452_runtime_resume' defined but not used [-Wunused-function]
1776 | static int mma8452_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/iio/accel/mma8452.c:1747:12: warning: 'mma8452_runtime_suspend' defined but not used [-Wunused-function] 1747 | static int mma8452_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +/mma8452_runtime_resume +1776 drivers/iio/accel/mma8452.c
c7eeea93ac60ab Peter Meerwald 2014-02-05 1746
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 @1747 static int mma8452_runtime_suspend(struct device *dev)
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1748 {
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1749 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1750 struct mma8452_data *data = iio_priv(indio_dev);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1751 int ret;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1752
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1753 mutex_lock(&data->lock);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1754 ret = mma8452_standby(data);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1755 mutex_unlock(&data->lock);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1756 if (ret < 0) {
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1757 dev_err(&data->client->dev, "powering off device failed\n");
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1758 return -EAGAIN;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1759 }
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1760
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1761 ret = regulator_disable(data->vddio_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1762 if (ret) {
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1763 dev_err(dev, "failed to disable VDDIO regulator\n");
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1764 return ret;
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1765 }
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1766
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1767 ret = regulator_disable(data->vdd_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1768 if (ret) {
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1769 dev_err(dev, "failed to disable VDD regulator\n");
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1770 return ret;
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1771 }
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1772
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1773 return 0;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1774 }
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1775
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 @1776 static int mma8452_runtime_resume(struct device *dev)
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1777 {
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1778 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1779 struct mma8452_data *data = iio_priv(indio_dev);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1780 int ret, sleep_val;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1781
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1782 ret = regulator_enable(data->vdd_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1783 if (ret) {
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1784 dev_err(dev, "failed to enable VDD regulator\n");
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1785 return ret;
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1786 }
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1787
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1788 ret = regulator_enable(data->vddio_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1789 if (ret) {
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1790 dev_err(dev, "failed to enable VDDIO regulator\n");
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1791 regulator_disable(data->vdd_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1792 return ret;
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1793 }
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1794
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1795 ret = mma8452_active(data);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1796 if (ret < 0)
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1797 goto runtime_resume_failed;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1798
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1799 ret = mma8452_get_odr_index(data);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1800 sleep_val = 1000 / mma8452_samp_freq[ret][0];
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1801 if (sleep_val < 20)
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1802 usleep_range(sleep_val * 1000, 20000);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1803 else
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1804 msleep_interruptible(sleep_val);
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1805
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1806 return 0;
96c0cb2bbfe0a5 Martin Kepplinger 2016-03-03 1807
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1808 runtime_resume_failed:
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1809 regulator_disable(data->vddio_reg);
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1810 regulator_disable(data->vdd_reg);
c7eeea93ac60ab Peter Meerwald 2014-02-05 1811
f6ff49b8a3b6f7 Anson Huang 2019-01-08 1812 return ret;
c7eeea93ac60ab Peter Meerwald 2014-02-05 1813 }
c7eeea93ac60ab Peter Meerwald 2014-02-05 1814 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Hi Sanjay,
Quoted 7 lines · Sanjay Chitroda
From: Sanjay Chitroda <[email protected]>
Use
pm_ptr()so the PM ops pointer is automatically set to NULL whenCONFIG_PMis disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.Signed-off-by Sanjay Chitroda <[email protected]>
Thanks for your patch!
Quoted 11 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1744,7 +1744,6 @@ static void mma8452_remove(struct i2c_client *client)regulator_disable (data->vdd_reg); } -#ifdef CONFIG_PM static int mma8452_runtime_suspend (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));
drivers/iio/accel/mma8452.c static int mma8452_runtime_resume(struct device *dev) · line 1816
Quoted 7 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1812,7 +1811,6 @@ static int mma8452_runtime_resume(struct device *dev)return ret; } -#endif static const struct dev_pm_ops mma8452_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, pm_runtime_force_resume)
You are still getting defined but not used warnings, as reported by the kernel test robot, due to the use of SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS(). Please define the structure using DEFINE_RUNTIME_DEV_PM_OPS() to fix this.
drivers/iio/accel/mma8452.c static struct i2c_driver mma8452_driver = { · line 1839
Quoted 9 lines
drivers/iio/accel/mma8452.c +1
-1@@ -1835,7 +1833,7 @@ static struct i2c_driver mma8452_driver = { .driver = { .name = "mma8452", .of_match_table = mma8452_dt_ids, - .pm = &mma8452_pm_ops, + .pm = pm_ptr(&mma8452_pm_ops), }, .probe = mma8452_probe, .remove = mma8452_remove,
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 50 lines · Geert Uytterhoeven
Hi Sanjay,
Quoted 7 lines · Sanjay Chitroda
From: Sanjay Chitroda <[email protected]>
Use
pm_ptr()so the PM ops pointer is automatically set to NULL whenCONFIG_PMis disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.Signed-off-by Sanjay Chitroda <[email protected]>Thanks for your patch!
Quoted 11 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1744,7 +1744,6 @@ static void mma8452_remove(struct i2c_client *client)regulator_disable (data->vdd_reg); } -#ifdef CONFIG_PM static int mma8452_runtime_suspend (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));drivers/iio/accel/mma8452.c static int mma8452_runtime_resume(struct device *dev) · line 1816
Quoted 7 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1812,7 +1811,6 @@ static int mma8452_runtime_resume(struct device *dev)return ret; } -#endif static const struct dev_pm_ops mma8452_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, pm_runtime_force_resume)You are still getting defined but not used warnings, as reported by the kernel test robot, due to the use of
SET_SYSTEM_SLEEP_PM_OPS()andSET_RUNTIME_PM_OPS(). Please define the structure usingDEFINE_RUNTIME_DEV_PM_OPS()to fix this.drivers/iio/accel/mma8452.c static struct i2c_driver mma8452_driver = { · line 1839
Quoted 9 lines
drivers/iio/accel/mma8452.c +1
-1@@ -1835,7 +1833,7 @@ static struct i2c_driver mma8452_driver = { .driver = { .name = "mma8452", .of_match_table = mma8452_dt_ids, - .pm = &mma8452_pm_ops, + .pm = pm_ptr(&mma8452_pm_ops), }, .probe = mma8452_probe, .remove = mma8452_remove,Gr{oetje,eeting}s,
Quoted 2 lines
Geert
Hi Greet,
Thank you for the review and feedback.
I will update changes in next version.
Thank,
Sanjay Chitroda
Jonathan Cameron
maintainerQuoted 53 lines · On Tue, 21 Apr 2026 07:23:06 +0530 Sanjay Chitroda…
Quoted 50 lines · Geert Uytterhoeven
Hi Sanjay,
Quoted 7 lines · Sanjay Chitroda
From: Sanjay Chitroda <[email protected]>
Use
pm_ptr()so the PM ops pointer is automatically set to NULL whenCONFIG_PMis disabled. This avoids unused-function warnings and follows modern kernel power-management conventions.Signed-off-by Sanjay Chitroda <[email protected]>Thanks for your patch!
Quoted 11 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1744,7 +1744,6 @@ static void mma8452_remove(struct i2c_client *client)regulator_disable (data->vdd_reg); } -#ifdef CONFIG_PM static int mma8452_runtime_suspend (struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));drivers/iio/accel/mma8452.c static int mma8452_runtime_resume(struct device *dev) · line 1816
Quoted 7 lines
drivers/iio/accel/mma8452.c +0
-1@@ -1812,7 +1811,6 @@ static int mma8452_runtime_resume(struct device *dev)return ret; } -#endif static const struct dev_pm_ops mma8452_pm_ops = {SET_SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, pm_runtime_force_resume)You are still getting defined but not used warnings, as reported by the kernel test robot, due to the use of
SET_SYSTEM_SLEEP_PM_OPS()andSET_RUNTIME_PM_OPS(). Please define the structure usingDEFINE_RUNTIME_DEV_PM_OPS()to fix this.drivers/iio/accel/mma8452.c static struct i2c_driver mma8452_driver = { · line 1839
Quoted 9 lines
drivers/iio/accel/mma8452.c +1
-1@@ -1835,7 +1833,7 @@ static struct i2c_driver mma8452_driver = { .driver = { .name = "mma8452", .of_match_table = mma8452_dt_ids, - .pm = &mma8452_pm_ops, + .pm = pm_ptr(&mma8452_pm_ops), }, .probe = mma8452_probe, .remove = mma8452_remove,Gr{oetje,eeting}s,
Quoted 2 lines
Geert
Quoted 7 lines
Hi Greet,
Thank you for the review and feedback.
I will update changes in next version.Thank,
Sanjay Chitroda
Trivial process thing. Whilst it may seem less polite than you'd like to me, emails like this just add noise for those dealing with a lot of review. Save your thanks for the change log of the next version (under the ---)
I've not grumped at anyone about this for a few weeks. You just happen to be the unfortunate victim amongst many who do this!
Thanks,
Jonathan