Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1134279ioo; Sun, 22 May 2022 04:57:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYiogK+UBDiugNxA0XrUfFqhv1Ue0iPwMH7S3EK8aSKMgiKpelT+yD/zm8z6ANFAetdIde X-Received: by 2002:a17:902:eb01:b0:162:2486:7840 with SMTP id l1-20020a170902eb0100b0016224867840mr681489plb.161.1653220620939; Sun, 22 May 2022 04:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653220620; cv=none; d=google.com; s=arc-20160816; b=OR4vG5B51BwlaZp5lb/99Kjijt05MXVNQiJHNiBpxRzebVDTXZnxUdS4yOf8Na1ixo vIUhgzrLq+6RCOX3XLrACSVSTaNrJ4lx38+FqFBLy7Ap+zFKEx4swUGoHFfeS+XnV8za sBaaqZHQmUHYtAGnMeTAqQNDljoQXyCtC0nGJEPMWpTx6M77kFGJFSTlrCVd5wDZ5RkN ostwgVNS9EPjTaYQCuyLb/acJ+ecFxcTP00SWT6EziEoeyhzSnq1ULPexmJW2C5Kn4jn Xwa0V0mPhQ526kgbbBVLb8NDRUxMfjD7bmrhehVxLU4iTDTS2mv3YWRVFLVfz+HwSa/8 jyWg== 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=lPrxtgyGbqzHKGsEAjyQEVN37SrtZOBlF6GrEMqQqa4=; b=h07SYrAJXIt18CK9O3PSjba2jIBmWxCNRoSBwcpBRuTt/7F3cJDysIYYBwj/x7tWdQ kvUbkPw0OTKLfjAZYwq+nU90j0bKao+ySBua2ATeAFqWVdTE2bbLiMelO9iQMD8cQN+O QBfcRM7si/VkS1eKj9uY1lpttFezl3Az4FWNwtHcGORVJQj6ViqvjZb1iQWvKtuDx++4 CzzFFNThSpT3LBSaXFs+ey9d8HDxxASTNAHuqixm5CFEOXPoyhne7l2Y6f5QadpIzP9N APfskozaPZ6HGpwdDmImEemEsVzu/+GJAewBcZlsVfR7NG9tPF10x7yHgE3mTJZ7thAL eIvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b=xKJykPBB; 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 k14-20020a170902d58e00b00153b2d16543si6463159plh.331.2022.05.22.04.56.49; Sun, 22 May 2022 04:57:00 -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=xKJykPBB; 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 S1343669AbiESXoJ (ORCPT + 99 others); Thu, 19 May 2022 19:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343642AbiESXoH (ORCPT ); Thu, 19 May 2022 19:44:07 -0400 Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B408CBA555 for ; Thu, 19 May 2022 16:44:05 -0700 (PDT) Date: Thu, 19 May 2022 23:43:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1653003843; x=1653263043; bh=lPrxtgyGbqzHKGsEAjyQEVN37SrtZOBlF6GrEMqQqa4=; h=Date:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=xKJykPBBx/L5Vr1t7xUnI5x9TGXgE8IgXjj4CPVLrIdChu1VQn3ZH82SI2oW0PGSZ 0oYhG5ZxgtbNwK0EhUoDwMGqxdizlMseFdG/PSHw+duBPymJIBbbSBJI7A4vBAIBEV iovnmzSL/nrfMGQLhd73LoECz/qmmqiNYzPiOmPeUv44l/B/NuOmxHh/Co6c94N519 fr9JYm8hFWS1iI2ROz8D/BnuSHjswIx9CAjSV6npxOSkS+QsHy+MpqTYueTM14+ShH mIAdN1jFBaM+QSMh3nVSzbGAv/Utwu3pw8916kbMp5bc5Bjs4xR1pftuhMspj0ztmp zIeBuSsCDUynA== 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 1/3] hwmon: (pmbus) add a function to check the presence of a block register Message-ID: <20220519234346.440398-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 --- 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 55153a71c170..2634ac1fa3d5 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); +=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