Skip to content

Commit

Permalink
Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/jdelvare/staging

Pull hwmon updates from Jean Delvare:
 "This includes a number of driver conversions to
  devm_hwmon_device_register_with_groups, a few cleanups, and
  support for the ITE IT8623E"

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  hwmon: (it87) Add support for IT8623E
  hwmon: (it87) Fix IT8603E define name
  hwmon: (lm90) Convert to use hwmon_device_register_with_groups
  hwmon: (lm90) Create all sysfs groups in one call
  hwmon: (lm90) Always use the dev variable in the probe function
  hwmon: (lm90) Create most optional attributes with sysfs_create_group
  hwmon: Avoid initializing the same field twice
  hwmon: (pc87360) Avoid initializing the same field twice
  hwmon: (lm80) Convert to use devm_hwmon_device_register_with_groups
  hwmon: (adm1021) Convert to use devm_hwmon_device_register_with_groups
  hwmon: (lm63) Avoid initializing the same field twice
  hwmon: (lm63) Convert to use devm_hwmon_device_register_with_groups
  hwmon: (lm63) Create all sysfs groups in one call
  hwmon: (lm63) Introduce 'dev' variable to point to client->dev
  hwmon: (lm63) Add additional sysfs group for temp2_type attribute
  hwmon: (f71805f) Fix author's address
  • Loading branch information
torvalds committed Apr 6, 2014
2 parents 19bc2ee + 574e9bd commit 3e76b74
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 282 deletions.
10 changes: 5 additions & 5 deletions Documentation/hwmon/it87
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Kernel driver it87
==================

Supported chips:
* IT8603E
* IT8603E/IT8623E
Prefix: 'it8603'
Addresses scanned: from Super I/O config space (8 I/O ports)
Datasheet: Not publicly available
Expand Down Expand Up @@ -94,9 +94,9 @@ motherboard models.
Description
-----------

This driver implements support for the IT8603E, IT8705F, IT8712F, IT8716F,
IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E, IT8771E, IT8772E,
IT8782F, IT8783E/F, and SiS950 chips.
This driver implements support for the IT8603E, IT8623E, IT8705F, IT8712F,
IT8716F, IT8718F, IT8720F, IT8721F, IT8726F, IT8728F, IT8758E, IT8771E,
IT8772E, IT8782F, IT8783E/F, and SiS950 chips.

These chips are 'Super I/O chips', supporting floppy disks, infrared ports,
joysticks and other miscellaneous stuff. For hardware monitoring, they
Expand Down Expand Up @@ -133,7 +133,7 @@ to userspace applications.
The IT8728F, IT8771E, and IT8772E are considered compatible with the IT8721F,
until a datasheet becomes available (hopefully.)

The IT8603E is a custom design, hardware monitoring part is similar to
The IT8603E/IT8623E is a custom design, hardware monitoring part is similar to
IT8728F. It only supports 16-bit fan mode, the full speed mode of the
fan is not supported (value 0 of pwmX_enable).

Expand Down
70 changes: 22 additions & 48 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ enum chips {

/* Each client has this additional data */
struct adm1021_data {
struct device *hwmon_dev;
struct i2c_client *client;
enum chips type;

const struct attribute_group *groups[3];

struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
char low_power; /* !=0 if device in low power mode */
Expand All @@ -101,7 +103,6 @@ static int adm1021_probe(struct i2c_client *client,
static int adm1021_detect(struct i2c_client *client,
struct i2c_board_info *info);
static void adm1021_init_client(struct i2c_client *client);
static int adm1021_remove(struct i2c_client *client);
static struct adm1021_data *adm1021_update_device(struct device *dev);

/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */
Expand All @@ -128,7 +129,6 @@ static struct i2c_driver adm1021_driver = {
.name = "adm1021",
},
.probe = adm1021_probe,
.remove = adm1021_remove,
.id_table = adm1021_id,
.detect = adm1021_detect,
.address_list = normal_i2c,
Expand Down Expand Up @@ -182,8 +182,8 @@ static ssize_t set_temp_max(struct device *dev,
const char *buf, size_t count)
{
int index = to_sensor_dev_attr(devattr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
long temp;
int err;

Expand All @@ -207,8 +207,8 @@ static ssize_t set_temp_min(struct device *dev,
const char *buf, size_t count)
{
int index = to_sensor_dev_attr(devattr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
long temp;
int err;

Expand Down Expand Up @@ -238,8 +238,8 @@ static ssize_t set_low_power(struct device *dev,
struct device_attribute *devattr,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
char low_power;
unsigned long val;
int err;
Expand Down Expand Up @@ -412,45 +412,30 @@ static int adm1021_detect(struct i2c_client *client,
static int adm1021_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct adm1021_data *data;
int err;
struct device *hwmon_dev;

data = devm_kzalloc(&client->dev, sizeof(struct adm1021_data),
GFP_KERNEL);
data = devm_kzalloc(dev, sizeof(struct adm1021_data), GFP_KERNEL);
if (!data)
return -ENOMEM;

i2c_set_clientdata(client, data);
data->client = client;
data->type = id->driver_data;
mutex_init(&data->update_lock);

/* Initialize the ADM1021 chip */
if (data->type != lm84 && !read_only)
adm1021_init_client(client);

/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &adm1021_group);
if (err)
return err;

if (data->type != lm84) {
err = sysfs_create_group(&client->dev.kobj, &adm1021_min_group);
if (err)
goto error;
}
data->groups[0] = &adm1021_group;
if (data->type != lm84)
data->groups[1] = &adm1021_min_group;

data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto error;
}
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data, data->groups);

return 0;

error:
sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
sysfs_remove_group(&client->dev.kobj, &adm1021_group);
return err;
return PTR_ERR_OR_ZERO(hwmon_dev);
}

static void adm1021_init_client(struct i2c_client *client)
Expand All @@ -462,29 +447,18 @@ static void adm1021_init_client(struct i2c_client *client)
i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04);
}

static int adm1021_remove(struct i2c_client *client)
{
struct adm1021_data *data = i2c_get_clientdata(client);

hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
sysfs_remove_group(&client->dev.kobj, &adm1021_group);

return 0;
}

static struct adm1021_data *adm1021_update_device(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;

mutex_lock(&data->update_lock);

if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
int i;

dev_dbg(&client->dev, "Starting adm1021 update\n");
dev_dbg(dev, "Starting adm1021 update\n");

for (i = 0; i < 2; i++) {
data->temp[i] = 1000 *
Expand Down
1 change: 0 additions & 1 deletion drivers/hwmon/asc7621.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,6 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id)
return -ENOMEM;

i2c_set_clientdata(client, data);
data->valid = 0;
mutex_init(&data->update_lock);

/* Initialize the asc7621 chip */
Expand Down
2 changes: 0 additions & 2 deletions drivers/hwmon/atxp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ static int atxp1_probe(struct i2c_client *new_client,
data->vrm = vid_which_vrm();

i2c_set_clientdata(new_client, data);
data->valid = 0;

mutex_init(&data->update_lock);

/* Register sysfs hooks */
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/f71805f.c
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ static void __exit f71805f_exit(void)
platform_driver_unregister(&f71805f_driver);
}

MODULE_AUTHOR("Jean Delvare <khali@linux-fr>");
MODULE_AUTHOR("Jean Delvare <[email protected]>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("F71805F/F71872F hardware monitoring driver");

Expand Down
9 changes: 6 additions & 3 deletions drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* similar parts. The other devices are supported by different drivers.
*
* Supports: IT8603E Super I/O chip w/LPC interface
* IT8623E Super I/O chip w/LPC interface
* IT8705F Super I/O chip w/LPC interface
* IT8712F Super I/O chip w/LPC interface
* IT8716F Super I/O chip w/LPC interface
Expand Down Expand Up @@ -147,7 +148,8 @@ static inline void superio_exit(void)
#define IT8772E_DEVID 0x8772
#define IT8782F_DEVID 0x8782
#define IT8783E_DEVID 0x8783
#define IT8306E_DEVID 0x8603
#define IT8603E_DEVID 0x8603
#define IT8623E_DEVID 0x8623
#define IT87_ACT_REG 0x30
#define IT87_BASE_REG 0x60

Expand Down Expand Up @@ -1431,7 +1433,7 @@ static ssize_t show_label(struct device *dev, struct device_attribute *attr,
static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 0);
static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, show_label, NULL, 1);
static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, show_label, NULL, 2);
/* special AVCC3 IT8306E in9 */
/* special AVCC3 IT8603E in9 */
static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 0);

static ssize_t show_name(struct device *dev, struct device_attribute
Expand Down Expand Up @@ -1766,7 +1768,8 @@ static int __init it87_find(unsigned short *address,
case IT8783E_DEVID:
sio_data->type = it8783;
break;
case IT8306E_DEVID:
case IT8603E_DEVID:
case IT8623E_DEVID:
sio_data->type = it8603;
break;
case 0xffff: /* No device at all */
Expand Down
Loading

0 comments on commit 3e76b74

Please sign in to comment.