Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8853951ybi; Wed, 10 Jul 2019 00:27:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrRszp81exAFAV74ccsfSSilsUrAAwCrCUNnoIK3iwNweXMRs5pFGlqGLwpW397Jr6rviP X-Received: by 2002:a63:506:: with SMTP id 6mr34997471pgf.434.1562743643671; Wed, 10 Jul 2019 00:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562743643; cv=none; d=google.com; s=arc-20160816; b=uGQHg+2r2xK96YzYGJRJ+ArV1B/nGi5lNuKYdAB7L0oxl0XNlab4o7NdKOdlGqjU2R Uny7U/xlTHEjlwq5+5JdthRBxrco2XHaLROyfPQ2GxRd0SaPLswwX0ySzZTIYS9iAjcB 2eaeH/rNHQjmImtf7CF6aclL2BG5aAXsy/n/TOEp304tv+ng5VXd4v1OW4dW0IyNEtWV 6zQmTxudi6c7jxvTf2Mfre2rGGWXkHvdIDrcFWbExix3eVj1WZsY7hI3ytoz9Mh3LHG6 xTcX3ZiByJTyVdJePdBpgMiIKvW/LBNcoagJHxP6xtN5qsZpkcWWhPI/L7OgZIKCBubp zMcw== 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 c17si1413385plo.46.2019.07.10.00.27.07; Wed, 10 Jul 2019 00:27:23 -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 S1727121AbfGJH0S (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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(+) 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: -- 2.20.1