From patchwork Wed Apr 17 11:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Amelkin X-Patchwork-Id: 10905267 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 DCCA514DB for ; Wed, 17 Apr 2019 11:36:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C75B22897A for ; Wed, 17 Apr 2019 11:36:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA9C1288E0; Wed, 17 Apr 2019 11:36:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 418F828939 for ; Wed, 17 Apr 2019 11:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731908AbfDQLgl (ORCPT ); Wed, 17 Apr 2019 07:36:41 -0400 Received: from mta-01.yadro.com ([89.207.88.251]:55850 "EHLO mta-01.yadro.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726695AbfDQLgl (ORCPT ); Wed, 17 Apr 2019 07:36:41 -0400 X-Greylist: delayed 587 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Apr 2019 07:36:40 EDT Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 5DEF8418A4; Wed, 17 Apr 2019 11:26:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received:received; s= mta-01; t=1555500411; x=1557314812; bh=t8iDtAW+nK3U0b+PHwzP8FAKL YD0E6VVW10KI8evMPE=; b=aC8tGkab6AwGvmjU/6X55jtEQJtLLWTpQllrNm+kg PIAZcLWwQi+S9/+rQEuK48NbwBqsvsbCiea16+pMwW43fhD6imMDth7SJJzmUzzK /UalcVrqCS6VJm2fkwdXevPY+WfsuNrIoM8qn8Hq6Xn5tFl5MTwxYmnxqyfFTgjr 24= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U4Cjeh5uPKlU; Wed, 17 Apr 2019 14:26:51 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 962CD41896; Wed, 17 Apr 2019 14:26:50 +0300 (MSK) Received: from cinnamon.dev.yadro.com (172.17.14.197) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Wed, 17 Apr 2019 14:26:50 +0300 From: Alexander Amelkin To: CC: , Alexander Soldatov , Alexander Amelkin , "Edward A . James" , Joel Stanley Subject: [PATCH 1/1] hwmon (occ): Add temp sensor value check Date: Wed, 17 Apr 2019 14:26:36 +0300 Message-ID: <1555500396-11976-1-git-send-email-a.amelkin@yadro.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [172.17.14.197] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) 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 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 occured, 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. Signed-off-by: Alexander Soldatov Signed-off-by: Alexander Amelkin Reviewed-by: Alexander Amelkin Cc: Edward A. James Cc: Joel Stanley --- drivers/hwmon/occ/common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index 4679acb..825631c 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -235,6 +235,10 @@ static ssize_t occ_show_temp_1(struct device *dev, val = get_unaligned_be16(&temp->sensor_id); break; case 1: + /* If a sensor timed out long enough, + OCC returns 0xFFFF for that sensor.*/ + if (temp->value == 0xFFFF) + return -EREMOTEIO; val = get_unaligned_be16(&temp->value) * 1000; break; default: