From f0967eea80ec2a19a4fe1ad27e3ff1b22c79a3c7 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 20 Jan 2012 15:38:18 +0800 Subject: hwmon: convert drivers/hwmon/* to use module_i2c_driver() This patch converts the drivers in drivers/hwmon/* to use the module_i2c_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin Cc: Corentin Labbe Cc: Dirk Eibach Cc: "Mark M. Hoffman" Cc: Steve Glendinning Cc: Riku Voipio Cc: Guillaume Ligneul Cc: David George Cc: "Hans J. Koch" Cc: Marc Hulsman Cc: Rudolf Marek Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/ucd9000.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'drivers/hwmon/pmbus/ucd9000.c') diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index 4ff6cf289f85..759a563de636 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c @@ -258,18 +258,8 @@ static struct i2c_driver ucd9000_driver = { .id_table = ucd9000_id, }; -static int __init ucd9000_init(void) -{ - return i2c_add_driver(&ucd9000_driver); -} - -static void __exit ucd9000_exit(void) -{ - i2c_del_driver(&ucd9000_driver); -} +module_i2c_driver(ucd9000_driver); MODULE_AUTHOR("Guenter Roeck"); MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx"); MODULE_LICENSE("GPL"); -module_init(ucd9000_init); -module_exit(ucd9000_exit); -- cgit v1.2.3 From 8b313ca7f1b98263ce22519b25a9c2a362eeb898 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 22 Feb 2012 08:56:43 -0800 Subject: hwmon: (pmbus) Convert pmbus drivers to use devm_kzalloc Marginally less code and eliminate the possibility of memory leaks. Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/adm1275.c | 16 +++--------- drivers/hwmon/pmbus/lm25066.c | 26 +++++-------------- drivers/hwmon/pmbus/ltc2978.c | 30 ++++++---------------- drivers/hwmon/pmbus/pmbus.c | 17 +++---------- drivers/hwmon/pmbus/pmbus_core.c | 54 ++++++++++++++-------------------------- drivers/hwmon/pmbus/ucd9000.c | 26 ++++++------------- drivers/hwmon/pmbus/ucd9200.c | 22 +++++----------- drivers/hwmon/pmbus/zl6100.c | 19 ++++---------- 8 files changed, 56 insertions(+), 154 deletions(-) (limited to 'drivers/hwmon/pmbus/ucd9000.c') diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index fe52c3cf87ba..f81cb4adaeba 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -229,7 +229,8 @@ static int adm1275_probe(struct i2c_client *client, if (device_config < 0) return device_config; - data = kzalloc(sizeof(struct adm1275_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data), + GFP_KERNEL); if (!data) return -ENOMEM; @@ -297,23 +298,12 @@ static int adm1275_probe(struct i2c_client *client, break; } - ret = pmbus_do_probe(client, id, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(data); - return ret; + return pmbus_do_probe(client, id, info); } static int adm1275_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - const struct adm1275_data *data = to_adm1275_data(info); - pmbus_do_remove(client); - kfree(data); return 0; } diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index 86ac15ade6ab..e70d4ca14fbe 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -176,7 +176,6 @@ static int lm25066_probe(struct i2c_client *client, const struct i2c_device_id *id) { int config; - int ret; struct lm25066_data *data; struct pmbus_driver_info *info; @@ -184,15 +183,14 @@ static int lm25066_probe(struct i2c_client *client, I2C_FUNC_SMBUS_READ_BYTE_DATA)) return -ENODEV; - data = kzalloc(sizeof(struct lm25066_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct lm25066_data), + GFP_KERNEL); if (!data) return -ENOMEM; config = i2c_smbus_read_byte_data(client, LM25066_DEVICE_SETUP); - if (config < 0) { - ret = config; - goto err_mem; - } + if (config < 0) + return config; data->id = id->driver_data; info = &data->info; @@ -291,27 +289,15 @@ static int lm25066_probe(struct i2c_client *client, } break; default: - ret = -ENODEV; - goto err_mem; + return -ENODEV; } - ret = pmbus_do_probe(client, id, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(data); - return ret; + return pmbus_do_probe(client, id, info); } static int lm25066_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - const struct lm25066_data *data = to_lm25066_data(info); - pmbus_do_remove(client); - kfree(data); return 0; } diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c index c9e4dd20bf9c..5e07a363b3e9 100644 --- a/drivers/hwmon/pmbus/ltc2978.c +++ b/drivers/hwmon/pmbus/ltc2978.c @@ -287,7 +287,7 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id); static int ltc2978_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int chip_id, ret, i; + int chip_id, i; struct ltc2978_data *data; struct pmbus_driver_info *info; @@ -295,15 +295,14 @@ static int ltc2978_probe(struct i2c_client *client, I2C_FUNC_SMBUS_READ_WORD_DATA)) return -ENODEV; - data = kzalloc(sizeof(struct ltc2978_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct ltc2978_data), + GFP_KERNEL); if (!data) return -ENOMEM; chip_id = i2c_smbus_read_word_data(client, LTC2978_MFR_SPECIAL_ID); - if (chip_id < 0) { - ret = chip_id; - goto err_mem; - } + if (chip_id < 0) + return chip_id; if (chip_id == LTC2978_ID_REV1 || chip_id == LTC2978_ID_REV2) { data->id = ltc2978; @@ -311,8 +310,7 @@ static int ltc2978_probe(struct i2c_client *client, data->id = ltc3880; } else { dev_err(&client->dev, "Unsupported chip ID 0x%x\n", chip_id); - ret = -ENODEV; - goto err_mem; + return -ENODEV; } if (data->id != id->driver_data) dev_warn(&client->dev, @@ -357,27 +355,15 @@ static int ltc2978_probe(struct i2c_client *client, data->vout_min[1] = 0xffff; break; default: - ret = -ENODEV; - goto err_mem; + return -ENODEV; } - ret = pmbus_do_probe(client, id, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(data); - return ret; + return pmbus_do_probe(client, id, info); } static int ltc2978_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - const struct ltc2978_data *data = to_ltc2978_data(info); - pmbus_do_remove(client); - kfree(data); return 0; } diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index da5fe361a940..b94bec23d95c 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -166,32 +166,21 @@ static int pmbus_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct pmbus_driver_info *info; - int ret; - info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), + GFP_KERNEL); if (!info) return -ENOMEM; info->pages = id->driver_data; info->identify = pmbus_identify; - ret = pmbus_do_probe(client, id, info); - if (ret < 0) - goto out; - return 0; - -out: - kfree(info); - return ret; + return pmbus_do_probe(client, id, info); } static int pmbus_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info; - - info = pmbus_get_driver_info(client); pmbus_do_remove(client); - kfree(info); return 0; } diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index f571388d88fd..26b6542a90cd 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1676,7 +1676,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) { dev_err(&client->dev, "No memory to allocate driver data\n"); return -ENOMEM; @@ -1688,8 +1688,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, /* Bail out if PMBus status register does not exist. */ if (i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE) < 0) { dev_err(&client->dev, "PMBus status register not found\n"); - ret = -ENODEV; - goto out_data; + return -ENODEV; } if (pdata) @@ -1702,50 +1701,49 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, ret = (*info->identify)(client, info); if (ret < 0) { dev_err(&client->dev, "Chip identification failed\n"); - goto out_data; + return ret; } } if (info->pages <= 0 || info->pages > PMBUS_PAGES) { dev_err(&client->dev, "Bad number of PMBus pages: %d\n", info->pages); - ret = -ENODEV; - goto out_data; + return -ENODEV; } ret = pmbus_identify_common(client, data); if (ret < 0) { dev_err(&client->dev, "Failed to identify chip capabilities\n"); - goto out_data; + return ret; } ret = -ENOMEM; - data->sensors = kzalloc(sizeof(struct pmbus_sensor) * data->max_sensors, - GFP_KERNEL); + data->sensors = devm_kzalloc(&client->dev, sizeof(struct pmbus_sensor) + * data->max_sensors, GFP_KERNEL); if (!data->sensors) { dev_err(&client->dev, "No memory to allocate sensor data\n"); - goto out_data; + return -ENOMEM; } - data->booleans = kzalloc(sizeof(struct pmbus_boolean) + data->booleans = devm_kzalloc(&client->dev, sizeof(struct pmbus_boolean) * data->max_booleans, GFP_KERNEL); if (!data->booleans) { dev_err(&client->dev, "No memory to allocate boolean data\n"); - goto out_sensors; + return -ENOMEM; } - data->labels = kzalloc(sizeof(struct pmbus_label) * data->max_labels, - GFP_KERNEL); + data->labels = devm_kzalloc(&client->dev, sizeof(struct pmbus_label) + * data->max_labels, GFP_KERNEL); if (!data->labels) { dev_err(&client->dev, "No memory to allocate label data\n"); - goto out_booleans; + return -ENOMEM; } - data->attributes = kzalloc(sizeof(struct attribute *) - * data->max_attributes, GFP_KERNEL); + data->attributes = devm_kzalloc(&client->dev, sizeof(struct attribute *) + * data->max_attributes, GFP_KERNEL); if (!data->attributes) { dev_err(&client->dev, "No memory to allocate attribute data\n"); - goto out_labels; + return -ENOMEM; } pmbus_find_attributes(client, data); @@ -1756,8 +1754,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, */ if (!data->num_attributes) { dev_err(&client->dev, "No attributes found\n"); - ret = -ENODEV; - goto out_attributes; + return -ENODEV; } /* Register sysfs hooks */ @@ -1765,7 +1762,7 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, ret = sysfs_create_group(&client->dev.kobj, &data->group); if (ret) { dev_err(&client->dev, "Failed to create sysfs entries\n"); - goto out_attributes; + return ret; } data->hwmon_dev = hwmon_device_register(&client->dev); if (IS_ERR(data->hwmon_dev)) { @@ -1777,16 +1774,6 @@ int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, out_hwmon_device_register: sysfs_remove_group(&client->dev.kobj, &data->group); -out_attributes: - kfree(data->attributes); -out_labels: - kfree(data->labels); -out_booleans: - kfree(data->booleans); -out_sensors: - kfree(data->sensors); -out_data: - kfree(data); return ret; } EXPORT_SYMBOL_GPL(pmbus_do_probe); @@ -1796,11 +1783,6 @@ void pmbus_do_remove(struct i2c_client *client) struct pmbus_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &data->group); - kfree(data->attributes); - kfree(data->labels); - kfree(data->booleans); - kfree(data->sensors); - kfree(data); } EXPORT_SYMBOL_GPL(pmbus_do_remove); diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index 759a563de636..e0573459447c 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c @@ -155,7 +155,8 @@ static int ucd9000_probe(struct i2c_client *client, "Device mismatch: Configured %s, detected %s\n", id->name, mid->name); - data = kzalloc(sizeof(struct ucd9000_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), + GFP_KERNEL); if (!data) return -ENOMEM; info = &data->info; @@ -164,13 +165,12 @@ static int ucd9000_probe(struct i2c_client *client, if (ret < 0) { dev_err(&client->dev, "Failed to read number of active pages\n"); - goto out; + return ret; } info->pages = ret; if (!info->pages) { dev_err(&client->dev, "No pages configured\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } /* The internal temperature sensor is always active */ @@ -181,8 +181,7 @@ static int ucd9000_probe(struct i2c_client *client, block_buffer); if (ret <= 0) { dev_err(&client->dev, "Failed to read configuration data\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } for (i = 0; i < ret; i++) { int page = UCD9000_MON_PAGE(block_buffer[i]); @@ -218,7 +217,7 @@ static int ucd9000_probe(struct i2c_client *client, UCD9000_FAN_CONFIG, data->fan_data[i]); if (ret < 0) - goto out; + return ret; } i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0); @@ -227,23 +226,12 @@ static int ucd9000_probe(struct i2c_client *client, | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34; } - ret = pmbus_do_probe(client, mid, info); - if (ret < 0) - goto out; - return 0; - -out: - kfree(data); - return ret; + return pmbus_do_probe(client, mid, info); } static int ucd9000_remove(struct i2c_client *client) { - struct ucd9000_data *data; - - data = to_ucd9000_data(pmbus_get_driver_info(client)); pmbus_do_remove(client); - kfree(data); return 0; } diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index 629d0c93cac6..c0d41b993a53 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c @@ -81,7 +81,8 @@ static int ucd9200_probe(struct i2c_client *client, "Device mismatch: Configured %s, detected %s\n", id->name, mid->name); - info = kzalloc(sizeof(struct pmbus_driver_info), GFP_KERNEL); + info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), + GFP_KERNEL); if (!info) return -ENOMEM; @@ -89,7 +90,7 @@ static int ucd9200_probe(struct i2c_client *client, block_buffer); if (ret < 0) { dev_err(&client->dev, "Failed to read phase information\n"); - goto out; + return ret; } /* @@ -106,8 +107,7 @@ static int ucd9200_probe(struct i2c_client *client, } if (!info->pages) { dev_err(&client->dev, "No rails configured\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } dev_info(&client->dev, "%d rails configured\n", info->pages); @@ -137,7 +137,7 @@ static int ucd9200_probe(struct i2c_client *client, if (ret < 0) { dev_err(&client->dev, "Failed to initialize PHASE registers\n"); - goto out; + return ret; } } if (info->pages > 1) @@ -160,22 +160,12 @@ static int ucd9200_probe(struct i2c_client *client, if (mid->driver_data == ucd9240) info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12; - ret = pmbus_do_probe(client, mid, info); - if (ret < 0) - goto out; - return 0; -out: - kfree(info); - return ret; + return pmbus_do_probe(client, mid, info); } static int ucd9200_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info; - - info = pmbus_get_driver_info(client); pmbus_do_remove(client); - kfree(info); return 0; } diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c index 8ae658118bec..9d3b84535e73 100644 --- a/drivers/hwmon/pmbus/zl6100.c +++ b/drivers/hwmon/pmbus/zl6100.c @@ -193,7 +193,8 @@ static int zl6100_probe(struct i2c_client *client, "Device mismatch: Configured %s, detected %s\n", id->name, mid->name); - data = kzalloc(sizeof(struct zl6100_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct zl6100_data), + GFP_KERNEL); if (!data) return -ENOMEM; @@ -223,7 +224,8 @@ static int zl6100_probe(struct i2c_client *client, ret = i2c_smbus_read_word_data(client, ZL6100_MFR_CONFIG); if (ret < 0) - goto err_mem; + return ret; + if (ret & ZL6100_MFR_XTEMP_ENABLE) info->func[0] |= PMBUS_HAVE_TEMP2; @@ -235,23 +237,12 @@ static int zl6100_probe(struct i2c_client *client, info->write_word_data = zl6100_write_word_data; info->write_byte = zl6100_write_byte; - ret = pmbus_do_probe(client, mid, info); - if (ret) - goto err_mem; - return 0; - -err_mem: - kfree(data); - return ret; + return pmbus_do_probe(client, mid, info); } static int zl6100_remove(struct i2c_client *client) { - const struct pmbus_driver_info *info = pmbus_get_driver_info(client); - const struct zl6100_data *data = to_zl6100_data(info); - pmbus_do_remove(client); - kfree(data); return 0; } -- cgit v1.2.3 From dd285ad7373bf5d21cceacb3b7a5eb8b72d37085 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Wed, 22 Feb 2012 08:56:44 -0800 Subject: hwmon: (pmbus) Simplify remove functions Since devm_kzalloc() is now used to allocate driver memory, the client driver remove function has no purpose other than to call pmbus_do_remove(). This means we can get rid of it by redefining pmbus_do_remove() to use the same prototype, and pointing to it directly. Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/adm1275.c | 8 +------- drivers/hwmon/pmbus/lm25066.c | 8 +------- drivers/hwmon/pmbus/ltc2978.c | 8 +------- drivers/hwmon/pmbus/max16064.c | 8 +------- drivers/hwmon/pmbus/max34440.c | 8 +------- drivers/hwmon/pmbus/max8688.c | 8 +------- drivers/hwmon/pmbus/pmbus.c | 8 +------- drivers/hwmon/pmbus/pmbus.h | 2 +- drivers/hwmon/pmbus/pmbus_core.c | 3 ++- drivers/hwmon/pmbus/ucd9000.c | 9 +-------- drivers/hwmon/pmbus/ucd9200.c | 9 +-------- drivers/hwmon/pmbus/zl6100.c | 8 +------- 12 files changed, 13 insertions(+), 74 deletions(-) (limited to 'drivers/hwmon/pmbus/ucd9000.c') diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index f81cb4adaeba..5e4421e57eb0 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -301,18 +301,12 @@ static int adm1275_probe(struct i2c_client *client, return pmbus_do_probe(client, id, info); } -static int adm1275_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static struct i2c_driver adm1275_driver = { .driver = { .name = "adm1275", }, .probe = adm1275_probe, - .remove = adm1275_remove, + .remove = pmbus_do_remove, .id_table = adm1275_id, }; diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index e70d4ca14fbe..c299392716af 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -295,12 +295,6 @@ static int lm25066_probe(struct i2c_client *client, return pmbus_do_probe(client, id, info); } -static int lm25066_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static const struct i2c_device_id lm25066_id[] = { {"lm25066", lm25066}, {"lm5064", lm5064}, @@ -316,7 +310,7 @@ static struct i2c_driver lm25066_driver = { .name = "lm25066", }, .probe = lm25066_probe, - .remove = lm25066_remove, + .remove = pmbus_do_remove, .id_table = lm25066_id, }; diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c index 5e07a363b3e9..9652a2c92a24 100644 --- a/drivers/hwmon/pmbus/ltc2978.c +++ b/drivers/hwmon/pmbus/ltc2978.c @@ -361,19 +361,13 @@ static int ltc2978_probe(struct i2c_client *client, return pmbus_do_probe(client, id, info); } -static int ltc2978_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - /* This is the driver that will be inserted */ static struct i2c_driver ltc2978_driver = { .driver = { .name = "ltc2978", }, .probe = ltc2978_probe, - .remove = ltc2978_remove, + .remove = pmbus_do_remove, .id_table = ltc2978_id, }; diff --git a/drivers/hwmon/pmbus/max16064.c b/drivers/hwmon/pmbus/max16064.c index 5cfe20f1e030..fa237a3c3291 100644 --- a/drivers/hwmon/pmbus/max16064.c +++ b/drivers/hwmon/pmbus/max16064.c @@ -103,12 +103,6 @@ static int max16064_probe(struct i2c_client *client, return pmbus_do_probe(client, id, &max16064_info); } -static int max16064_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static const struct i2c_device_id max16064_id[] = { {"max16064", 0}, {} @@ -122,7 +116,7 @@ static struct i2c_driver max16064_driver = { .name = "max16064", }, .probe = max16064_probe, - .remove = max16064_remove, + .remove = pmbus_do_remove, .id_table = max16064_id, }; diff --git a/drivers/hwmon/pmbus/max34440.c b/drivers/hwmon/pmbus/max34440.c index d9026f9ff13e..7d830c1e7032 100644 --- a/drivers/hwmon/pmbus/max34440.c +++ b/drivers/hwmon/pmbus/max34440.c @@ -224,12 +224,6 @@ static int max34440_probe(struct i2c_client *client, return pmbus_do_probe(client, id, &max34440_info[id->driver_data]); } -static int max34440_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static const struct i2c_device_id max34440_id[] = { {"max34440", max34440}, {"max34441", max34441}, @@ -244,7 +238,7 @@ static struct i2c_driver max34440_driver = { .name = "max34440", }, .probe = max34440_probe, - .remove = max34440_remove, + .remove = pmbus_do_remove, .id_table = max34440_id, }; diff --git a/drivers/hwmon/pmbus/max8688.c b/drivers/hwmon/pmbus/max8688.c index 82c598d7cfa3..f04454a42fdd 100644 --- a/drivers/hwmon/pmbus/max8688.c +++ b/drivers/hwmon/pmbus/max8688.c @@ -180,12 +180,6 @@ static int max8688_probe(struct i2c_client *client, return pmbus_do_probe(client, id, &max8688_info); } -static int max8688_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static const struct i2c_device_id max8688_id[] = { {"max8688", 0}, { } @@ -199,7 +193,7 @@ static struct i2c_driver max8688_driver = { .name = "max8688", }, .probe = max8688_probe, - .remove = max8688_remove, + .remove = pmbus_do_remove, .id_table = max8688_id, }; diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index b94bec23d95c..34887408505b 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -178,12 +178,6 @@ static int pmbus_probe(struct i2c_client *client, return pmbus_do_probe(client, id, info); } -static int pmbus_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - /* * Use driver_data to set the number of pages supported by the chip. */ @@ -209,7 +203,7 @@ static struct i2c_driver pmbus_driver = { .name = "pmbus", }, .probe = pmbus_probe, - .remove = pmbus_remove, + .remove = pmbus_do_remove, .id_table = pmbus_id, }; diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 5d31d1c2c0f5..0b17d4f20f81 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -364,7 +364,7 @@ bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, struct pmbus_driver_info *info); -void pmbus_do_remove(struct i2c_client *client); +int pmbus_do_remove(struct i2c_client *client); const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 26b6542a90cd..aada0c67a911 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1778,11 +1778,12 @@ out_hwmon_device_register: } EXPORT_SYMBOL_GPL(pmbus_do_probe); -void pmbus_do_remove(struct i2c_client *client) +int pmbus_do_remove(struct i2c_client *client) { struct pmbus_data *data = i2c_get_clientdata(client); hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&client->dev.kobj, &data->group); + return 0; } EXPORT_SYMBOL_GPL(pmbus_do_remove); diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index e0573459447c..fbb1479d3ad4 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c @@ -229,20 +229,13 @@ static int ucd9000_probe(struct i2c_client *client, return pmbus_do_probe(client, mid, info); } -static int ucd9000_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - - /* This is the driver that will be inserted */ static struct i2c_driver ucd9000_driver = { .driver = { .name = "ucd9000", }, .probe = ucd9000_probe, - .remove = ucd9000_remove, + .remove = pmbus_do_remove, .id_table = ucd9000_id, }; diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index c0d41b993a53..033d6aca47d3 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c @@ -163,20 +163,13 @@ static int ucd9200_probe(struct i2c_client *client, return pmbus_do_probe(client, mid, info); } -static int ucd9200_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - - /* This is the driver that will be inserted */ static struct i2c_driver ucd9200_driver = { .driver = { .name = "ucd9200", }, .probe = ucd9200_probe, - .remove = ucd9200_remove, + .remove = pmbus_do_remove, .id_table = ucd9200_id, }; diff --git a/drivers/hwmon/pmbus/zl6100.c b/drivers/hwmon/pmbus/zl6100.c index 9d3b84535e73..e5bb7355d480 100644 --- a/drivers/hwmon/pmbus/zl6100.c +++ b/drivers/hwmon/pmbus/zl6100.c @@ -240,18 +240,12 @@ static int zl6100_probe(struct i2c_client *client, return pmbus_do_probe(client, mid, info); } -static int zl6100_remove(struct i2c_client *client) -{ - pmbus_do_remove(client); - return 0; -} - static struct i2c_driver zl6100_driver = { .driver = { .name = "zl6100", }, .probe = zl6100_probe, - .remove = zl6100_remove, + .remove = pmbus_do_remove, .id_table = zl6100_id, }; -- cgit v1.2.3