--- zzzz-none-000/linux-3.10.107/drivers/hwmon/lm93.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/hwmon/lm93.c 2021-02-04 17:41:59.000000000 +0000 @@ -12,7 +12,7 @@ * Copyright (c) 2003 Margit Schubert-While * * derived in part from w83l785ts.c: - * Copyright (c) 2003-2004 Jean Delvare + * Copyright (c) 2003-2004 Jean Delvare * * Ported to Linux 2.6 by Eric J. Bowersox * Copyright (c) 2005 Aspen Systems, Inc. @@ -207,7 +207,7 @@ * Client-specific data */ struct lm93_data { - struct device *hwmon_dev; + struct i2c_client *client; struct mutex update_lock; unsigned long last_updated; /* In jiffies */ @@ -919,8 +919,8 @@ static struct lm93_data *lm93_update_device(struct device *dev) { - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; const unsigned long interval = HZ + (HZ / 2); mutex_lock(&data->update_lock); @@ -1158,8 +1158,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; int vccp = nr - 6; long vid; unsigned long val; @@ -1239,8 +1239,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; int vccp = nr - 6; long vid; unsigned long val; @@ -1323,8 +1323,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; long val; int err; @@ -1358,8 +1358,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; long val; int err; @@ -1394,8 +1394,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; long val; int err; @@ -1430,8 +1430,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; long val; int err; @@ -1469,8 +1469,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -1520,8 +1520,8 @@ struct sensor_device_attribute_2 *s_attr = to_sensor_dev_attr_2(attr); int nr = s_attr->index; int ofs = s_attr->nr; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -1632,8 +1632,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 reg, ctl4; unsigned long val; int err; @@ -1680,8 +1680,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 reg; unsigned long val; int err; @@ -1741,8 +1741,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -1824,8 +1824,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -1880,8 +1880,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ctl2, ctl4; unsigned long val; int err; @@ -1928,8 +1928,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ctl2; unsigned long val; int err; @@ -2006,8 +2006,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ctl4; unsigned long val; int err; @@ -2046,8 +2046,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -2087,8 +2087,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ctl3, ctl4; unsigned long val; int err; @@ -2130,8 +2130,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ctl3; unsigned long val; int err; @@ -2168,8 +2168,8 @@ struct device_attribute *attr, const char *buf, size_t count) { - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ramp; unsigned long val; int err; @@ -2202,8 +2202,8 @@ struct device_attribute *attr, const char *buf, size_t count) { - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 ramp; unsigned long val; int err; @@ -2270,8 +2270,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -2308,8 +2308,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -2351,8 +2351,8 @@ const char *buf, size_t count) { int nr = (to_sensor_dev_attr(attr))->index; - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; u8 tmp; unsigned long val; int err; @@ -2390,8 +2390,8 @@ struct device_attribute *attr, const char *buf, size_t count) { - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -2423,8 +2423,8 @@ struct device_attribute *attr, const char *buf, size_t count) { - struct i2c_client *client = to_i2c_client(dev); - struct lm93_data *data = i2c_get_clientdata(client); + struct lm93_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; unsigned long val; int err; @@ -2631,9 +2631,7 @@ NULL }; -static struct attribute_group lm93_attr_grp = { - .attrs = lm93_attrs, -}; +ATTRIBUTE_GROUPS(lm93); static void lm93_init_client(struct i2c_client *client) { @@ -2726,64 +2724,42 @@ static int lm93_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device *dev = &client->dev; struct lm93_data *data; - int err, func; + struct device *hwmon_dev; + int func; void (*update)(struct lm93_data *, struct i2c_client *); /* choose update routine based on bus capabilities */ func = i2c_get_functionality(client->adapter); if (((LM93_SMBUS_FUNC_FULL & func) == LM93_SMBUS_FUNC_FULL) && (!disable_block)) { - dev_dbg(&client->dev, "using SMBus block data transactions\n"); + dev_dbg(dev, "using SMBus block data transactions\n"); update = lm93_update_client_full; } else if ((LM93_SMBUS_FUNC_MIN & func) == LM93_SMBUS_FUNC_MIN) { - dev_dbg(&client->dev, - "disabled SMBus block data transactions\n"); + dev_dbg(dev, "disabled SMBus block data transactions\n"); update = lm93_update_client_min; } else { - dev_dbg(&client->dev, - "detect failed, smbus byte and/or word data not supported!\n"); + dev_dbg(dev, "detect failed, smbus byte and/or word data not supported!\n"); return -ENODEV; } - data = devm_kzalloc(&client->dev, sizeof(struct lm93_data), GFP_KERNEL); - if (!data) { - dev_dbg(&client->dev, "out of memory!\n"); + data = devm_kzalloc(dev, sizeof(struct lm93_data), GFP_KERNEL); + if (!data) return -ENOMEM; - } - i2c_set_clientdata(client, data); /* housekeeping */ - data->valid = 0; + data->client = client; data->update = update; mutex_init(&data->update_lock); /* initialize the chip */ lm93_init_client(client); - err = sysfs_create_group(&client->dev.kobj, &lm93_attr_grp); - if (err) - return err; - - /* Register hwmon driver class */ - data->hwmon_dev = hwmon_device_register(&client->dev); - if (!IS_ERR(data->hwmon_dev)) - return 0; - - err = PTR_ERR(data->hwmon_dev); - dev_err(&client->dev, "error registering hwmon device.\n"); - sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); - return err; -} - -static int lm93_remove(struct i2c_client *client) -{ - struct lm93_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &lm93_attr_grp); - - return 0; + hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, + data, + lm93_groups); + return PTR_ERR_OR_ZERO(hwmon_dev); } static const struct i2c_device_id lm93_id[] = { @@ -2799,7 +2775,6 @@ .name = "lm93", }, .probe = lm93_probe, - .remove = lm93_remove, .id_table = lm93_id, .detect = lm93_detect, .address_list = normal_i2c,