diff options
| -rw-r--r-- | drivers/hwmon/pc87427.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c index a4b1b8b828c5..0ac55ba6c6b8 100644 --- a/drivers/hwmon/pc87427.c +++ b/drivers/hwmon/pc87427.c | |||
| @@ -217,9 +217,8 @@ done: | |||
| 217 | static ssize_t show_fan_input(struct device *dev, struct device_attribute | 217 | static ssize_t show_fan_input(struct device *dev, struct device_attribute |
| 218 | *devattr, char *buf) | 218 | *devattr, char *buf) |
| 219 | { | 219 | { |
| 220 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
| 221 | struct pc87427_data *data = pc87427_update_device(dev); | 220 | struct pc87427_data *data = pc87427_update_device(dev); |
| 222 | int nr = attr->index; | 221 | int nr = to_sensor_dev_attr(devattr)->index; |
| 223 | 222 | ||
| 224 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan[nr])); | 223 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan[nr])); |
| 225 | } | 224 | } |
| @@ -227,9 +226,8 @@ static ssize_t show_fan_input(struct device *dev, struct device_attribute | |||
| 227 | static ssize_t show_fan_min(struct device *dev, struct device_attribute | 226 | static ssize_t show_fan_min(struct device *dev, struct device_attribute |
| 228 | *devattr, char *buf) | 227 | *devattr, char *buf) |
| 229 | { | 228 | { |
| 230 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
| 231 | struct pc87427_data *data = pc87427_update_device(dev); | 229 | struct pc87427_data *data = pc87427_update_device(dev); |
| 232 | int nr = attr->index; | 230 | int nr = to_sensor_dev_attr(devattr)->index; |
| 233 | 231 | ||
| 234 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan_min[nr])); | 232 | return sprintf(buf, "%lu\n", fan_from_reg(data->fan_min[nr])); |
| 235 | } | 233 | } |
| @@ -237,9 +235,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute | |||
| 237 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute | 235 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute |
| 238 | *devattr, char *buf) | 236 | *devattr, char *buf) |
| 239 | { | 237 | { |
| 240 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
| 241 | struct pc87427_data *data = pc87427_update_device(dev); | 238 | struct pc87427_data *data = pc87427_update_device(dev); |
| 242 | int nr = attr->index; | 239 | int nr = to_sensor_dev_attr(devattr)->index; |
| 243 | 240 | ||
| 244 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] | 241 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] |
| 245 | & FAN_STATUS_LOSPD)); | 242 | & FAN_STATUS_LOSPD)); |
| @@ -248,9 +245,8 @@ static ssize_t show_fan_alarm(struct device *dev, struct device_attribute | |||
| 248 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute | 245 | static ssize_t show_fan_fault(struct device *dev, struct device_attribute |
| 249 | *devattr, char *buf) | 246 | *devattr, char *buf) |
| 250 | { | 247 | { |
| 251 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | ||
| 252 | struct pc87427_data *data = pc87427_update_device(dev); | 248 | struct pc87427_data *data = pc87427_update_device(dev); |
| 253 | int nr = attr->index; | 249 | int nr = to_sensor_dev_attr(devattr)->index; |
| 254 | 250 | ||
| 255 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] | 251 | return sprintf(buf, "%d\n", !!(data->fan_status[nr] |
| 256 | & FAN_STATUS_STALL)); | 252 | & FAN_STATUS_STALL)); |
| @@ -260,11 +256,13 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
| 260 | *devattr, const char *buf, size_t count) | 256 | *devattr, const char *buf, size_t count) |
| 261 | { | 257 | { |
| 262 | struct pc87427_data *data = dev_get_drvdata(dev); | 258 | struct pc87427_data *data = dev_get_drvdata(dev); |
| 263 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); | 259 | int nr = to_sensor_dev_attr(devattr)->index; |
| 264 | int nr = attr->index; | 260 | unsigned long val; |
| 265 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
| 266 | int iobase = data->address[LD_FAN]; | 261 | int iobase = data->address[LD_FAN]; |
| 267 | 262 | ||
| 263 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 264 | return -EINVAL; | ||
| 265 | |||
| 268 | mutex_lock(&data->lock); | 266 | mutex_lock(&data->lock); |
| 269 | outb(BANK_FM(nr), iobase + PC87427_REG_BANK); | 267 | outb(BANK_FM(nr), iobase + PC87427_REG_BANK); |
| 270 | /* The low speed limit registers are read-only while monitoring | 268 | /* The low speed limit registers are read-only while monitoring |
| @@ -441,7 +439,8 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
| 441 | struct resource *res; | 439 | struct resource *res; |
| 442 | int i, err; | 440 | int i, err; |
| 443 | 441 | ||
| 444 | if (!(data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL))) { | 442 | data = kzalloc(sizeof(struct pc87427_data), GFP_KERNEL); |
| 443 | if (!data) { | ||
| 445 | err = -ENOMEM; | 444 | err = -ENOMEM; |
| 446 | printk(KERN_ERR DRVNAME ": Out of memory\n"); | 445 | printk(KERN_ERR DRVNAME ": Out of memory\n"); |
| 447 | goto exit; | 446 | goto exit; |
| @@ -464,13 +463,15 @@ static int __devinit pc87427_probe(struct platform_device *pdev) | |||
| 464 | pc87427_init_device(&pdev->dev); | 463 | pc87427_init_device(&pdev->dev); |
| 465 | 464 | ||
| 466 | /* Register sysfs hooks */ | 465 | /* Register sysfs hooks */ |
| 467 | if ((err = device_create_file(&pdev->dev, &dev_attr_name))) | 466 | err = device_create_file(&pdev->dev, &dev_attr_name); |
| 467 | if (err) | ||
| 468 | goto exit_release_region; | 468 | goto exit_release_region; |
| 469 | for (i = 0; i < 8; i++) { | 469 | for (i = 0; i < 8; i++) { |
| 470 | if (!(data->fan_enabled & (1 << i))) | 470 | if (!(data->fan_enabled & (1 << i))) |
| 471 | continue; | 471 | continue; |
| 472 | if ((err = sysfs_create_group(&pdev->dev.kobj, | 472 | err = sysfs_create_group(&pdev->dev.kobj, |
| 473 | &pc87427_group_fan[i]))) | 473 | &pc87427_group_fan[i]); |
| 474 | if (err) | ||
| 474 | goto exit_remove_files; | 475 | goto exit_remove_files; |
| 475 | } | 476 | } |
| 476 | 477 | ||
