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

Configure Feed

Select the types of activity you want to include in your feed.

i2c: designware: Use runtime PM macro for auto-cleanup

Simplify runtime PM handling in i2c_dw_xfer_common() by using the
pm_runtime_active_auto_try guard. This adds the proper handling for
runtime PM resume errors and allows us to get rid of the done and
done_nolock labels.

Also use the dedicated PM_RUNTIME macros in amd_i2c_dw_xfer_quirk()
instead of ACQUIRE()/ACQUIRE_ERR().

Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260130-i2c-dw-v6-2-08ca1e9ece07@bootlin.com

authored by

Benoît Monin and committed by
Andi Shyti
4a5aa009 470f1a71

+9 -9
+9 -9
drivers/i2c/busses/i2c-designware-master.c
··· 296 296 u8 *tx_buf; 297 297 unsigned int val; 298 298 299 - ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev); 300 - if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) 299 + PM_RUNTIME_ACQUIRE_AUTOSUSPEND(dev->dev, pm); 300 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 301 301 return -ENXIO; 302 302 303 303 /* ··· 846 846 847 847 dev_dbg(dev->dev, "msgs: %d\n", num); 848 848 849 - pm_runtime_get_sync(dev->dev); 849 + PM_RUNTIME_ACQUIRE_AUTOSUSPEND(dev->dev, pm); 850 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 851 + return -ENXIO; 850 852 851 853 ret = i2c_dw_acquire_lock(dev); 852 854 if (ret) 853 - goto done_nolock; 855 + return ret; 854 856 855 857 /* 856 858 * If the I2C_M_STOP is present in some the messages, ··· 868 866 for (cnt = 1; ; cnt++) { 869 867 if (!i2c_dw_msg_is_valid(dev, msgs_part, cnt - 1)) { 870 868 ret = -EINVAL; 871 - goto done; 869 + break; 872 870 } 873 871 874 872 if ((msgs_part[cnt - 1].flags & I2C_M_STOP) || 875 873 (msgs_part + cnt == msgs + num)) 876 874 break; 877 875 } 876 + if (ret < 0) 877 + break; 878 878 879 879 /* transfer one part up to a STOP */ 880 880 ret = __i2c_dw_xfer_one_part(dev, msgs_part, cnt); ··· 884 880 break; 885 881 } 886 882 887 - done: 888 883 i2c_dw_set_mode(dev, DW_IC_SLAVE); 889 884 890 885 i2c_dw_release_lock(dev); 891 - 892 - done_nolock: 893 - pm_runtime_put_autosuspend(dev->dev); 894 886 895 887 if (ret < 0) 896 888 return ret;