From patchwork Sun Apr 16 04:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Crawford X-Patchwork-Id: 13212703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2034EC77B76 for ; Sun, 16 Apr 2023 04:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229462AbjDPEZm (ORCPT ); Sun, 16 Apr 2023 00:25:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbjDPEZk (ORCPT ); Sun, 16 Apr 2023 00:25:40 -0400 Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [150.101.137.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73D832D4C for ; Sat, 15 Apr 2023 21:25:38 -0700 (PDT) IronPort-SDR: 643b78bc_346VmSdYT6N+7JQEOH1quHds0GXE6/TOou35kH2FZ4+rfAL WQglDyjH97FtK57y6FX0ReI3Pkeaudw4Cc8DL+w== X-SMTP-MATCH: 0 X-IPAS-Result: A2CwAACkdztkjPQc8jxaGwEBAQEBAQEBBQEBARIBAQEDAwEBAUmBRoIugk+uCIdXDwEPAQFEBAEBhQYChTwmOBMBAgQBAQEBAwIDAQEBAQEBAwEBBgEBAQEBAQYEFAEBAQFARYVoDYYEAgEDJwsBDQEBNwEPGThXBgESgn6CXa8EM4EBgggBAQaCYppqgV4JgUGLdYEWgzZ6Qj+BToEVgTyCLYEPiXeaVoE0doEgDkpygQQCCQIRa4EQCGp+e0ACDWQLDm+BSYMqBAIURA5UAwkDBwVJQAMLGA0WOhMsNRQgXGwtEhIFAwsVKkcECDgGGz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UUuMeFKHJ/JG202WE= X-IronPort-Anti-Spam-Filtered: true Received: from 60-242-28-244.static.tpgi.com.au (HELO bits.crawford.emu.id.au) ([60.242.28.244]) by ipmail03.adl2.internode.on.net with ESMTP; 16 Apr 2023 13:55:33 +0930 Received: from agc.crawford.emu.id.au (agc.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc07]) (authenticated bits=0) by bits.crawford.emu.id.au (8.17.1/8.17.1) with ESMTPSA id 33G4PCj33415316 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 16 Apr 2023 14:25:28 +1000 Authentication-Results: bits.crawford.emu.id.au; arc=none smtp.remote-ip=fdd2:7aad:d478:1::cb10:cc07 DKIM-Filter: OpenDKIM Filter v2.11.0 bits.crawford.emu.id.au 33G4PCj33415316 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crawford.emu.id.au; s=s1; t=1681619128; bh=JbYOTgMbk5IKKqjYsYlQvml8l3PzjdpEW1kEeeNYd3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBXOJOYn84PmU0cSv3FzUQbN/GARSr6OUDecwDKFKY4b6i6MP0RwIthqCXswxsufc XSNk/6hUtxV0jJwWa+BmiWuEuO5PY0muOiRR6mWbRbELIzZstNVGveI6Q9bdsjIfg9 kaXjkQNkYj7Ah1nkM57m/wWDebBupUz2egHjnKvAEca7XOY+ze5XxJ3Re2CspM5/3Y aJSZszFPBXREVEq75exmY96rl7g8XVn/0aUdqoX4Z4ryAOvIs9fUrEQq3huekjLr2p JAVHqCUAR1m3Xnm0UE6L6jaB5b1+tXHtkdhLmIvKG79XgJypkI3VLzZVH75PzDDRpm 51Q+Ww5UeePSA== From: Frank Crawford To: Jean Delvare , Guenter Roeck Cc: linux-hwmon@vger.kernel.org, Frank Crawford Subject: [PATCH v2 2/4] hwmon: (it87) Test for error in it87_update_device Date: Sun, 16 Apr 2023 14:25:08 +1000 Message-Id: <20230416042510.1929077-3-frank@crawford.emu.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230416042510.1929077-1-frank@crawford.emu.id.au> References: <20230416042510.1929077-1-frank@crawford.emu.id.au> MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (bits.crawford.emu.id.au [IPv6:fdd2:7aad:d478:1:0:0:cb10:cc01]); Sun, 16 Apr 2023 14:25:28 +1000 (AEST) X-Virus-Scanned: clamav-milter 0.103.8 at bits.crawford.emu.id.au X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Handle errors from it87_update_device(), which currently only occurs if SMBus access locking fails. Signed-off-by: Frank Crawford --- v2: * Reorder patches within patchset. --- drivers/hwmon/it87.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index b74dd861f0fe..920fb9b6b2e2 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -942,6 +942,9 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, int index = sattr->index; int nr = sattr->nr; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", in_from_reg(data, nr, data->in[nr][index])); } @@ -1030,6 +1033,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, int index = sattr->index; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr][index])); } @@ -1107,6 +1113,9 @@ static ssize_t show_temp_type(struct device *dev, struct device_attribute *attr, u8 reg = data->sensor; /* In case value is updated while used */ u8 extra = data->extra; + if (IS_ERR(data)) + return PTR_ERR(data); + if ((has_temp_peci(data, nr) && (reg >> 6 == nr + 1)) || (has_temp_old_peci(data, nr) && (extra & 0x80))) return sprintf(buf, "6\n"); /* Intel PECI */ @@ -1197,6 +1206,9 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, int speed; struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + speed = has_16bit_fans(data) ? FAN16_FROM_REG(data->fan[nr][index]) : FAN_FROM_REG(data->fan[nr][index], @@ -1211,6 +1223,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%lu\n", DIV_FROM_REG(data->fan_div[nr])); } @@ -1221,6 +1236,9 @@ static ssize_t show_pwm_enable(struct device *dev, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_mode(data, nr)); } @@ -1231,6 +1249,9 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->pwm_duty[nr])); } @@ -1244,6 +1265,9 @@ static ssize_t show_pwm_freq(struct device *dev, struct device_attribute *attr, unsigned int freq; int index; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_pwm_freq2(data) && nr == 1) index = (data->extra >> 4) & 0x07; else @@ -1531,6 +1555,9 @@ static ssize_t show_pwm_temp_map(struct device *dev, int nr = sensor_attr->index; int map; + if (IS_ERR(data)) + return PTR_ERR(data); + map = data->pwm_temp_map[nr]; if (map >= 3) map = 0; /* Should never happen */ @@ -1595,6 +1622,9 @@ static ssize_t show_auto_pwm(struct device *dev, struct device_attribute *attr, int nr = sensor_attr->nr; int point = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", pwm_from_reg(data, data->auto_pwm[nr][point])); } @@ -1631,6 +1661,9 @@ static ssize_t show_auto_pwm_slope(struct device *dev, struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); int nr = sensor_attr->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%d\n", data->auto_pwm[nr][1] & 0x7f); } @@ -1664,6 +1697,9 @@ static ssize_t show_auto_temp(struct device *dev, struct device_attribute *attr, int point = sensor_attr->index; int reg; + if (IS_ERR(data)) + return PTR_ERR(data); + if (has_old_autopwm(data) || point) reg = data->auto_temp[nr][point]; else @@ -1884,6 +1920,9 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", data->alarms); } static DEVICE_ATTR_RO(alarms); @@ -1894,6 +1933,9 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); } @@ -1949,6 +1991,9 @@ static ssize_t show_beep(struct device *dev, struct device_attribute *attr, struct it87_data *data = it87_update_device(dev); int bitnr = to_sensor_dev_attr(attr)->index; + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%u\n", (data->beeps >> bitnr) & 1); } @@ -2022,6 +2067,9 @@ static ssize_t cpu0_vid_show(struct device *dev, { struct it87_data *data = it87_update_device(dev); + if (IS_ERR(data)) + return PTR_ERR(data); + return sprintf(buf, "%ld\n", (long)vid_from_reg(data->vid, data->vrm)); } static DEVICE_ATTR_RO(cpu0_vid);