From patchwork Fri Jul 29 21:42:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9252831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92A4760757 for ; Fri, 29 Jul 2016 21:42:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8063A28409 for ; Fri, 29 Jul 2016 21:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FCE22842B; Fri, 29 Jul 2016 21:42:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B015E28409 for ; Fri, 29 Jul 2016 21:42:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754173AbcG2Vmz (ORCPT ); Fri, 29 Jul 2016 17:42:55 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:48089 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbcG2Vmy (ORCPT ); Fri, 29 Jul 2016 17:42:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=VXWJnPL92MvppxYtsaUKRMv/bA3CUPKsa102vqVxkaw=; b=AOxTinEB/WqbzU z8RISLE/IjB3e8ciTAaFVE3bUiOq9+IdWXG1hbHk2ggtfK2tulVaTtK5pxVLatnBE8q6N1mGle0fb /sdB/P/I3ed37nvFHaQR4uvTmnu3zG+0WMwBsa1ifz0Su7pGYFMTaduZnnv9qfo8NokQ0Foea1KAw 4BkeQekJT/5v4Rc7mzSZ3HxPCr6Qc5u+mHSrGm5Iwp3EYBP5rkeo3+6aK4xhsAuLwW9GZxzkxj4/0 ypJpGwPHGTtaIhSQKqe3R5o08DhAzDoiQOvhxjemMAOkrQERZRqWJJm/E1uSjcjpBZKrEBIqpXZQT M8DLs0w+DvtDkcwnSJSw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:44808 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bTFYN-000qIf-DS; Fri, 29 Jul 2016 21:42:47 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 2/3] hwmon: (ntc_thermistor) Use dev instead of &pdev->dev where possible Date: Fri, 29 Jul 2016 14:42:43 -0700 Message-Id: <1469828564-21928-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1469828564-21928-1-git-send-email-linux@roeck-us.net> References: <1469828564-21928-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of repeatedly accessing &pdev->dev, use a local variable dev instead where possible. Also drop 'dev' from private data since it is unnecessary. Signed-off-by: Guenter Roeck --- drivers/hwmon/ntc_thermistor.c | 52 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index 485701ca3609..6b2d5222521f 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -256,7 +256,6 @@ struct ntc_data { struct device *hwmon_dev; struct ntc_thermistor_platform_data *pdata; const struct ntc_compensation *comp; - struct device *dev; int n_comp; char name[PLATFORM_NAME_SIZE]; }; @@ -316,22 +315,22 @@ static const struct of_device_id ntc_match[] = { MODULE_DEVICE_TABLE(of, ntc_match); static struct ntc_thermistor_platform_data * -ntc_thermistor_parse_dt(struct platform_device *pdev) +ntc_thermistor_parse_dt(struct device *dev) { struct iio_channel *chan; enum iio_chan_type type; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; struct ntc_thermistor_platform_data *pdata; int ret; if (!np) return NULL; - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); - chan = devm_iio_channel_get(&pdev->dev, NULL); + chan = devm_iio_channel_get(dev, NULL); if (IS_ERR(chan)) return ERR_CAST(chan); @@ -361,7 +360,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) } #else static struct ntc_thermistor_platform_data * -ntc_thermistor_parse_dt(struct platform_device *pdev) +ntc_thermistor_parse_dt(struct device *dev) { return NULL; } @@ -572,33 +571,34 @@ static const struct thermal_zone_of_device_ops ntc_of_thermal_ops = { static int ntc_thermistor_probe(struct platform_device *pdev) { struct thermal_zone_device *tz; + struct device *dev = &pdev->dev; const struct of_device_id *of_id = - of_match_device(of_match_ptr(ntc_match), &pdev->dev); + of_match_device(of_match_ptr(ntc_match), dev); const struct platform_device_id *pdev_id; struct ntc_thermistor_platform_data *pdata; struct ntc_data *data; int ret; - pdata = ntc_thermistor_parse_dt(pdev); + pdata = ntc_thermistor_parse_dt(dev); if (IS_ERR(pdata)) return PTR_ERR(pdata); else if (pdata == NULL) - pdata = dev_get_platdata(&pdev->dev); + pdata = dev_get_platdata(dev); if (!pdata) { - dev_err(&pdev->dev, "No platform init data supplied.\n"); + dev_err(dev, "No platform init data supplied.\n"); return -ENODEV; } /* Either one of the two is required. */ if (!pdata->read_uv && !pdata->read_ohm) { - dev_err(&pdev->dev, + dev_err(dev, "Both read_uv and read_ohm missing. Need either one of the two.\n"); return -EINVAL; } if (pdata->read_uv && pdata->read_ohm) { - dev_warn(&pdev->dev, + dev_warn(dev, "Only one of read_uv and read_ohm is needed; ignoring read_uv.\n"); pdata->read_uv = NULL; } @@ -610,18 +610,16 @@ static int ntc_thermistor_probe(struct platform_device *pdev) NTC_CONNECTED_POSITIVE) || (pdata->connect != NTC_CONNECTED_POSITIVE && pdata->connect != NTC_CONNECTED_GROUND))) { - dev_err(&pdev->dev, - "Required data to use read_uv not supplied.\n"); + dev_err(dev, "Required data to use read_uv not supplied.\n"); return -EINVAL; } - data = devm_kzalloc(&pdev->dev, sizeof(struct ntc_data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(struct ntc_data), GFP_KERNEL); if (!data) return -ENOMEM; pdev_id = of_id ? of_id->data : platform_get_device_id(pdev); - data->dev = &pdev->dev; data->pdata = pdata; strlcpy(data->name, pdev_id->name, sizeof(data->name)); @@ -647,37 +645,37 @@ static int ntc_thermistor_probe(struct platform_device *pdev) data->n_comp = ARRAY_SIZE(ncpXXxh103); break; default: - dev_err(&pdev->dev, "Unknown device type: %lu(%s)\n", + dev_err(dev, "Unknown device type: %lu(%s)\n", pdev_id->driver_data, pdev_id->name); return -EINVAL; } platform_set_drvdata(pdev, data); - ret = sysfs_create_group(&data->dev->kobj, &ntc_attr_group); + ret = sysfs_create_group(&dev->kobj, &ntc_attr_group); if (ret) { - dev_err(data->dev, "unable to create sysfs files\n"); + dev_err(dev, "unable to create sysfs files\n"); return ret; } - data->hwmon_dev = hwmon_device_register(data->dev); + data->hwmon_dev = hwmon_device_register(dev); if (IS_ERR(data->hwmon_dev)) { - dev_err(data->dev, "unable to register as hwmon device.\n"); + dev_err(dev, "unable to register as hwmon device.\n"); ret = PTR_ERR(data->hwmon_dev); goto err_after_sysfs; } - dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n", - pdev_id->name); + dev_info(dev, "Thermistor type: %s successfully probed.\n", + pdev_id->name); - tz = devm_thermal_zone_of_sensor_register(data->dev, 0, data->dev, + tz = devm_thermal_zone_of_sensor_register(dev, 0, dev, &ntc_of_thermal_ops); if (IS_ERR(tz)) - dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n"); + dev_dbg(dev, "Failed to register to thermal fw.\n"); return 0; err_after_sysfs: - sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); + sysfs_remove_group(&dev->kobj, &ntc_attr_group); return ret; } @@ -686,7 +684,7 @@ static int ntc_thermistor_remove(struct platform_device *pdev) struct ntc_data *data = platform_get_drvdata(pdev); hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&data->dev->kobj, &ntc_attr_group); + sysfs_remove_group(&pdev->dev.kobj, &ntc_attr_group); return 0; }