From patchwork Tue Aug 7 08:57:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: IKEGAMI Tokunori X-Patchwork-Id: 10558405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60DB713BB for ; Tue, 7 Aug 2018 08:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5017C29B73 for ; Tue, 7 Aug 2018 08:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4460129B86; Tue, 7 Aug 2018 08:58:53 +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.3 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,URIBL_SBL 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 CFE3229B76 for ; Tue, 7 Aug 2018 08:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbeHGLML (ORCPT ); Tue, 7 Aug 2018 07:12:11 -0400 Received: from mail1.bemta24.messagelabs.com ([67.219.250.5]:7146 "EHLO mail1.bemta24.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbeHGLML (ORCPT ); Tue, 7 Aug 2018 07:12:11 -0400 Received: from [67.219.250.100] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-5.bemta.az-a.us-west-2.aws.symcld.net id 85/F9-25586-A4F596B5; Tue, 07 Aug 2018 08:58:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsUyLfyHiK5XfGa 0waVpuhbtr7cyOjB6fN4kF8AYxZqZl5RfkcCasWv/GdaCk9IVczZ9ZG5gPCfexcjFISQwh1Hi XfteVgjnJ6NEz+VTzF2MnBxsAqYS018tZASxRQRUJLasW8MMUsQssIpR4vuyA0wgCWGBKIkX8 x6xgdgsAqoSvw9tBmvmFXCUeHG6nwXElhCQlzj8pokVxOYUcJK49LwNbKgQUE3HlSUsELamxP Oe74wQ9cESLatWMk9g5F3AyLCK0SKpKDM9oyQ3MTNH19DAQNfQ0EjX0NhQ19DIVC+xSjdRr7R Ytzy1uETXSC+xvFivuDI3OSdFLy+1ZBMjMGAYgGAH45cXKYcYJTmYlER5i5Qzo4X4kvJTKjMS izPii0pzUosPMcpwcChJ8ObHAeUEi1LTUyvSMnOAoQuTluDgURLhzQFJ8xYXJOYWZ6ZDpE4xG nOcau6ZxMzx5/3UScxCLHn5ealS4rwCIKUCIKUZpXlwg2AxdYlRVkqYlxHoNCGegtSi3MwSVP lXjOIcjErCvIUgU3gy80rg9r0COoUJ6JQ32mCnlCQipKQaGMO/lKeKaKf/sr/49/L047rHKgv OPZv8I+1zs8llLr7vBuxeVttmGXE9MT6ptdxhYsIc13eTvpvPEfL8aN5UHz09cHbkq5dPNIzk pulZWIRu23/Y0YXbcKX37Ak3l8in/7fZoxT0Rv2pyg6uc5I7mK8F6x789iDiw/5NAULSpxdZy cY5Hm077q7EUpyRaKjFXFScCAAc5F/1pAIAAA== X-Env-Sender: ikegami@allied-telesis.co.jp X-Msg-Ref: server-8.tower-324.messagelabs.com!1533632329!3076686!1 X-Originating-IP: [150.87.248.20] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.9.15; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5397 invoked from network); 7 Aug 2018 08:58:50 -0000 Received: from abricot-inet.allied-telesis.co.jp (HELO TKY-DS01.at.lc) (150.87.248.20) by server-8.tower-324.messagelabs.com with SMTP; 7 Aug 2018 08:58:50 -0000 Received: from swim-manx.rd.allied-telesis.co.jp ([150.87.21.50]) by TKY-DS01.at.lc with Microsoft SMTPSVC(8.0.9200.16384); Tue, 7 Aug 2018 17:58:49 +0900 Received: from ikegami-pc.rd.allied-telesis.co.jp by swim-manx.rd.allied-telesis.co.jp (AlliedTelesis SMTPRS 1.3 pl 1 ++E6B86F8C687C6288D9B5559052954DC9) with ESMTP id ; Tue, 7 Aug 2018 17:58:48 +0900 From: Tokunori Ikegami To: Jean Delvare Cc: Tokunori Ikegami , Guenter Roeck , Chris Packham , linux-hwmon@vger.kernel.org Subject: [PATCH 4/4] hwmon: (adt7475) Change show functions to return error data correctly Date: Tue, 7 Aug 2018 17:57:33 +0900 Message-Id: <20180807085733.28756-5-ikegami@allied-telesis.co.jp> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180807085733.28756-1-ikegami@allied-telesis.co.jp> References: <20180807085733.28756-1-ikegami@allied-telesis.co.jp> X-OriginalArrivalTime: 07 Aug 2018 08:58:49.0406 (UTC) FILETIME=[DB58DDE0:01D42E2C] 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 The update device function was changed to return error pointer value. So change the show functions using the update function to return error. Signed-off-by: Tokunori Ikegami Cc: Guenter Roeck Cc: Chris Packham Cc: linux-hwmon@vger.kernel.org --- drivers/hwmon/adt7475.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index fb89b88f1998..21a40fbb3a49 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -326,6 +326,9 @@ static ssize_t show_voltage(struct device *dev, struct device_attribute *attr, struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); unsigned short val; + if (IS_ERR(data)) + return PTR_ERR(data); + switch (sattr->nr) { case ALARM: return sprintf(buf, "%d\n", @@ -381,6 +384,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); int out; + if (IS_ERR(data)) + return PTR_ERR(data); + switch (sattr->nr) { case HYSTERSIS: mutex_lock(&data->lock); @@ -625,6 +631,9 @@ static ssize_t show_point2(struct device *dev, struct device_attribute *attr, struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); int out, val; + if (IS_ERR(data)) + return PTR_ERR(data); + mutex_lock(&data->lock); out = (data->range[sattr->index] >> 4) & 0x0F; val = reg2temp(data, data->temp[AUTOMIN][sattr->index]); @@ -683,6 +692,9 @@ static ssize_t show_tach(struct device *dev, struct device_attribute *attr, struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); int out; + if (IS_ERR(data)) + return PTR_ERR(data); + if (sattr->nr == ALARM) out = (data->alarms >> (sattr->index + 10)) & 1; else @@ -720,6 +732,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, struct adt7475_data *data = adt7475_update_device(dev); struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]); } @@ -729,6 +744,9 @@ static ssize_t show_pwmchan(struct device *dev, struct device_attribute *attr, struct adt7475_data *data = adt7475_update_device(dev); struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->pwmchan[sattr->index]); } @@ -738,6 +756,9 @@ static ssize_t show_pwmctrl(struct device *dev, struct device_attribute *attr, struct adt7475_data *data = adt7475_update_device(dev); struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->pwmctl[sattr->index]); } @@ -945,6 +966,9 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr, int i = clamp_val(data->range[sattr->index] & 0xf, 0, ARRAY_SIZE(pwmfreq_table) - 1); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwmfreq_table[i]); } @@ -1035,6 +1059,10 @@ static ssize_t cpu0_vid_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct adt7475_data *data = adt7475_update_device(dev); + + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); }