Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5818094ioo; Wed, 1 Jun 2022 13:14:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJRavabD/n7T4OQetinx7lgSB209Agu2dPnhuy4ZoNeZO+ryJrQbl+lAJv5U/IC1bUv8du X-Received: by 2002:a17:90b:4ac1:b0:1e6:7c82:9aee with SMTP id mh1-20020a17090b4ac100b001e67c829aeemr1150481pjb.234.1654114463852; Wed, 01 Jun 2022 13:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654114463; cv=none; d=google.com; s=arc-20160816; b=Di3gje292vQ7uUXcdrW18kUsnI43x3ZsA1vk6YldhjoC2YKlok5+eW7wEcehtD0jT+ +dGgk8N2pUD6or663eT9jfWjoaXM7VSFgg2l4d4wqV59MsBQmMImLrw8WWWfVdCExF+L bmdMTOVmgZ2Z4WGhFojVjRySQ2j456+uvy+OPz0O+bpwuskIFBXZ5UoVI0Lxxqq6UN93 26UCjXSgKfFCyxmioVX6+305aQ57iC+gnYAZL29BjJJdZ7KEwKNNfgNQlv1pmDLh9+Mv q+F1six1lqbAS+U7066KKMCk/MyPxuJv6NaWenzW31I4EAtL5thshEAYmxVPNk/RBfHG wgbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:reply-to:cc :from:to:dkim-signature:date; bh=HNyDEZPUiD5WQaSU7ZB0ohB0dUGEd+n30NevK73Q/eI=; b=vTLoti3zTrGOPqvWbL9tKs/n4cjT6YvivLN8mznD8FaoSvGpuyH7xttIAz5IxYKqdB riu+DZwNXPkfv//5UiscvqoF02wJk9MHMpiGu8aD0+yhsO54JXQOH9ewvo9CRR12mbKT CdEMUhPQ+8HkbGx13fljOFzSS07/0AAC1Gf+38cBbeFWFvLAG8EwNf9Qd9FeLrOyyGGB q2DyMPdtaklUymDshbsb08ST3v6PeSMgcJMqtNG51D7KyCNW1LqPxWH8uJyTY0oXWLDy wvtawkv6SqR6OiVHc/CwzQQhi4FUYQZhdbuKk25jakN8gY7f+ttf+hh8rwYPZfVfa0NE emeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wujek.eu header.s=protonmail2 header.b=umXE7fDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d8-20020a170903230800b001582fa35afasi3433123plh.190.2022.06.01.13.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:14:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@wujek.eu header.s=protonmail2 header.b=umXE7fDg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8177C17856A; Wed, 1 Jun 2022 12:27:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348998AbiFABeJ (ORCPT + 99 others); Tue, 31 May 2022 21:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244972AbiFABeH (ORCPT ); Tue, 31 May 2022 21:34:07 -0400 Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8789A5B3F9; Tue, 31 May 2022 18:34:06 -0700 (PDT) Date: Wed, 01 Jun 2022 01:34:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1654047244; x=1654306444; bh=HNyDEZPUiD5WQaSU7ZB0ohB0dUGEd+n30NevK73Q/eI=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:Feedback-ID:From:To:Cc:Date:Subject:Reply-To: Feedback-ID:Message-ID; b=umXE7fDg9UuUBFZhWph6ZfofMERBm05Gjwtrwv8u/71VhAYOt5IP6X+Ak3y69SKpC Cqy+GMIiGV00jDMMsXQ96f/nev0j6CJC0y5uX6yCEIsYGYfykGmZsYsoi21Rsb+XMQ CZ/O/8FXfaldufSLQL2Q+aIoTo3QZbRX3GqenNFmPRcHxVRD6sxwAwY8XvGqFlbRXP bx2KEyJoHfmRFmTGt+Rxf4hf89XmTZHgjXSkKV/umnXuYYaIIlhWQ07PPPq510AJoN IfRF/mnTPagHtAobrvM1DuFOxYnsJ5ZV/nsDEklwcGdAILWSpBUoTC/gHCOhxEirGu 4MmxbHDxmE7bQ== To: Guenter Roeck From: wujek dev Cc: Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: wujek dev Subject: Re: [PATCH v2 1/2] hwmon: (pmbus) add a function to check the presence of a block register Message-ID: In-Reply-To: References: <20220524104307.272806-1-dev_public@wujek.eu> Feedback-ID: 23425257:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, May 24th, 2022 at 15:32, Guenter Roeck wro= te: > > > On 5/24/22 03:43, Adam Wujek wrote: > > > Other functions (like pmbus_check_byte_register) cannot be used to chec= k > > the presence of a block register, because it will generate error when P= EC > > is used. > > > > Signed-off-by: Adam Wujek dev_public@wujek.eu > > --- > > Notes: > > Changes in v2: > > - Use Phase 0xff when setting the page > > > > drivers/hwmon/pmbus/pmbus_core.c | 26 ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmb= us_core.c > > index acf78d0829d9..2ff66f133d95 100644 > > --- a/drivers/hwmon/pmbus/pmbus_core.c > > +++ b/drivers/hwmon/pmbus/pmbus_core.c > > @@ -421,6 +421,18 @@ static int _pmbus_read_byte_data(struct i2c_client= *client, int page, int reg) > > return pmbus_read_byte_data(client, page, reg); > > } > > > > +static int pmbus_read_block_data(struct i2c_client *client, int page, = u8 reg, > > + char *data_buf) > > +{ > > + int rv; > > + > > + rv =3D pmbus_set_page(client, page, 0xff); > > + if (rv < 0) > > + return rv; > > + > > + return i2c_smbus_read_block_data(client, reg, data_buf); > > +} > > + > > static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, = int page, > > int reg) > > { > > @@ -558,6 +570,20 @@ bool pmbus_check_word_register(struct i2c_client *= client, int page, int reg) > > } > > EXPORT_SYMBOL_NS_GPL(pmbus_check_word_register, PMBUS); > > > > +static bool pmbus_check_block_register(struct i2c_client *client, int = page, > > + int reg) > > +{ > > + int rv; > > + struct pmbus_data *data =3D i2c_get_clientdata(client); > > + char data_buf[I2C_SMBUS_BLOCK_MAX + 2] =3D { 0 }; > > > Unnecessary initialization. Agree > > > + > > + rv =3D pmbus_read_block_data(client, page, reg, data_buf); > > + if (rv >=3D 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK)) > > + rv =3D pmbus_check_status_cml(client); > > > How about PMBUS_READ_STATUS_AFTER_FAILED_CHECK ? added in the next version > > Thanks, > Guenter BR, Adam > > > + pmbus_clear_fault_page(client, -1); > > + return rv >=3D 0; > > +} > > + > > const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client= *client) > > { > > struct pmbus_data *data =3D i2c_get_clientdata(client); > > -- > > 2.17.1