hwmon updates for v6.8 - part 2

Fix crash seen when instantiating npcm750-pwm-fan
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmWmq5YACgkQyx8mb86f
 mYH9WRAAoX2Vo1SGMGCcgv5+vkZu3T7OUDswZvTAeODBPNSKlVfAL0/pRe3F+rFH
 ftHB/p2eFATt41WpUkn2APzt8YVT/SBYHGkaZhIJtgzUW0DHQLkf/UrHyHGP8T99
 hSzMubpJhNXZkUdSY4J2IIXdI6tNJJB9ma098An0Y2zmez3v/BWR/011nmZl0HQb
 ohyCAbHPAVwLXdHAHA0NtuDL9a7qpJgtELETbkIrfKD0v5a9vE05zmhqqAlpM2GT
 LBcEQlofUyhCSyzs/K7T14BxJdbQgNpaJS0jpi9PqwUWfKT/U5j/sETmMV8by4I2
 pLn/d4HBJMEWi4P+6HrT93weYl/dRrzD+Po9dJy5pTgj67bi5cNmb9j6+XiocYb7
 GHvERQ6EIUkKTUwxPWBZ/Og35VRGHSXKtlpjNS3R6y4jPaFWMPi7usCwFpcIvbvt
 L3YimKNVGFu2kFqmoN6HCIXy9gGg7WXOpjVabL299nMl0exVONOIzADozPtBKwql
 ylIxBJGj13gZ4+WLHcJa8BNKNNDHII6y3FFCxbFbnRzKJ9YM2+pe7rxY7dYOb6k+
 ib421czTyqeo1D8bpUGpBYAaJDXLJD2jIMn4VhMnCLfQRS05eqEFSVjYedxsinRw
 mbuUb6ySncxaC7aCP7YvHkqySf2L82vEiNjlCgNhtnvz0gozFIg=
 =DwUL
 -----END PGP SIGNATURE-----

Merge tag 'hwmon-for-v6.8-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmonfix from Guenter Roeck:
 "Fix crash seen when instantiating npcm750-pwm-fan"

* tag 'hwmon-for-v6.8-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: (npcm750-pwm-fan) Fix crash observed when instantiating nuvoton,npcm750-pwm-fan
This commit is contained in:
Linus Torvalds 2024-01-18 16:42:18 -08:00
commit da3c45c721

View File

@ -195,6 +195,7 @@ struct npcm7xx_cooling_device {
struct npcm7xx_pwm_fan_data {
void __iomem *pwm_base;
void __iomem *fan_base;
int pwm_modules;
unsigned long pwm_clk_freq;
unsigned long fan_clk_freq;
struct clk *pwm_clk;
@ -710,7 +711,7 @@ static u32 npcm7xx_pwm_init(struct npcm7xx_pwm_fan_data *data)
/* Setting PWM Prescale Register value register to both modules */
prescale_val |= (prescale_val << NPCM7XX_PWM_PRESCALE_SHIFT_CH01);
for (m = 0; m < NPCM7XX_PWM_MAX_MODULES ; m++) {
for (m = 0; m < data->pwm_modules; m++) {
iowrite32(prescale_val, NPCM7XX_PWM_REG_PR(data->pwm_base, m));
iowrite32(NPCM7XX_PWM_PRESCALE2_DEFAULT,
NPCM7XX_PWM_REG_CSR(data->pwm_base, m));
@ -946,6 +947,8 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
if (!data->info)
return -EINVAL;
data->pwm_modules = data->info->pwm_max_channel / NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm");
if (!res) {
dev_err(dev, "pwm resource not found\n");
@ -983,7 +986,7 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
output_freq = npcm7xx_pwm_init(data);
npcm7xx_fan_init(data);
for (cnt = 0; cnt < NPCM7XX_PWM_MAX_MODULES ; cnt++)
for (cnt = 0; cnt < data->pwm_modules; cnt++)
mutex_init(&data->pwm_lock[cnt]);
for (i = 0; i < NPCM7XX_FAN_MAX_MODULE; i++) {