--- zzzz-none-000/linux-3.10.107/drivers/hwmon/smsc47m1.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/hwmon/smsc47m1.c 2021-02-04 17:41:59.000000000 +0000 @@ -7,7 +7,7 @@ * Super-I/O chips. * * Copyright (C) 2002 Mark D. Studebaker - * Copyright (C) 2004-2007 Jean Delvare + * Copyright (C) 2004-2007 Jean Delvare * Ported to Linux 2.6 by Gabriele Gorla * and Jean Delvare * @@ -142,11 +142,6 @@ u8 activate; /* Remember initial device state */ }; - -static int __exit smsc47m1_remove(struct platform_device *pdev); -static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, - int init); - static inline int smsc47m1_read_value(struct smsc47m1_data *data, u8 reg) { return inb_p(data->addr + reg); @@ -158,13 +153,54 @@ outb_p(value, data->addr + reg); } -static struct platform_driver smsc47m1_driver = { - .driver = { - .owner = THIS_MODULE, - .name = DRVNAME, - }, - .remove = __exit_p(smsc47m1_remove), -}; +static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, + int init) +{ + struct smsc47m1_data *data = dev_get_drvdata(dev); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { + int i, fan_nr; + fan_nr = data->type == smsc47m2 ? 3 : 2; + + for (i = 0; i < fan_nr; i++) { + data->fan[i] = smsc47m1_read_value(data, + SMSC47M1_REG_FAN[i]); + data->fan_preload[i] = smsc47m1_read_value(data, + SMSC47M1_REG_FAN_PRELOAD[i]); + data->pwm[i] = smsc47m1_read_value(data, + SMSC47M1_REG_PWM[i]); + } + + i = smsc47m1_read_value(data, SMSC47M1_REG_FANDIV); + data->fan_div[0] = (i >> 4) & 0x03; + data->fan_div[1] = i >> 6; + + data->alarms = smsc47m1_read_value(data, + SMSC47M1_REG_ALARM) >> 6; + /* Clear alarms if needed */ + if (data->alarms) + smsc47m1_write_value(data, SMSC47M1_REG_ALARM, 0xC0); + + if (fan_nr >= 3) { + data->fan_div[2] = (smsc47m1_read_value(data, + SMSC47M2_REG_FANDIV3) >> 4) & 0x03; + data->alarms |= (smsc47m1_read_value(data, + SMSC47M2_REG_ALARM6) & 0x40) >> 4; + /* Clear alarm if needed */ + if (data->alarms & 0x04) + smsc47m1_write_value(data, + SMSC47M2_REG_ALARM6, + 0x40); + } + + data->last_updated = jiffies; + } + + mutex_unlock(&data->update_lock); + return data; +} static ssize_t get_fan(struct device *dev, struct device_attribute *devattr, char *buf) @@ -668,7 +704,7 @@ static int __init smsc47m1_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct smsc47m1_sio_data *sio_data = dev->platform_data; + struct smsc47m1_sio_data *sio_data = dev_get_platdata(dev); struct smsc47m1_data *data; struct resource *res; int err; @@ -811,54 +847,12 @@ return 0; } -static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, - int init) -{ - struct smsc47m1_data *data = dev_get_drvdata(dev); - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) { - int i, fan_nr; - fan_nr = data->type == smsc47m2 ? 3 : 2; - - for (i = 0; i < fan_nr; i++) { - data->fan[i] = smsc47m1_read_value(data, - SMSC47M1_REG_FAN[i]); - data->fan_preload[i] = smsc47m1_read_value(data, - SMSC47M1_REG_FAN_PRELOAD[i]); - data->pwm[i] = smsc47m1_read_value(data, - SMSC47M1_REG_PWM[i]); - } - - i = smsc47m1_read_value(data, SMSC47M1_REG_FANDIV); - data->fan_div[0] = (i >> 4) & 0x03; - data->fan_div[1] = i >> 6; - - data->alarms = smsc47m1_read_value(data, - SMSC47M1_REG_ALARM) >> 6; - /* Clear alarms if needed */ - if (data->alarms) - smsc47m1_write_value(data, SMSC47M1_REG_ALARM, 0xC0); - - if (fan_nr >= 3) { - data->fan_div[2] = (smsc47m1_read_value(data, - SMSC47M2_REG_FANDIV3) >> 4) & 0x03; - data->alarms |= (smsc47m1_read_value(data, - SMSC47M2_REG_ALARM6) & 0x40) >> 4; - /* Clear alarm if needed */ - if (data->alarms & 0x04) - smsc47m1_write_value(data, - SMSC47M2_REG_ALARM6, - 0x40); - } - - data->last_updated = jiffies; - } - - mutex_unlock(&data->update_lock); - return data; -} +static struct platform_driver smsc47m1_driver = { + .driver = { + .name = DRVNAME, + }, + .remove = __exit_p(smsc47m1_remove), +}; static int __init smsc47m1_device_add(unsigned short address, const struct smsc47m1_sio_data *sio_data) @@ -940,7 +934,7 @@ static void __exit sm_smsc47m1_exit(void) { platform_driver_unregister(&smsc47m1_driver); - smsc47m1_restore(pdev->dev.platform_data); + smsc47m1_restore(dev_get_platdata(&pdev->dev)); platform_device_unregister(pdev); }