History

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

Linus Torvalds committed 2 years ago

Commit da3c45c2 parents db5ccb9 2539b151 file · +5 −2Browse files

Unified · Split

drivers/hwmon/npcm750-pwm-fan.c+5−2
@@ -195,6 +195,7 @@ struct npcm7xx_cooling_device { · 194 unmodified lines
195195 struct npcm7xx_pwm_fan_data {
196196 void __iomem *pwm_base;
197197 void __iomem *fan_base;
198+ int pwm_modules;
198199 unsigned long pwm_clk_freq;
199200 unsigned long fan_clk_freq;
200201 struct clk *pwm_clk;
@@ -710,7 +711,7 @@ static u32 npcm7xx_pwm_init(struct npcm7xx_pwm_fan_data *data) · 509 unmodified lines
710711 /* Setting PWM Prescale Register value register to both modules */
711712 prescale_val |= (prescale_val << NPCM7XX_PWM_PRESCALE_SHIFT_CH01);
712713
713− for (m = 0; m < NPCM7XX_PWM_MAX_MODULES ; m++) {
714+ for (m = 0; m < data->pwm_modules; m++) {
714715 iowrite32(prescale_val, NPCM7XX_PWM_REG_PR(data->pwm_base, m));
715716 iowrite32(NPCM7XX_PWM_PRESCALE2_DEFAULT,
716717 NPCM7XX_PWM_REG_CSR(data->pwm_base, m));
@@ -946,6 +947,8 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev) · 229 unmodified lines
946947 if (!data->info)
947948 return -EINVAL;
948949
950+ data->pwm_modules = data->info->pwm_max_channel / NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE;
951+
949952 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm");
950953 if (!res) {
951954 dev_err(dev, "pwm resource not found\n");
@@ -983,7 +986,7 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev) · 31 unmodified lines
983986 output_freq = npcm7xx_pwm_init(data);
984987 npcm7xx_fan_init(data);
985988
986− for (cnt = 0; cnt < NPCM7XX_PWM_MAX_MODULES ; cnt++)
989+ for (cnt = 0; cnt < data->pwm_modules; cnt++)
987990 mutex_init(&data->pwm_lock[cnt]);
988991
989992 for (i = 0; i < NPCM7XX_FAN_MAX_MODULE; i++) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t