diff mbox series

[v1] modify adm1266 blackbox access flow

Message ID CAJCfHmVSG3c=E6dMkBgdF9EU0sxP8if2g-=xhkSU5t=vEsRbEw@mail.gmail.com (mailing list archive)
State New
Headers show
Series [v1] modify adm1266 blackbox access flow | expand

Commit Message

ChiangBrian 江泳緻 TAO Dec. 25, 2024, 9:51 a.m. UTC
From: Brian Chiang<chiang.brian@inventec.com>

Modify adm1266 blackbox access flow  by only accessing the latest index of data
to speed up the access

Signed-off-by: Brian Chiang<chiang.brian@inventec.com>
---
 drivers/hwmon/pmbus/adm1266.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

    if (ret < 0)
@@ -359,10 +360,16 @@ static int adm1266_nvmem_read_blackbox(struct
adm1266_data *data, u8 *read_buff)

    if (ret != 4)
        return -EIO;
-
+   latest_index = buf[2];
    record_count = buf[3];

-   for (index = 0; index < record_count; index++) {
+    /*get latest index of blackbox data*/
+    ret = adm1266_pmbus_block_xfer(data, ADM1266_READ_BLACKBOX, 1,
&latest_index, read_buff);
+    if (ret < 0)
+        return ret;
+    return 0;
+#if 0 /*comment out the original one , this dump all the blackboxes ,
very time-consuming*/
+    for (index = 0; index < record_count; index++) {
        ret = adm1266_pmbus_block_xfer(data, ADM1266_READ_BLACKBOX, 1,
&index, read_buff);
        if (ret < 0)
            return ret;
@@ -374,6 +381,7 @@ static int adm1266_nvmem_read_blackbox(struct
adm1266_data *data, u8 *read_buff)
    }

    return 0;
+#endif
 }

 static int adm1266_nvmem_read(void *priv, unsigned int offset, void
*val, size_t bytes)
diff mbox series

Patch

diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
index ec5f932fc6f0..d79b2208de86 100644
--- a/drivers/hwmon/pmbus/adm1266.c
+++ b/drivers/hwmon/pmbus/adm1266.c
@@ -352,6 +352,7 @@  static int adm1266_nvmem_read_blackbox(struct
adm1266_data *data, u8 *read_buff)
    char index;
    u8 buf[5];
    int ret;
+    char latest_index = 0;

    ret = i2c_smbus_read_block_data(data->client, ADM1266_BLACKBOX_INFO, buf);