Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: light: tsl2583: Balance runtime pm + use pm_runtime_resume_and_get()

Error paths in read_raw() and write_raw() callbacks failed to perform and
type of runtime pm put(). Remove called pm_runtime_put_noidle()
but there is no equivalent get (this is safe because the reference
count is protected against going below zero, but it is misleading.

Whilst here use pm_runtime_resume_and_get() to replace boilerplate.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Brian Masney <masneyb@onstation.org>
Reviewed-by: Brian Masney <masneyb@onstation.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-4-jic23@kernel.org

+7 -6
+7 -6
drivers/iio/light/tsl2583.c
··· 644 644 int ret; 645 645 646 646 if (on) { 647 - ret = pm_runtime_get_sync(&chip->client->dev); 648 - if (ret < 0) 649 - pm_runtime_put_noidle(&chip->client->dev); 647 + ret = pm_runtime_resume_and_get(&chip->client->dev); 650 648 } else { 651 649 pm_runtime_mark_last_busy(&chip->client->dev); 652 650 ret = pm_runtime_put_autosuspend(&chip->client->dev); ··· 727 729 read_done: 728 730 mutex_unlock(&chip->als_mutex); 729 731 730 - if (ret < 0) 732 + if (ret < 0) { 733 + tsl2583_set_pm_runtime_busy(chip, false); 731 734 return ret; 735 + } 732 736 733 737 /* 734 738 * Preserve the ret variable if the call to ··· 791 791 792 792 mutex_unlock(&chip->als_mutex); 793 793 794 - if (ret < 0) 794 + if (ret < 0) { 795 + tsl2583_set_pm_runtime_busy(chip, false); 795 796 return ret; 797 + } 796 798 797 799 ret = tsl2583_set_pm_runtime_busy(chip, false); 798 800 if (ret < 0) ··· 882 880 883 881 pm_runtime_disable(&client->dev); 884 882 pm_runtime_set_suspended(&client->dev); 885 - pm_runtime_put_noidle(&client->dev); 886 883 887 884 return tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF); 888 885 }