From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934866AbcCJC3g (ORCPT ); Wed, 9 Mar 2016 21:29:36 -0500 Received: from forward.webhostbox.net ([5.100.155.97]:49460 "EHLO forward.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934832AbcCJC3Y (ORCPT ); Wed, 9 Mar 2016 21:29:24 -0500 Subject: Re: [PATCH 04/13] hwmon: convert scpi-hwmon to use devm_thermal_zone_of_sensor_register To: Eduardo Valentin , Rui Zhang References: <1457559336-17652-1-git-send-email-edubezval@gmail.com> <1457559336-17652-5-git-send-email-edubezval@gmail.com> Cc: Linux PM , LKML , lm-sensors@lm-sensors.org, Jean Delvare From: Guenter Roeck Message-ID: <56E0DBFD.7060903@roeck-us.net> Date: Wed, 9 Mar 2016 18:29:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1457559336-17652-5-git-send-email-edubezval@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=NfdGrz34 c=1 sm=1 tr=0 a=QNED+QcLUkoL9qulTODnwA==:117 a=2cfIYNtKkjgZNaOwnGXpGw==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=N659UExz7-8A:10 a=7OsogOcEt9IA:10 a=R6F98OrSRw-DJ7q4F1oA:9 a=pILNOxqGKmIA:10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/2016 01:35 PM, Eduardo Valentin wrote: > This changes the driver to use the devm_ version > of thermal_zone_of_sensor_register and cleans > up the local points and unregister calls. > > Cc: Jean Delvare > Cc: Guenter Roeck > Cc: lm-sensors@lm-sensors.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Eduardo Valentin > --- > drivers/hwmon/scpi-hwmon.c | 41 ++++++++--------------------------------- > 1 file changed, 8 insertions(+), 33 deletions(-) > > diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c > index 7e20567..2309e47 100644 > --- a/drivers/hwmon/scpi-hwmon.c > +++ b/drivers/hwmon/scpi-hwmon.c > @@ -31,10 +31,8 @@ struct sensor_data { > }; > > struct scpi_thermal_zone { > - struct list_head list; > int sensor_id; > struct scpi_sensors *scpi_sensors; > - struct thermal_zone_device *tzd; > }; > > struct scpi_sensors { > @@ -92,20 +90,6 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf) > return sprintf(buf, "%s\n", sensor->info.name); > } > > -static void > -unregister_thermal_zones(struct platform_device *pdev, > - struct scpi_sensors *scpi_sensors) > -{ > - struct list_head *pos; > - > - list_for_each(pos, &scpi_sensors->thermal_zones) { > - struct scpi_thermal_zone *zone; > - > - zone = list_entry(pos, struct scpi_thermal_zone, list); > - thermal_zone_of_sensor_unregister(&pdev->dev, zone->tzd); > - } > -} > - > static struct thermal_zone_of_device_ops scpi_sensor_ops = { > .get_temp = scpi_read_temp, > }; > @@ -224,6 +208,7 @@ static int scpi_hwmon_probe(struct platform_device *pdev) > INIT_LIST_HEAD(&scpi_sensors->thermal_zones); > for (i = 0; i < nr_sensors; i++) { > struct sensor_data *sensor = &scpi_sensors->data[i]; > + struct thermal_zone_device *z; > struct scpi_thermal_zone *zone; > > if (sensor->info.class != TEMPERATURE) > @@ -232,42 +217,33 @@ static int scpi_hwmon_probe(struct platform_device *pdev) > zone = devm_kzalloc(dev, sizeof(*zone), GFP_KERNEL); > if (!zone) { > ret = -ENOMEM; > - goto unregister_tzd; > + goto mfail; return -ENOMEM; ... and drop the unnecessary label. Thanks, Guenter > } > > zone->sensor_id = i; > zone->scpi_sensors = scpi_sensors; > - zone->tzd = thermal_zone_of_sensor_register(dev, > - sensor->info.sensor_id, zone, &scpi_sensor_ops); > + z = devm_thermal_zone_of_sensor_register(dev, > + sensor->info.sensor_id, > + zone, > + &scpi_sensor_ops); > /* > * The call to thermal_zone_of_sensor_register returns > * an error for sensors that are not associated with > * any thermal zones or if the thermal subsystem is > * not configured. > */ > - if (IS_ERR(zone->tzd)) { > + if (IS_ERR(z)) { > devm_kfree(dev, zone); > continue; > } > - list_add(&zone->list, &scpi_sensors->thermal_zones); > } > > return 0; > > -unregister_tzd: > - unregister_thermal_zones(pdev, scpi_sensors); > +mfail: > return ret; > } > > -static int scpi_hwmon_remove(struct platform_device *pdev) > -{ > - struct scpi_sensors *scpi_sensors = platform_get_drvdata(pdev); > - > - unregister_thermal_zones(pdev, scpi_sensors); > - > - return 0; > -} > - > static const struct of_device_id scpi_of_match[] = { > {.compatible = "arm,scpi-sensors"}, > {}, > @@ -280,7 +256,6 @@ static struct platform_driver scpi_hwmon_platdrv = { > .of_match_table = scpi_of_match, > }, > .probe = scpi_hwmon_probe, > - .remove = scpi_hwmon_remove, > }; > module_platform_driver(scpi_hwmon_platdrv); > >