提交 d27c37c0 编写于 作者: J Jean Delvare 提交者: Jean Delvare

hwmon/w83627hf: Preliminary cleanups

Some preliminary cleanups to the w83627hf hardware monitoring driver,
to make its conversion to a platform driver easier:

* Add missing include ioport.h
* Drop unused enum value any_chip
* Group module parameters
* Define and use DRVNAME
* Drop unused struct member lm75
* Move the handling of force_addr and device activation to
  w83627hf_find
* Consistently use local type in w83627hf_init_client
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 e46751bf
...@@ -48,9 +48,16 @@ ...@@ -48,9 +48,16 @@
#include <linux/hwmon-vid.h> #include <linux/hwmon-vid.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/ioport.h>
#include <asm/io.h> #include <asm/io.h>
#include "lm75.h" #include "lm75.h"
/* The actual ISA address is read from Super-I/O configuration space */
static unsigned short address;
#define DRVNAME "w83627hf"
enum chips { w83627hf, w83627thf, w83697hf, w83637hf, w83687thf };
static u16 force_addr; static u16 force_addr;
module_param(force_addr, ushort, 0); module_param(force_addr, ushort, 0);
MODULE_PARM_DESC(force_addr, MODULE_PARM_DESC(force_addr,
...@@ -60,12 +67,6 @@ module_param(force_i2c, byte, 0); ...@@ -60,12 +67,6 @@ module_param(force_i2c, byte, 0);
MODULE_PARM_DESC(force_i2c, MODULE_PARM_DESC(force_i2c,
"Initialize the i2c address of the sensors"); "Initialize the i2c address of the sensors");
/* The actual ISA address is read from Super-I/O configuration space */
static unsigned short address;
/* Insmod parameters */
enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf };
static int reset; static int reset;
module_param(reset, bool, 0); module_param(reset, bool, 0);
MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); MODULE_PARM_DESC(reset, "Set to one to reset chip on load");
...@@ -298,9 +299,6 @@ struct w83627hf_data { ...@@ -298,9 +299,6 @@ struct w83627hf_data {
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
struct i2c_client *lm75; /* for secondary I2C addresses */
/* pointer to array of 2 subclients */
u8 in[9]; /* Register value */ u8 in[9]; /* Register value */
u8 in_max[9]; /* Register value */ u8 in_max[9]; /* Register value */
u8 in_min[9]; /* Register value */ u8 in_min[9]; /* Register value */
...@@ -339,7 +337,7 @@ static void w83627hf_init_client(struct i2c_client *client); ...@@ -339,7 +337,7 @@ static void w83627hf_init_client(struct i2c_client *client);
static struct i2c_driver w83627hf_driver = { static struct i2c_driver w83627hf_driver = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "w83627hf", .name = DRVNAME,
}, },
.attach_adapter = w83627hf_detect, .attach_adapter = w83627hf_detect,
.detach_client = w83627hf_detach_client, .detach_client = w83627hf_detach_client,
...@@ -931,6 +929,7 @@ sysfs_sensor(3); ...@@ -931,6 +929,7 @@ sysfs_sensor(3);
static int __init w83627hf_find(int sioaddr, unsigned short *addr) static int __init w83627hf_find(int sioaddr, unsigned short *addr)
{ {
int err = -ENODEV;
u16 val; u16 val;
REG = sioaddr; REG = sioaddr;
...@@ -943,21 +942,37 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr) ...@@ -943,21 +942,37 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr)
val != W697_DEVID && val != W697_DEVID &&
val != W637_DEVID && val != W637_DEVID &&
val != W687THF_DEVID) { val != W687THF_DEVID) {
superio_exit(); goto exit;
return -ENODEV;
} }
superio_select(W83627HF_LD_HWM); superio_select(W83627HF_LD_HWM);
force_addr &= WINB_ALIGNMENT;
if (force_addr) {
printk(KERN_WARNING DRVNAME ": Forcing address 0x%x\n",
force_addr);
superio_outb(WINB_BASE_REG, force_addr >> 8);
superio_outb(WINB_BASE_REG + 1, force_addr & 0xff);
}
val = (superio_inb(WINB_BASE_REG) << 8) | val = (superio_inb(WINB_BASE_REG) << 8) |
superio_inb(WINB_BASE_REG + 1); superio_inb(WINB_BASE_REG + 1);
*addr = val & WINB_ALIGNMENT; *addr = val & WINB_ALIGNMENT;
if (*addr == 0 && force_addr == 0) { if (*addr == 0) {
superio_exit(); printk(KERN_WARNING DRVNAME ": Base address not set, "
return -ENODEV; "skipping\n");
goto exit;
}
val = superio_inb(WINB_ACT_REG);
if (!(val & 0x01)) {
printk(KERN_WARNING DRVNAME ": Enabling HWM logical device\n");
superio_outb(WINB_ACT_REG, val | 0x01);
} }
err = 0;
exit:
superio_exit(); superio_exit();
return 0; return err;
} }
static struct attribute *w83627hf_attributes[] = { static struct attribute *w83627hf_attributes[] = {
...@@ -1047,24 +1062,12 @@ static int w83627hf_detect(struct i2c_adapter *adapter) ...@@ -1047,24 +1062,12 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
int err = 0; int err = 0;
const char *client_name = ""; const char *client_name = "";
if(force_addr)
address = force_addr & WINB_ALIGNMENT;
if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE,
w83627hf_driver.driver.name)) { w83627hf_driver.driver.name)) {
err = -EBUSY; err = -EBUSY;
goto ERROR0; goto ERROR0;
} }
if(force_addr) {
printk("w83627hf.o: forcing ISA address 0x%04X\n", address);
superio_enter();
superio_select(W83627HF_LD_HWM);
superio_outb(WINB_BASE_REG, address >> 8);
superio_outb(WINB_BASE_REG+1, address & 0xff);
superio_exit();
}
superio_enter(); superio_enter();
val= superio_inb(DEVID); val= superio_inb(DEVID);
if(val == W627_DEVID) if(val == W627_DEVID)
...@@ -1082,10 +1085,6 @@ static int w83627hf_detect(struct i2c_adapter *adapter) ...@@ -1082,10 +1085,6 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
"Unsupported chip (dev_id=0x%02X).\n", val); "Unsupported chip (dev_id=0x%02X).\n", val);
goto ERROR1; goto ERROR1;
} }
superio_select(W83627HF_LD_HWM);
if((val = 0x01 & superio_inb(WINB_ACT_REG)) == 0)
superio_outb(WINB_ACT_REG, 1);
superio_exit(); superio_exit();
/* OK. For now, we presume we have a valid client. We now create the /* OK. For now, we presume we have a valid client. We now create the
...@@ -1128,8 +1127,6 @@ static int w83627hf_detect(struct i2c_adapter *adapter) ...@@ -1128,8 +1127,6 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
if ((err = i2c_attach_client(new_client))) if ((err = i2c_attach_client(new_client)))
goto ERROR2; goto ERROR2;
data->lm75 = NULL;
/* Initialize the chip */ /* Initialize the chip */
w83627hf_init_client(new_client); w83627hf_init_client(new_client);
...@@ -1374,7 +1371,7 @@ static void w83627hf_init_client(struct i2c_client *client) ...@@ -1374,7 +1371,7 @@ static void w83627hf_init_client(struct i2c_client *client)
{ {
struct w83627hf_data *data = i2c_get_clientdata(client); struct w83627hf_data *data = i2c_get_clientdata(client);
int i; int i;
int type = data->type; enum chips type = data->type;
u8 tmp; u8 tmp;
if (reset) { if (reset) {
...@@ -1407,19 +1404,18 @@ static void w83627hf_init_client(struct i2c_client *client) ...@@ -1407,19 +1404,18 @@ static void w83627hf_init_client(struct i2c_client *client)
w83627hf_write_value(client, W83781D_REG_I2C_ADDR, force_i2c); w83627hf_write_value(client, W83781D_REG_I2C_ADDR, force_i2c);
/* Read VID only once */ /* Read VID only once */
if (w83627hf == data->type || w83637hf == data->type) { if (type == w83627hf || type == w83637hf) {
int lo = w83627hf_read_value(client, W83781D_REG_VID_FANDIV); int lo = w83627hf_read_value(client, W83781D_REG_VID_FANDIV);
int hi = w83627hf_read_value(client, W83781D_REG_CHIPID); int hi = w83627hf_read_value(client, W83781D_REG_CHIPID);
data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); data->vid = (lo & 0x0f) | ((hi & 0x01) << 4);
} else if (w83627thf == data->type) { } else if (type == w83627thf) {
data->vid = w83627thf_read_gpio5(client); data->vid = w83627thf_read_gpio5(client);
} else if (w83687thf == data->type) { } else if (type == w83687thf) {
data->vid = w83687thf_read_vid(client); data->vid = w83687thf_read_vid(client);
} }
/* Read VRM & OVT Config only once */ /* Read VRM & OVT Config only once */
if (w83627thf == data->type || w83637hf == data->type if (type == w83627thf || type == w83637hf || type == w83687thf) {
|| w83687thf == data->type) {
data->vrm_ovt = data->vrm_ovt =
w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册