hwmon: (vt8231) Reorder symbols to get rid of a few forward declarations

Declarations for static symbols are useless repetition unless there are
cyclic dependencies.

Reorder the functions and variables to get rid of 5 forward declarations.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220920135617.1046361-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Uwe Kleine-König 2022-09-20 15:56:17 +02:00 committed by Guenter Roeck
parent 6c7c469c80
commit ac387b0cb3

View File

@ -164,10 +164,6 @@ struct vt8231_data {
};
static struct pci_dev *s_bridge;
static int vt8231_probe(struct platform_device *pdev);
static int vt8231_remove(struct platform_device *pdev);
static struct vt8231_data *vt8231_update_device(struct device *dev);
static void vt8231_init_device(struct vt8231_data *data);
static inline int vt8231_read_value(struct vt8231_data *data, u8 reg)
{
@ -180,6 +176,74 @@ static inline void vt8231_write_value(struct vt8231_data *data, u8 reg,
outb_p(value, data->addr + reg);
}
static struct vt8231_data *vt8231_update_device(struct device *dev)
{
struct vt8231_data *data = dev_get_drvdata(dev);
int i;
u16 low;
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
for (i = 0; i < 6; i++) {
if (ISVOLT(i, data->uch_config)) {
data->in[i] = vt8231_read_value(data,
regvolt[i]);
data->in_min[i] = vt8231_read_value(data,
regvoltmin[i]);
data->in_max[i] = vt8231_read_value(data,
regvoltmax[i]);
}
}
for (i = 0; i < 2; i++) {
data->fan[i] = vt8231_read_value(data,
VT8231_REG_FAN(i));
data->fan_min[i] = vt8231_read_value(data,
VT8231_REG_FAN_MIN(i));
}
low = vt8231_read_value(data, VT8231_REG_TEMP_LOW01);
low = (low >> 6) | ((low & 0x30) >> 2)
| (vt8231_read_value(data, VT8231_REG_TEMP_LOW25) << 4);
for (i = 0; i < 6; i++) {
if (ISTEMP(i, data->uch_config)) {
data->temp[i] = (vt8231_read_value(data,
regtemp[i]) << 2)
| ((low >> (2 * i)) & 0x03);
data->temp_max[i] = vt8231_read_value(data,
regtempmax[i]);
data->temp_min[i] = vt8231_read_value(data,
regtempmin[i]);
}
}
i = vt8231_read_value(data, VT8231_REG_FANDIV);
data->fan_div[0] = (i >> 4) & 0x03;
data->fan_div[1] = i >> 6;
data->alarms = vt8231_read_value(data, VT8231_REG_ALARM1) |
(vt8231_read_value(data, VT8231_REG_ALARM2) << 8);
/* Set alarm flags correctly */
if (!data->fan[0] && data->fan_min[0])
data->alarms |= 0x40;
else if (data->fan[0] && !data->fan_min[0])
data->alarms &= ~0x40;
if (!data->fan[1] && data->fan_min[1])
data->alarms |= 0x80;
else if (data->fan[1] && !data->fan_min[1])
data->alarms &= ~0x80;
data->last_updated = jiffies;
data->valid = true;
}
mutex_unlock(&data->update_lock);
return data;
}
/* following are the sysfs callback functions */
static ssize_t in_show(struct device *dev, struct device_attribute *attr,
char *buf)
@ -753,29 +817,11 @@ static const struct attribute_group vt8231_group = {
.attrs = vt8231_attributes,
};
static struct platform_driver vt8231_driver = {
.driver = {
.name = DRIVER_NAME,
},
.probe = vt8231_probe,
.remove = vt8231_remove,
};
static const struct pci_device_id vt8231_pci_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) },
{ 0, }
};
MODULE_DEVICE_TABLE(pci, vt8231_pci_ids);
static int vt8231_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id);
static struct pci_driver vt8231_pci_driver = {
.name = DRIVER_NAME,
.id_table = vt8231_pci_ids,
.probe = vt8231_pci_probe,
};
static void vt8231_init_device(struct vt8231_data *data)
{
vt8231_write_value(data, VT8231_REG_TEMP1_CONFIG, 0);
vt8231_write_value(data, VT8231_REG_TEMP2_CONFIG, 0);
}
static int vt8231_probe(struct platform_device *pdev)
{
@ -865,79 +911,21 @@ static int vt8231_remove(struct platform_device *pdev)
return 0;
}
static void vt8231_init_device(struct vt8231_data *data)
{
vt8231_write_value(data, VT8231_REG_TEMP1_CONFIG, 0);
vt8231_write_value(data, VT8231_REG_TEMP2_CONFIG, 0);
}
static struct vt8231_data *vt8231_update_device(struct device *dev)
{
struct vt8231_data *data = dev_get_drvdata(dev);
int i;
u16 low;
static struct platform_driver vt8231_driver = {
.driver = {
.name = DRIVER_NAME,
},
.probe = vt8231_probe,
.remove = vt8231_remove,
};
mutex_lock(&data->update_lock);
static const struct pci_device_id vt8231_pci_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) },
{ 0, }
};
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
for (i = 0; i < 6; i++) {
if (ISVOLT(i, data->uch_config)) {
data->in[i] = vt8231_read_value(data,
regvolt[i]);
data->in_min[i] = vt8231_read_value(data,
regvoltmin[i]);
data->in_max[i] = vt8231_read_value(data,
regvoltmax[i]);
}
}
for (i = 0; i < 2; i++) {
data->fan[i] = vt8231_read_value(data,
VT8231_REG_FAN(i));
data->fan_min[i] = vt8231_read_value(data,
VT8231_REG_FAN_MIN(i));
}
low = vt8231_read_value(data, VT8231_REG_TEMP_LOW01);
low = (low >> 6) | ((low & 0x30) >> 2)
| (vt8231_read_value(data, VT8231_REG_TEMP_LOW25) << 4);
for (i = 0; i < 6; i++) {
if (ISTEMP(i, data->uch_config)) {
data->temp[i] = (vt8231_read_value(data,
regtemp[i]) << 2)
| ((low >> (2 * i)) & 0x03);
data->temp_max[i] = vt8231_read_value(data,
regtempmax[i]);
data->temp_min[i] = vt8231_read_value(data,
regtempmin[i]);
}
}
i = vt8231_read_value(data, VT8231_REG_FANDIV);
data->fan_div[0] = (i >> 4) & 0x03;
data->fan_div[1] = i >> 6;
data->alarms = vt8231_read_value(data, VT8231_REG_ALARM1) |
(vt8231_read_value(data, VT8231_REG_ALARM2) << 8);
/* Set alarm flags correctly */
if (!data->fan[0] && data->fan_min[0])
data->alarms |= 0x40;
else if (data->fan[0] && !data->fan_min[0])
data->alarms &= ~0x40;
if (!data->fan[1] && data->fan_min[1])
data->alarms |= 0x80;
else if (data->fan[1] && !data->fan_min[1])
data->alarms &= ~0x80;
data->last_updated = jiffies;
data->valid = true;
}
mutex_unlock(&data->update_lock);
return data;
}
MODULE_DEVICE_TABLE(pci, vt8231_pci_ids);
static int vt8231_device_add(unsigned short address)
{
@ -1042,6 +1030,12 @@ exit:
return -ENODEV;
}
static struct pci_driver vt8231_pci_driver = {
.name = DRIVER_NAME,
.id_table = vt8231_pci_ids,
.probe = vt8231_pci_probe,
};
static int __init sm_vt8231_init(void)
{
return pci_register_driver(&vt8231_pci_driver);