• Nicolin Chen's avatar
    hwmon: (ina3221) Add PM runtime support · 323aeb0e
    Nicolin Chen authored
    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: default avatarNicolin Chen <nicoleotsuka@gmail.com>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    323aeb0e
ina3221.c 20.1 KB