Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4546506pxb; Wed, 20 Apr 2022 05:35:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFntNGfX4rH1yW8qj9eehzBuDBjCwTFcrzae3jlGJk1zTymZk+AM9RSpY9vw1sjJdtG+KA X-Received: by 2002:a17:906:8301:b0:6e4:896d:59b1 with SMTP id j1-20020a170906830100b006e4896d59b1mr17482511ejx.396.1650458109728; Wed, 20 Apr 2022 05:35:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650458109; cv=none; d=google.com; s=arc-20160816; b=SyYcSMkvZGHkADv+KwIkHaIpQXpC7/DT2lQ9O8W4D6/38JY80BnaPzmKYKyPirnhLD nXdHtw+h/6V1XqCRfBAKUJEaM3hF6tJtYH/OkzkkgtBF1OiWyDrUkPKxM4qVCPXBFcdX nlc84OimNXotFqE0iUoRPpfJmXQQfZFd4eWOEbZ7tWX9sOof7f2ROj3xGai4Ih5vajJa p3L/sTkg57XuBf+nRYcOMJljfGPvOy2h+YwdiMQicct54v6HprM3ycMGm2hKkw4seLXi ZVK32URMFT1K71xbOkICvY1+laaOJH+n+SzoQ9TTKdz3lXKEB3fhYNG5wgP7Ilx4Tmtg HWfQ== 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=YnTtRLrMceiJAjr17Kev+jb0+4PAI0gLw7VnQdS0VFg=; b=P2ne6+lHB/Xf/gN37nji/OpfDLxNjqqyQEy6Zp5TpOqWlAaPFbotid+dEFONn5C25W LuqYv3rOHzZwOxnV/UJWAwArictecf9RqKBl/UDTsIy1Feyd7Lkuu/QwnPDi+dQeH8uR KXEOFS+QxNPXuP3JnitpRXpxP3DvFRN3dhpjszGXZOvPNqqzWKgDTjTXSphKD5QKxlzk zsFyV42jdYwEDAxVTHofyxxTKU06EJx3pKWvl2VHzHHPbqIcSZ8PoQ5ecVOaXA0kGR2q lRcXbT2P/hFELZxe6uQKBTPSLUUgbAi+2fJnlqjFHjOXd7+t4/Jw6OIusWnfbZPlENAL VZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wujek.eu header.s=protonmail2 header.b="uKNog/vw"; 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 dz13-20020a0564021d4d00b0041d9354ecacsi1695395edb.222.2022.04.20.05.34.44; Wed, 20 Apr 2022 05:35:09 -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="uKNog/vw"; 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 S1358096AbiDSV4n (ORCPT + 99 others); Tue, 19 Apr 2022 17:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357069AbiDSV4j (ORCPT ); Tue, 19 Apr 2022 17:56:39 -0400 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B2C23DA70 for ; Tue, 19 Apr 2022 14:53:54 -0700 (PDT) Date: Tue, 19 Apr 2022 21:53:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wujek.eu; s=protonmail2; t=1650405231; bh=YnTtRLrMceiJAjr17Kev+jb0+4PAI0gLw7VnQdS0VFg=; h=Date:From:Cc:Reply-To:Subject:Message-ID:Feedback-ID:From:To:Cc: Date:Subject:Reply-To:Feedback-ID:Message-ID; b=uKNog/vwKw8AViHsdwdMmnZm+dcneuEAc4WZ8cZqB+452RsA30FPlhL6vejhu8w6C ee35audlkd6ruIfzsoqizhKCIeKzPXg7JsN3g7jDjWgJYCDBXMwsuneJ9idD7R1VDB opmUEIS7cdYoUhYmFVyItWbmrHm58UfRAddaaWvioL5FuY1GIjILAaibDzxE/R5VHp nWqP9u+ZMOLZhLG95xyeBXXFIUkvhcZIDqmuotxXPAGQo14xkPqsWohjNGKLvVpmGK wL4+eY5kuEIG+kbz1N6gPdS9T1eZcDrHDV8VWHstFC35YjwgSN2tkJkD/FJp6kmvcG IGqA6nIVxECcA== 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] hwmon: (pmbus) add MFR_* registers to debugfs Message-ID: <20220419215326.309991-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 Add registers to debugfs: PMBUS_MFR_ID PMBUS_MFR_MODEL PMBUS_MFR_REVISION PMBUS_MFR_LOCATION PMBUS_MFR_DATE PMBUS_MFR_SERIAL Signed-off-by: Adam Wujek --- drivers/hwmon/pmbus/pmbus_core.c | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index ef9989be8f89..6dc63f364ee6 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2156,6 +2156,31 @@ static int pmbus_debugfs_get_status(void *data, u64 = *val) DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_statu= s, =09=09=09 NULL, "0x%04llx\n"); + +static ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf, +=09=09=09=09 size_t count, loff_t *ppos) +{ +=09int rc; +=09struct pmbus_debugfs_entry *entry =3D file->private_data; +=09char data[I2C_SMBUS_BLOCK_MAX + 2] =3D { 0 }; + +=09rc =3D i2c_smbus_read_block_data(entry->client, entry->reg, data); +=09if (rc < 0) +=09=09return rc; + +=09data[rc] =3D '\n'; +=09rc +=3D 2; + +=09return simple_read_from_buffer(buf, count, ppos, data, rc); +} + +static const struct file_operations pmbus_debugfs_ops_mfr =3D { +=09.llseek =3D noop_llseek, +=09.read =3D pmbus_debugfs_mfr_read, +=09.write =3D NULL, +=09.open =3D simple_open, +}; + static int pmbus_init_debugfs(struct i2c_client *client, =09=09=09 struct pmbus_data *data) { @@ -2286,6 +2311,66 @@ static int pmbus_init_debugfs(struct i2c_client *cli= ent, =09=09=09=09=09 &entries[idx++], =09=09=09=09=09 &pmbus_debugfs_ops); =09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_ID)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_ID; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_id", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_MODEL)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_MODEL; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_model", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_REVISION)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_REVISION; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_revision", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_LOCATION)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_LOCATION; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_location", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_DATE)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_DATE; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_date", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} + +=09=09if (pmbus_check_byte_register(client, i, PMBUS_MFR_SERIAL)) { +=09=09=09entries[idx].client =3D client; +=09=09=09entries[idx].page =3D i; +=09=09=09entries[idx].reg =3D PMBUS_MFR_SERIAL; +=09=09=09scnprintf(name, PMBUS_NAME_SIZE, "mfr%d_serial", i); +=09=09=09debugfs_create_file(name, 0444, data->debugfs, +=09=09=09=09=09 &entries[idx++], +=09=09=09=09=09 &pmbus_debugfs_ops_mfr); +=09=09} =09} =09return 0; -- 2.17.1