Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3530181ioo; Wed, 25 May 2022 02:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBRyk6wRMIgBBJQKIwAGZ4d+HKxbf4RE0oTC/wUy/Kkh67hQljsGkMwKel9mLAO/NEGOmq X-Received: by 2002:a17:90a:e7cb:b0:1df:8481:9469 with SMTP id kb11-20020a17090ae7cb00b001df84819469mr9524080pjb.195.1653471852175; Wed, 25 May 2022 02:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653471852; cv=none; d=google.com; s=arc-20160816; b=p0OuKj4t55YSriJbK/GXIja4J8AZK/d71+kT3zc1BpGw5EanfGS5hAJ9Fd7CUVdjlb dUTnUCIpFSY1ClT8aQ98dSJ3PIGULfSDTjXWFjwqA7t4/Go//YX1KWX/ZXefMEaglqyD ubXHoxHIJWE+5p7RBeG/obBW+mhSD5sVUqMm1FcLcUjJQTuFB+Gaf38OgUCMOeM2Wo3i BG5hDWLQiXmRNIgdsGBVmI7OkIz9r0YwSMGe9EGvusEJ800eJZiJFYH0ErY1dn5gqlly OYvw8Er4aJmi90CQmXfIYIdi3SiUgRbsBuxbxTnXKH209rks+hPF+L4S/o771aBNIWjz SFZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :feedback-id:message-id:subject:reply-to:cc:from:dkim-signature:date; bh=o5docbRaScY7qE+aabZGv+6FM73SnDTY1EEaXw5f7GU=; b=waxv71NeY9C0Wi9UDaSLEanpXhowIx9nrlIY+RBmEsiaUD/rQHRJ5LsaX9VYceS39a FU3sYlSvFaxg0+TViBJzfFL+xzMeYaMEXnyyxUUUyEekAk4TS6TlQVd7RAJq60naSTmz kL33jzuNy1IjCABsahFVBOBijMz1N4KRfpC0fj8GQdKRwrLCI8ZWkoDt2VRydFkkMQzJ xaEK9vb58zB9hVGOvLBfLwZK2sGxgDlyd5M7nJBgVrI6x6KGP1AdiPKq/d2mI48n7eqH hThuUxStE3cuCCSF0EZKINAaj09j/wQWSb4ZOnnHsLcjzmb94iSFjiPo7FBcrvh0138J ZBqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b=db1790jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t5-20020a170902d14500b001635c854d48si952994plt.48.2022.05.25.02.43.58; Wed, 25 May 2022 02:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b=db1790jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbiEXKoJ (ORCPT + 99 others); Tue, 24 May 2022 06:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235142AbiEXKoG (ORCPT ); Tue, 24 May 2022 06:44:06 -0400 Received: from mail-4018.proton.ch (mail-4018.proton.ch [185.70.40.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C012D5EDD9 for ; Tue, 24 May 2022 03:44:02 -0700 (PDT) Date: Tue, 24 May 2022 10:43:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1653389039; x=1653648239; bh=o5docbRaScY7qE+aabZGv+6FM73SnDTY1EEaXw5f7GU=; h=Date:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=db1790jdLlzuwCzTJZcS75M20xBQu5RwaSD46AswcuBqnJsTnB3ZpXmXni6ra8wuD GNVP+hLWWV/b1w1fkJwCD+XmbN3vH3mXkwVjlnp6StPWhFYoB0b6wUa5u2IT6No2Ze dRo4uv1DfKFRYBb9cNaUmt/0vGki3pctnVaxhO9rAAhx+NB8m6RVfXr3L3qEl3u7dX 4iNiizP/Z8Y0wsAvVbKgLEVT1XW4eu+4dE7s1EibgiT3PZWf7k80UBjkzYZylXH7lq yI6K7aCJY7P9I252h0myBMqJMPXz39IR7Axm3sUsXaI/KyiH2+Zd3p73/Ah6TKyDnW 6/c0aD9YoGAow== From: Adam Wujek Cc: Adam Wujek , Guenter Roeck , Jean Delvare , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Adam Wujek Subject: [PATCH v2 1/2] hwmon: (pmbus) add a function to check the presence of a block register Message-ID: <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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS,SPF_HELO_NONE, SPF_PASS,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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Other functions (like pmbus_check_byte_register) cannot be used to check the presence of a block register, because it will generate error when PEC is used. Signed-off-by: Adam Wujek --- 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/pmbus_c= ore.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 *cl= ient, int page, int reg) =09return pmbus_read_byte_data(client, page, reg); } +static int pmbus_read_block_data(struct i2c_client *client, int page, u8 r= eg, +=09=09=09=09 char *data_buf) +{ +=09int rv; + +=09rv =3D pmbus_set_page(client, page, 0xff); +=09if (rv < 0) +=09=09return rv; + +=09return i2c_smbus_read_block_data(client, reg, data_buf); +} + static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, int= page, =09=09=09=09=09 int reg) { @@ -558,6 +570,20 @@ bool pmbus_check_word_register(struct i2c_client *clie= nt, 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= , +=09=09=09=09 int reg) +{ +=09int rv; +=09struct pmbus_data *data =3D i2c_get_clientdata(client); +=09char data_buf[I2C_SMBUS_BLOCK_MAX + 2] =3D { 0 }; + +=09rv =3D pmbus_read_block_data(client, page, reg, data_buf); +=09if (rv >=3D 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK)) +=09=09rv =3D pmbus_check_status_cml(client); +=09pmbus_clear_fault_page(client, -1); +=09return rv >=3D 0; +} + const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *c= lient) { =09struct pmbus_data *data =3D i2c_get_clientdata(client); -- 2.17.1