Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84525
b: refs/heads/master
c: f67fdab
h: refs/heads/master
i:
  84523: ebab962
v: v3
  • Loading branch information
Jean Delvare authored and Mark M. Hoffman committed Feb 8, 2008
1 parent 17a221c commit 0a0e482
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb01a2312f56c93d2740e827718966b92b7cbb91
refs/heads/master: f67fdabfb94b0bb96623a4b48d22be5329a06277
52 changes: 21 additions & 31 deletions trunk/drivers/hwmon/adm1026.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_FROM_REG(val) (((val)*2500)/255)

/* Typically used with systems using a v9.1 VRM spec ? */
#define ADM1026_INIT_VRM 91

/* Chip sampling rates
*
* Some sensors are not updated more frequently than once per second
Expand Down Expand Up @@ -264,7 +261,6 @@ struct pwm_data {
struct adm1026_data {
struct i2c_client client;
struct device *hwmon_dev;
enum chips type;

struct mutex update_lock;
int valid; /* !=0 if following fields are valid */
Expand Down Expand Up @@ -387,7 +383,6 @@ static void adm1026_init_client(struct i2c_client *client)
"and temp limits enabled.\n");
}

value = data->config3;
if (data->config3 & CFG3_GPIO16_ENABLE) {
dev_dbg(&client->dev, "GPIO16 enabled. THERM "
"pin disabled.\n");
Expand Down Expand Up @@ -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,
size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1026_data *data = i2c_get_clientdata(client);
struct adm1026_data *data = dev_get_drvdata(dev);

data->vrm = simple_strtol(buf, NULL, 10);
return count;
Expand All @@ -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)
{
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);
Expand Down Expand Up @@ -1641,7 +1635,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
int kind)
{
int company, verstep;
struct i2c_client *new_client;
struct i2c_client *client;
struct adm1026_data *data;
int err = 0;
const char *type_name = "";
Expand All @@ -1660,26 +1654,25 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
goto exit;
}

new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
new_client->driver = &adm1026_driver;
new_client->flags = 0;
client = &data->client;
i2c_set_clientdata(client, data);
client->addr = address;
client->adapter = adapter;
client->driver = &adm1026_driver;

/* Now, we do the remaining detection. */

company = adm1026_read_value(new_client, ADM1026_REG_COMPANY);
verstep = adm1026_read_value(new_client, ADM1026_REG_VERSTEP);
company = adm1026_read_value(client, ADM1026_REG_COMPANY);
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",
i2c_adapter_id(new_client->adapter), new_client->addr,
i2c_adapter_id(client->adapter), client->addr,
company, verstep);

/* If auto-detecting, Determine the chip type. */
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);
if (company == ADM1026_COMPANY_ANALOG_DEV
&& verstep == ADM1026_VERSTEP_ADM1026) {
Expand All @@ -1695,7 +1688,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
verstep);
kind = any_chip;
} else {
dev_dbg(&new_client->dev, ": Autodetection "
dev_dbg(&client->dev, ": Autodetection "
"failed\n");
/* Not an ADM1026 ... */
if (kind == 0) { /* User used force=x,y */
Expand All @@ -1704,7 +1697,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
"force_adm1026.\n",
i2c_adapter_id(adapter), address);
}
err = 0;
goto exitfree;
}
}
Expand All @@ -1723,28 +1715,26 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
err = -EFAULT;
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 */
data->type = kind;
data->valid = 0;
mutex_init(&data->update_lock);

/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
if ((err = i2c_attach_client(client)))
goto exitfree;

/* Set the VRM version */
data->vrm = vid_which_vrm();

/* Initialize the ADM1026 chip */
adm1026_init_client(new_client);
adm1026_init_client(client);

/* 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;

data->hwmon_dev = hwmon_device_register(&new_client->dev);
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exitremove;
Expand All @@ -1754,9 +1744,9 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,

/* Error out and cleanup code */
exitremove:
sysfs_remove_group(&new_client->dev.kobj, &adm1026_group);
sysfs_remove_group(&client->dev.kobj, &adm1026_group);
exitdetach:
i2c_detach_client(new_client);
i2c_detach_client(client);
exitfree:
kfree(data);
exit:
Expand Down

0 comments on commit 0a0e482

Please sign in to comment.