Commit f67fdabf authored by Jean Delvare's avatar Jean Delvare Committed by Mark M. Hoffman

hwmon: (adm1026) More cleanups (updated)

Various cleanups:
* Drop an unused define.
* Drop unused struct member "type".
* Drop one useless instruction.
* Drop redundant initializations to 0.
* Rename new_client to client.
* Drop a useless cast.
* Minor code cleanup.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
parent cb01a231
...@@ -232,9 +232,6 @@ static int adm1026_scaling[] = { /* .001 Volts */ ...@@ -232,9 +232,6 @@ static int adm1026_scaling[] = { /* .001 Volts */
#define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255)) #define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255))
#define DAC_FROM_REG(val) (((val)*2500)/255) #define DAC_FROM_REG(val) (((val)*2500)/255)
/* Typically used with systems using a v9.1 VRM spec ? */
#define ADM1026_INIT_VRM 91
/* Chip sampling rates /* Chip sampling rates
* *
* Some sensors are not updated more frequently than once per second * Some sensors are not updated more frequently than once per second
...@@ -264,7 +261,6 @@ struct pwm_data { ...@@ -264,7 +261,6 @@ struct pwm_data {
struct adm1026_data { struct adm1026_data {
struct i2c_client client; struct i2c_client client;
struct device *hwmon_dev; struct device *hwmon_dev;
enum chips type;
struct mutex update_lock; struct mutex update_lock;
int valid; /* !=0 if following fields are valid */ int valid; /* !=0 if following fields are valid */
...@@ -387,7 +383,6 @@ static void adm1026_init_client(struct i2c_client *client) ...@@ -387,7 +383,6 @@ static void adm1026_init_client(struct i2c_client *client)
"and temp limits enabled.\n"); "and temp limits enabled.\n");
} }
value = data->config3;
if (data->config3 & CFG3_GPIO16_ENABLE) { if (data->config3 & CFG3_GPIO16_ENABLE) {
dev_dbg(&client->dev, "GPIO16 enabled. THERM " dev_dbg(&client->dev, "GPIO16 enabled. THERM "
"pin disabled.\n"); "pin disabled.\n");
...@@ -1230,8 +1225,7 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, c ...@@ -1230,8 +1225,7 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, c
static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf,
size_t count) size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adm1026_data *data = dev_get_drvdata(dev);
struct adm1026_data *data = i2c_get_clientdata(client);
data->vrm = simple_strtol(buf, NULL, 10); data->vrm = simple_strtol(buf, NULL, 10);
return count; return count;
...@@ -1242,7 +1236,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); ...@@ -1242,7 +1236,7 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
{ {
struct adm1026_data *data = adm1026_update_device(dev); struct adm1026_data *data = adm1026_update_device(dev);
return sprintf(buf, "%ld\n", (long) (data->alarms)); return sprintf(buf, "%ld\n", data->alarms);
} }
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
...@@ -1641,7 +1635,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1641,7 +1635,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
int kind) int kind)
{ {
int company, verstep; int company, verstep;
struct i2c_client *new_client; struct i2c_client *client;
struct adm1026_data *data; struct adm1026_data *data;
int err = 0; int err = 0;
const char *type_name = ""; const char *type_name = "";
...@@ -1660,26 +1654,25 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1660,26 +1654,25 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
goto exit; goto exit;
} }
new_client = &data->client; client = &data->client;
i2c_set_clientdata(new_client, data); i2c_set_clientdata(client, data);
new_client->addr = address; client->addr = address;
new_client->adapter = adapter; client->adapter = adapter;
new_client->driver = &adm1026_driver; client->driver = &adm1026_driver;
new_client->flags = 0;
/* Now, we do the remaining detection. */ /* Now, we do the remaining detection. */
company = adm1026_read_value(new_client, ADM1026_REG_COMPANY); company = adm1026_read_value(client, ADM1026_REG_COMPANY);
verstep = adm1026_read_value(new_client, ADM1026_REG_VERSTEP); verstep = adm1026_read_value(client, ADM1026_REG_VERSTEP);
dev_dbg(&new_client->dev, "Detecting device at %d,0x%02x with" dev_dbg(&client->dev, "Detecting device at %d,0x%02x with"
" COMPANY: 0x%02x and VERSTEP: 0x%02x\n", " COMPANY: 0x%02x and VERSTEP: 0x%02x\n",
i2c_adapter_id(new_client->adapter), new_client->addr, i2c_adapter_id(client->adapter), client->addr,
company, verstep); company, verstep);
/* If auto-detecting, Determine the chip type. */ /* If auto-detecting, Determine the chip type. */
if (kind <= 0) { if (kind <= 0) {
dev_dbg(&new_client->dev, "Autodetecting device at %d,0x%02x " dev_dbg(&client->dev, "Autodetecting device at %d,0x%02x "
"...\n", i2c_adapter_id(adapter), address); "...\n", i2c_adapter_id(adapter), address);
if (company == ADM1026_COMPANY_ANALOG_DEV if (company == ADM1026_COMPANY_ANALOG_DEV
&& verstep == ADM1026_VERSTEP_ADM1026) { && verstep == ADM1026_VERSTEP_ADM1026) {
...@@ -1695,7 +1688,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1695,7 +1688,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
verstep); verstep);
kind = any_chip; kind = any_chip;
} else { } else {
dev_dbg(&new_client->dev, ": Autodetection " dev_dbg(&client->dev, ": Autodetection "
"failed\n"); "failed\n");
/* Not an ADM1026 ... */ /* Not an ADM1026 ... */
if (kind == 0) { /* User used force=x,y */ if (kind == 0) { /* User used force=x,y */
...@@ -1704,7 +1697,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1704,7 +1697,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
"force_adm1026.\n", "force_adm1026.\n",
i2c_adapter_id(adapter), address); i2c_adapter_id(adapter), address);
} }
err = 0;
goto exitfree; goto exitfree;
} }
} }
...@@ -1723,28 +1715,26 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1723,28 +1715,26 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
err = -EFAULT; err = -EFAULT;
goto exitfree; goto exitfree;
} }
strlcpy(new_client->name, type_name, I2C_NAME_SIZE); strlcpy(client->name, type_name, I2C_NAME_SIZE);
/* Fill in the remaining client fields */ /* Fill in the remaining client fields */
data->type = kind;
data->valid = 0;
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */ /* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client))) if ((err = i2c_attach_client(client)))
goto exitfree; goto exitfree;
/* Set the VRM version */ /* Set the VRM version */
data->vrm = vid_which_vrm(); data->vrm = vid_which_vrm();
/* Initialize the ADM1026 chip */ /* Initialize the ADM1026 chip */
adm1026_init_client(new_client); adm1026_init_client(client);
/* Register sysfs hooks */ /* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1026_group))) if ((err = sysfs_create_group(&client->dev.kobj, &adm1026_group)))
goto exitdetach; goto exitdetach;
data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
goto exitremove; goto exitremove;
...@@ -1754,9 +1744,9 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, ...@@ -1754,9 +1744,9 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
/* Error out and cleanup code */ /* Error out and cleanup code */
exitremove: exitremove:
sysfs_remove_group(&new_client->dev.kobj, &adm1026_group); sysfs_remove_group(&client->dev.kobj, &adm1026_group);
exitdetach: exitdetach:
i2c_detach_client(new_client); i2c_detach_client(client);
exitfree: exitfree:
kfree(data); kfree(data);
exit: exit:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment