Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4868184pjb; Mon, 27 Jul 2020 07:13:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpmoG27cxXJsS3Y8eOTGTsUFZddCNw2POakfgVZMaNPBt/7AupWK9XyNhFfNWpnJTLKHJ8 X-Received: by 2002:a17:906:430b:: with SMTP id j11mr12284524ejm.270.1595859181657; Mon, 27 Jul 2020 07:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595859181; cv=none; d=google.com; s=arc-20160816; b=SZt+3YYxS3/Hrqr+udsSuPL5NaCbKpnVSHOqXlCbpYpS3sFfP/LroBnfl13DXARl79 1zCpYZkn7da2KGBUC5ViGXSh9BX7p0jJ+xLulLeMY7kkDQGwfdrNrRGa2SfxaC+m0ir1 mqHhvKshaoHk26L5SgXL7NLWopnr74MLwag5duhdmwo86KrFRg+Cz0u/YwZeXXmVY7gM kLTIJmgD5yFDIW9fBARE+2GSEzlw25BSz1mhpW/zaWItLyO4TrOoOwRpef7S7ehadnvb iv7xIaxB++icayjw5uzph3Wj0Jwa2L6GtkjDw1oQT1ur1e5Vzat2alG+SxQanLM7sAGZ K+zQ== 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=6qdBPkU+j9MDx6bGFd6RRW17zrMXbzVkCD+kjBU4eyY=; b=QMlPbcv5EtE3RALjF6ndkPQIwgTOZ7gjx0ApLLPMnxE/z1O83IAlhaw5NloH8jWRGI 8y7QX8jLg4SdKUFDICqQe0KR9jnva8FiRY8FHkK7wIST/xdIwg+lAALeDij9JIPyO0wj QTVzOrZY+v2bssa7LDk+C6b9/KG1jdV7pUA/G+H/n4cw4rcGmJIXkYzRiJHDEElZNCiA k1G70gCJ/eHoSmYMgIsk30l5sDmexGShCKeRJV3NnuYbHgQGs/KB2SnDWD/53Oq+sEfF dh2cFtGcOCpoamGSXsIN0kpqUtoORq1qtbqje0VJmJCQbgxr1p6qybsnfUB6YqT4mh6V aFMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Eqif9O2K; 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 s18si4779729ejd.164.2020.07.27.07.12.38; Mon, 27 Jul 2020 07:13:01 -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=Eqif9O2K; 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 S1729997AbgG0OLQ (ORCPT + 99 others); Mon, 27 Jul 2020 10:11:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:34672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729993AbgG0OLO (ORCPT ); Mon, 27 Jul 2020 10:11:14 -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 83C07208E4; Mon, 27 Jul 2020 14:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859074; bh=7/bT1ObWFc0vmB+DUQCMp5JYvmyrsUL+aA9T/8le4Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eqif9O2KLQKysbk2esvvEg+B9udQBYOB+xl2dnuoYrng6BiJ27Us6y5Di5FXdOGD7 13ijE9ZA1CCu7vc/XUoNWUxlHyM7WoIwZ3LYOoQe+bg7uYSzQHV9fnaC4gj/zZSJyP 9JOSjQDQQgKh88d8Kd/XPQhKEsjOYqZcBkcQ/5ts= 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 4.19 56/86] hwmon: (adm1275) Make sure we are reading enough data for different chips Date: Mon, 27 Jul 2020 16:04:30 +0200 Message-Id: <20200727134917.225251026@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@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 13600fa79e7f3..a19cf9052fc6d 100644 --- a/drivers/hwmon/pmbus/adm1275.c +++ b/drivers/hwmon/pmbus/adm1275.c @@ -364,6 +364,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; @@ -408,11 +409,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