Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4880436pjb; Mon, 27 Jul 2020 07:28:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJoxqukERUXsijgWnQi2KKIAea9goF052bjxvxPyYWc9giu9hqi+/Hl/WLA7ccLy6gkLi2 X-Received: by 2002:a17:906:dbcf:: with SMTP id yc15mr20448579ejb.222.1595860137949; Mon, 27 Jul 2020 07:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860137; cv=none; d=google.com; s=arc-20160816; b=d+fRmU/dgs76X16XC0d9Mc4aiE0dDC5KKbhF8IkdPwuSrQqAJ/sDo4UWT4yVi8FCI6 yfuwef7qNrjyV/3KQjrIy2TiBQ0dcS85R365pCDfnn+U6cpiNT4L3JZcONGPMHCynVQE 814UcFoLNyf+o0QP4d3BY+1nRLtYhDo0+z0fPIm4BPInp5GljwHQ+KjedrHLeoD5qqZK 9YobFQaJcgszHEh2/uVd8e9xSaggrFlMySWTHBQQTI49xd5HXimtcxFprzDNSS3JVWEZ kmXOoGwntg5NBOE/gHHycCaFNIAFSQxu5SL/nKPHmXF3UgbKz6bL1+U21QbAOcbaiake 7Ceg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xopcrmsf0l+nMp649jCpbSWD2BF0+fkNJn4qeB6U8Rw=; b=w/QZ4ietp0/S90eGe6YVzFbM6vQhsicfW0XNUorcu64OvKhHtneXRfKU842JSw5wFQ zVS+bD4WVGEbTPn5gjkMkyrfDJcCoWr1d0zgkNWgZcP3E60NBhUfjifmeN+7uqLaz+DB TMnFQosi15ng3x6mhz5PaPKYY8DjAp74ZwbdEOJQFu5fOKtMA7AVq71x6KH6yiReTzdT k68jnfxPFqxPHQ47Bsx98JrZlAfL1lLNotAfWHElzdewsmiOu4ifCIvbY8O0u9huM3zr 0f0pbYjrObcu+pHME3Mxgaqkt+2GfyNSd4Buo1Oq4P0L5rjSkzO82Pgq9ZPcj7wl1D9L oMZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CPN4q4JW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si6455657ejb.35.2020.07.27.07.28.35; Mon, 27 Jul 2020 07:28:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CPN4q4JW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732390AbgG0OZS (ORCPT + 99 others); Mon, 27 Jul 2020 10:25:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:55052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732370AbgG0OZN (ORCPT ); Mon, 27 Jul 2020 10:25:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE4382075A; Mon, 27 Jul 2020 14:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859913; bh=qwv1oXhk8at2vNn/hHKYLEGA/5GQhzw6wtG6R2MdQ4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CPN4q4JWL3XE6JzqW9VWc97mp+NQbFTSNYnJTZvcT8TypPDGVAKmlFMJDy792g1x4 bk+rbF3NZ2iKWZE4DzA9c6c9bzjt4fNMUatEFu3a9Ytabu6vygPGG1pICP/sBQn7PE 54q8Ofu6im41dDAepTgXZkNzuOQpuFYJg1NbEwks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chu Lin , Guenter Roeck , Sasha Levin Subject: [PATCH 5.7 124/179] hwmon: (adm1275) Make sure we are reading enough data for different chips Date: Mon, 27 Jul 2020 16:04:59 +0200 Message-Id: <20200727134938.692888033@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chu Lin [ Upstream commit 6d1d41c075a1a54ba03370e268171fec20e06563 ] Issue: When PEC is enabled, binding adm1272 to the adm1275 would fail due to PEC error. See below: adm1275: probe of xxxx failed with error -74 Diagnosis: Per the datasheet of adm1272, adm1278, adm1293 and amd1294, PMON_CONFIG (0xd4) is 16bits wide. On the other hand, PMON_CONFIG (0xd4) for adm1275 is 8bits wide. The driver should not assume everything is 8bits wide and read only 8bits from it. Solution: If it is adm1272, adm1278, adm1293 and adm1294, use i2c_read_word. Else, use i2c_read_byte Testing: Binding adm1272 to the driver. The change is only tested on adm1272. Signed-off-by: Chu Lin Link: https://lore.kernel.org/r/20200709040612.3977094-1-linchuyuan@google.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/pmbus/adm1275.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c index e25f541227dae..19317575d1c6a 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -465,6 +465,7 @@ MODULE_DEVICE_TABLE(i2c, adm1275_id); static int adm1275_probe(struct i2c_client *client, const struct i2c_device_id *id) { + s32 (*config_read_fn)(const struct i2c_client *client, u8 reg); u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; int config, device_config; int ret; @@ -510,11 +511,16 @@ static int adm1275_probe(struct i2c_client *client, "Device mismatch: Configured %s, detected %s\n", id->name, mid->name); - config = i2c_smbus_read_byte_data(client, ADM1275_PMON_CONFIG); + if (mid->driver_data == adm1272 || mid->driver_data == adm1278 || + mid->driver_data == adm1293 || mid->driver_data == adm1294) + config_read_fn = i2c_smbus_read_word_data; + else + config_read_fn = i2c_smbus_read_byte_data; + config = config_read_fn(client, ADM1275_PMON_CONFIG); if (config < 0) return config; - device_config = i2c_smbus_read_byte_data(client, ADM1275_DEVICE_CONFIG); + device_config = config_read_fn(client, ADM1275_DEVICE_CONFIG); if (device_config < 0) return device_config; -- 2.25.1