From patchwork Wed Aug 8 01:32:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: IKEGAMI Tokunori X-Patchwork-Id: 10559389 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 ED97013B4 for ; Wed, 8 Aug 2018 01:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3692040D for ; Wed, 8 Aug 2018 01:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1C7826256; Wed, 8 Aug 2018 01:36:40 +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 C0E192040D for ; Wed, 8 Aug 2018 01:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726625AbeHHDxs (ORCPT ); Tue, 7 Aug 2018 23:53:48 -0400 Received: from mail1.bemta23.messagelabs.com ([67.219.246.1]:47667 "EHLO mail1.bemta23.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeHHDxs (ORCPT ); Tue, 7 Aug 2018 23:53:48 -0400 Received: from [67.219.246.100] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-1.bemta.az-b.us-east-1.aws.symcld.net id 2F/46-01620-6294A6B5; Wed, 08 Aug 2018 01:36:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeJIrShJLcpLzFFi42KZFv5DRFfVMyv a4Ot1M4v211sZHRg9Pm+SC2CMYs3MS8qvSGDNWPv/MXvBZpWK75u4GxhfyHUxcnEICcxhlPjU +I0ZwvnJKPHl8CamLkZODjYBU4nprxYygtgiAioSW9atAStiFljFKPF92QGwImGBWImLZ06zg dgsAqoSBzfNAmvgFXCU+H3pDDOILSEgL3H4TRNrFyMHB6eAk8ShhwkgYSGgkkV9HWwQtqbE85 7vjBDlwRJPtlxhnsDIu4CRYRWjWVJRZnpGSW5iZo6uoYGBrqGhka6xrpGpiV5ilW6SXmmxbmp icYmuoV5iebFecWVuck6KXl5qySZGYKAwAMEOxpW70g4xSnIwKYnyfv6WGS3El5SfUpmRWJwR X1Sak1p8iFGGg0NJgjfMIytaSLAoNT21Ii0zBxiyMGkJDh4lEV41kDRvcUFibnFmOkTqFKMxx 6nmnknMHH/eT53ELMSSl5+XKiXOmwRSKgBSmlGaBzcIFkuXGGWlhHkZgU4T4ilILcrNLEGVf8 UozsGoJMybCTKFJzOvBG7fK6BTmIBOeaOdCXJKSSJCSqqBkf1hadW+nM9szncEzE9MsUn+wV5 5QS0+Q3ySXty1+5qtysqxrvH8lRfuV9S6q/tzhK+bffKQztTTJsznexe0Ldj7RIz7185IZs/O J/fmVO/rf7Tn+P1u+YO8Mold8gnXA3h/+7NfUJra2akWVvVLNM/2QW3KLjnltXUrJvBc2n381 IP+/+efKLEUZyQaajEXFScCALlS1ISgAgAA X-Env-Sender: ikegami@allied-telesis.co.jp X-Msg-Ref: server-13.tower-384.messagelabs.com!1533692196!2075759!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 2783 invoked from network); 8 Aug 2018 01:36:37 -0000 Received: from abricot-inet.allied-telesis.co.jp (HELO TKY-DS01.at.lc) (150.87.248.20) by server-13.tower-384.messagelabs.com with SMTP; 8 Aug 2018 01:36:37 -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); Wed, 8 Aug 2018 10:36:36 +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 ; Wed, 8 Aug 2018 10:36:35 +0900 From: Tokunori Ikegami To: Jean Delvare Cc: Tokunori Ikegami , Guenter Roeck , Chris Packham , linux-hwmon@vger.kernel.org Subject: [PATCH v3 4/4] hwmon: (adt7475) Change show functions to return error data correctly Date: Wed, 8 Aug 2018 10:32:19 +0900 Message-Id: <20180808013219.26118-5-ikegami@allied-telesis.co.jp> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180808013219.26118-1-ikegami@allied-telesis.co.jp> References: <20180808013219.26118-1-ikegami@allied-telesis.co.jp> X-OriginalArrivalTime: 08 Aug 2018 01:36:36.0054 (UTC) FILETIME=[3EA66760:01D42EB8] 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 --- Changes since v2: - Change to rebase on the v3 patch 1. Changes since v1: - Move the changes in adt7475_update_device() from patch 3. - Change to rebase on the v2 patch 1. drivers/hwmon/adt7475.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 9f7e1a5b08a5..90837f7c7d0f 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -325,6 +325,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", @@ -380,6 +383,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); @@ -624,6 +630,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]); @@ -682,6 +691,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 @@ -719,6 +731,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]); } @@ -728,6 +743,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]); } @@ -737,6 +755,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]); } @@ -944,6 +965,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]); } @@ -1034,6 +1058,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)); } @@ -1677,7 +1705,9 @@ static int adt7475_probe(struct i2c_client *client, (data->bypass_attn & (1 << 4)) ? " in4" : ""); /* Limits and settings, should never change update more than once */ - adt7475_update_limits(client); + ret = adt7475_update_limits(client); + if (ret) + goto eremove; return 0; @@ -1876,13 +1906,19 @@ static struct adt7475_data *adt7475_update_device(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct adt7475_data *data = i2c_get_clientdata(client); + int ret; mutex_lock(&data->lock); /* Measurement values update every 2 seconds */ if (time_after(jiffies, data->measure_updated + HZ * 2) || !data->valid) { - adt7475_update_measure(dev); + ret = adt7475_update_measure(dev); + if (ret) { + data->valid = false; + mutex_unlock(&data->lock); + return ERR_PTR(ret); + } data->measure_updated = jiffies; data->valid = true; }