From patchwork Wed Jul 10 07:26:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 168785 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9586713ilk; Wed, 10 Jul 2019 00:26:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGXfNDa8JPKyW0FERTp9NJkrlmAC33AzfWg1dyyI79vgo2heNw3Qrr0Wg0OY433wlgjGZi X-Received: by 2002:a17:902:361:: with SMTP id 88mr23929446pld.123.1562743579814; Wed, 10 Jul 2019 00:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562743579; cv=none; d=google.com; s=arc-20160816; b=b9e7Jom0UB2J+hu2JrMGUihks0D1ZBorAubDxn1CaMkglMRj+OKvto8Z5dzAelfrsF XS+MtKFfdqILZCn26T4v3tv5/hZh4QyFgGyWu9JshAxb7fkyVsjXpay8UGrgpI7V/VAy kyJ1OboDAcuk10Tns2rMVjlqqLAEJ64JlnY80nZKeYQwTtk0H4svVw2iNOPt/xq0fPYF lHsuDF3x+0VCxRNNz+y7qej5TE/Hj6a6pMvjLN8zF3xJMvC/10nzrDxjrfL0//a095Tl VeUpudh++FL5ZMGq66y7P6+trek/nGa8B+d0Q/2+sEJOvAEq0dTYNHVJu0cx1immB45d aiuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cdSf9Bk39d2jsEwtirbUFvZR6WuTUDxY23e5Q3Gyu54=; b=u5lYDPIINtGAcSKixQ2PgeR9KC51xclS869mt39d5nhXW9NWpjTYO7b1W1ccZD1AFy l4usdJTlXdi7+NokqWW+lqUxXBqiGxfaXxhapPhjSVJEtbEK3Orr9hVjZzV5D55hwULq ZXpVGBkCDzpON/GyPWW6q/irPfnwxL9AgeQiO8PitFpmBpVbwIaIcr/W+HbSp2KBHKUm Wdj/v+6huPFBL3c8ZcTWjaWZlIuhciVGpKcca/tiPejgjmkNpAHBFZ4ZUfjtwtWdWEjO YNgoR/PN5qjPuXBBxP1kpg4/hzRGoRVDM2C73g3kneznA/8XkE89KFzM6Aid43w56Cqu gaug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KBYkAkyc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si1467853plr.94.2019.07.10.00.26.19; Wed, 10 Jul 2019 00:26:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KBYkAkyc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbfGJH0S (ORCPT + 30 others); Wed, 10 Jul 2019 03:26:18 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:41989 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbfGJH0S (ORCPT ); Wed, 10 Jul 2019 03:26:18 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so657125pff.9; Wed, 10 Jul 2019 00:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cdSf9Bk39d2jsEwtirbUFvZR6WuTUDxY23e5Q3Gyu54=; b=KBYkAkycZiz8DZ1DdXQ09DtirV6eaCKk3fmVFyIBKxbjrT7BHk2fATKnvMqjuFKqtL 2VVWpAxLUOf2sFvSR1Ki+Vto7jYVcUKMF6E0/b9zXN1h6LCaQx5xuVlomf8/omMtm2et J61gvJfNmZcJkmMt3N3ZhKRPU0TPtsG97ISH+wksw7N8TBZF4MOFBRuJ4ONbmbjlBl9S IWZfsW+wyHljkFz3b4S9mOX+bA0Z5/byG4Ds6TrkkqZ2FZiJ6MkQHhyZLyZN4Q4riLMN 3XRZrOR5pnbAlhfcgRX7/z1bIYZR8JEbt7v3quprl6EpQwiiRneIx6UXRrL7tZSYOhwO oWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=cdSf9Bk39d2jsEwtirbUFvZR6WuTUDxY23e5Q3Gyu54=; b=HhVGBsKUrHWhGdLJgz736QeIEdkx3HJC64L45FnOtJQI13VUhy86Qxeb+YdkPC1jkZ WSjJdIT7qMUSl0+Kzl3cPoucBU+vT/UoVebyFlLgI2hexr1aHD7wegm13cFzqFIH/n+v pt4urQogTviJrS+OlYaOyzP0iVg8qumJgQK+KX4Cnx3/KFILruHmtW0PIvQbEh3c4ChI vj+4fF073ZmEw+6oI/o5nxcK0z0yrHi/w61LOrMioGP7XW5Gp7XQdZuFYuNY9Rr9qHUg yoN6VxkXBoCeR0M+V7dCKs2mJa0HIjoMjG5R6PbMIcBEsOWWiRqmXYnpmdq0b5fZs6GB tzhg== X-Gm-Message-State: APjAAAVIX32zucHmmR+7zZgeizk+DSc2lADambnQzx50qCj12/JknSrh MHh1va+2QGs9SJl0/SkfEJMPnhvv X-Received: by 2002:a63:da52:: with SMTP id l18mr35850153pgj.131.1562743577006; Wed, 10 Jul 2019 00:26:17 -0700 (PDT) Received: from voyager.ozlabs.ibm.com ([36.255.48.244]) by smtp.gmail.com with ESMTPSA id o130sm2802358pfg.171.2019.07.10.00.26.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 00:26:15 -0700 (PDT) From: Joel Stanley To: Guenter Roeck , linux-hwmon@vger.kernel.org Cc: Eddie James , Alexander Amelkin , Lei YU , Alexander Soldatov , linux-kernel@vger.kernel.org Subject: [PATCH] hwmon (occ): Add temp sensor value check Date: Wed, 10 Jul 2019 16:56:06 +0930 Message-Id: <20190710072606.4849-1-joel@jms.id.au> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Soldatov The occ driver supports two formats for the temp sensor value. The OCC firmware for P8 supports only the first format, for which no range checking or error processing is performed in the driver. Inspecting the OCC sources for P8 reveals that OCC may send a special value 0xFFFF to indicate that a sensor read timeout has occurred, see https://github.com/open-power/occ/blob/master_p8/src/occ/cmdh/cmdh_fsp_cmds.c#L395 That situation wasn't handled in the driver. This patch adds invalid temp value check for the sensor data format 1 and handles it the same way as it is done for the format 2, where EREMOTEIO is reported for this case. Fixes: 54076cb3b5ff ("hwmon (occ): Add sensor attributes and register hwmon device") Signed-off-by: Alexander Soldatov Signed-off-by: Alexander Amelkin Reviewed-by: Alexander Amelkin Reviewed-by: Eddie James Signed-off-by: Joel Stanley --- drivers/hwmon/occ/common.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index cccf91742c1a..a7d2b16dd702 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -241,6 +241,12 @@ static ssize_t occ_show_temp_1(struct device *dev, val = get_unaligned_be16(&temp->sensor_id); break; case 1: + /* + * If a sensor reading has expired and couldn't be refreshed, + * OCC returns 0xFFFF for that sensor. + */ + if (temp->value == 0xFFFF) + return -EREMOTEIO; val = get_unaligned_be16(&temp->value) * 1000; break; default: