hwmon: (smsc47m1) Avoid forward declaration

Reorder functions to avoid forward declaration.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Axel Lin 2014-07-17 19:15:36 +08:00 committed by Guenter Roeck
parent 166f72966d
commit e70198acf8

View File

@ -142,11 +142,6 @@ struct smsc47m1_sio_data {
u8 activate; /* Remember initial device state */ 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) static inline int smsc47m1_read_value(struct smsc47m1_data *data, u8 reg)
{ {
return inb_p(data->addr + reg); return inb_p(data->addr + reg);
@ -158,13 +153,54 @@ static inline void smsc47m1_write_value(struct smsc47m1_data *data, u8 reg,
outb_p(value, data->addr + reg); outb_p(value, data->addr + reg);
} }
static struct platform_driver smsc47m1_driver = { static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
.driver = { int init)
.owner = THIS_MODULE, {
.name = DRVNAME, struct smsc47m1_data *data = dev_get_drvdata(dev);
},
.remove = __exit_p(smsc47m1_remove), 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 static ssize_t get_fan(struct device *dev, struct device_attribute
*devattr, char *buf) *devattr, char *buf)
@ -811,54 +847,13 @@ static int __exit smsc47m1_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static struct platform_driver smsc47m1_driver = {
int init) .driver = {
{ .owner = THIS_MODULE,
struct smsc47m1_data *data = dev_get_drvdata(dev); .name = DRVNAME,
},
mutex_lock(&data->update_lock); .remove = __exit_p(smsc47m1_remove),
};
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 int __init smsc47m1_device_add(unsigned short address, static int __init smsc47m1_device_add(unsigned short address,
const struct smsc47m1_sio_data *sio_data) const struct smsc47m1_sio_data *sio_data)