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:
@ -195,6 +195,7 @@ struct npcm7xx_cooling_device {
|
|||||||
struct npcm7xx_pwm_fan_data {
|
struct npcm7xx_pwm_fan_data {
|
||||||
void __iomem *pwm_base;
|
void __iomem *pwm_base;
|
||||||
void __iomem *fan_base;
|
void __iomem *fan_base;
|
||||||
|
int pwm_modules;
|
||||||
unsigned long pwm_clk_freq;
|
unsigned long pwm_clk_freq;
|
||||||
unsigned long fan_clk_freq;
|
unsigned long fan_clk_freq;
|
||||||
struct clk *pwm_clk;
|
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 */
|
/* Setting PWM Prescale Register value register to both modules */
|
||||||
prescale_val |= (prescale_val << NPCM7XX_PWM_PRESCALE_SHIFT_CH01);
|
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(prescale_val, NPCM7XX_PWM_REG_PR(data->pwm_base, m));
|
||||||
iowrite32(NPCM7XX_PWM_PRESCALE2_DEFAULT,
|
iowrite32(NPCM7XX_PWM_PRESCALE2_DEFAULT,
|
||||||
NPCM7XX_PWM_REG_CSR(data->pwm_base, m));
|
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)
|
if (!data->info)
|
||||||
return -EINVAL;
|
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");
|
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm");
|
||||||
if (!res) {
|
if (!res) {
|
||||||
dev_err(dev, "pwm resource not found\n");
|
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);
|
output_freq = npcm7xx_pwm_init(data);
|
||||||
npcm7xx_fan_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]);
|
mutex_init(&data->pwm_lock[cnt]);
|
||||||
|
|
||||||
for (i = 0; i < NPCM7XX_FAN_MAX_MODULE; i++) {
|
for (i = 0; i < NPCM7XX_FAN_MAX_MODULE; i++) {
|
||||||
|
Reference in New Issue
Block a user