hwmon: (ina3221) Add PM runtime support
authorNicolin Chen <nicoleotsuka@gmail.com>
Mon, 5 Nov 2018 20:48:43 +0000 (12:48 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 16 Dec 2018 23:13:13 +0000 (15:13 -0800)
commit323aeb0eb5d9a6820130dfab1214a83edf385dcd
tree64daad7cf46ae76a9089568c191b1ccb52bc2a1d
parent4c0415a371fdbac6531d435a50745255e32d0e0e
hwmon: (ina3221) Add PM runtime support

If all three channels are disabled via in[123]_enable ABI,
the driver could suspend the chip for power saving purpose.

So this patch adds the PM runtime support in order to gain
more power control than system suspend and resume use case.

For PM runtime, there are a few related changes happening:
1) Added a new pm_dev device pointer for all the PM runtime
   callbacks. This is because hwmon core registers a child
   device for each hwmon driver and passes it back to each
   driver. So there might be a mismatch between two device
   pointers in the driver if mixing using them.
2) Added a check in ina3221_is_enabled() to make sure that
   the chip is resumed.
3) Bypassed the unchanged status in ina3221_write_enable()
   in order to keep the PM runtime refcount being matched.
4) Removed the reset routine in the probe() by calling the
   resume() via pm_runtime_get_sync() instead, as they're
   similar. It's also necessary to do so to match initial
   PM refcount with the number of enabled channels.

Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina3221.c