From: "Erim, Salih" <salih.erim@amd.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, git@amd.com, nuno.sa@analog.com,
andy@kernel.org, dlechner@baylibre.com, michal.simek@amd.com,
conall.ogriofa@amd.com, erimsalih@gmail.com,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] iio: adc: versal-sysmon: add I2C driver
Date: Fri, 15 May 2026 16:50:59 +0100 [thread overview]
Message-ID: <1f103bf5-c9fc-480b-9470-258e63d853ad@amd.com> (raw)
In-Reply-To: <afh0GW_SXuq72KwJ@ashevche-desk.local>
Hi Andy,
Replies are inline.
On 04/05/2026 11:25, Andy Shevchenko wrote:
>> +#include <linux/bitfield.h>
>> +#include <linux/bits.h>
>> +#include <linux/i2c.h>
>> +#include <linux/module.h>
>> +#include <linux/regmap.h>
>
> Follow IWYU.
Accepted. Will audit and add missing includes.
>
> ...
>
>> +enum sysmon_i2c_payload_idx {
>> + SYSMON_I2C_DATA0_IDX = 0,
>
> Is it mapped to HW bits or is it pure Linux enum? If the former, assign *all*
> items as per datasheet, otherwise drop explicit assignment (it's rare that we
> need it in the software).
These are byte offsets in the I2C payload buffer, mapped to the
hardware protocol. Will assign all items explicitly.
>
>> + SYSMON_I2C_DATA1_IDX,
>> + SYSMON_I2C_DATA2_IDX,
>> + SYSMON_I2C_DATA3_IDX,
>> + SYSMON_I2C_OFS_LOW_IDX,
>> + SYSMON_I2C_OFS_HIGH_IDX,
>> + SYSMON_I2C_INSTR_IDX,
>> +};
>
> ...
>
>> +struct sysmon_i2c {
>> + struct i2c_client *client;
>> +};
>
> Can't be the struct i2c_client used directly? (Haven't checked if this is going
> to be extended or have special uses.
Yes, the struct only wraps the client pointer and is not extended
in later patches. Will remove the wrapper and pass struct i2c_client
directly as the regmap context.
>
> ...
>
>> +static int sysmon_i2c_reg_read(void *context, unsigned int reg,
>> + unsigned int *val)
>> +{
>> + u8 write_buf[SYSMON_I2C_WRITE_SIZE] = { 0 };
>> + u8 read_buf[SYSMON_I2C_READ_SIZE];
>> + struct sysmon_i2c *priv = context;
>> + int ret;
>> +
>> + write_buf[SYSMON_I2C_OFS_LOW_IDX] =
>> + FIELD_GET(SYSMON_I2C_OFS_LOW_MASK, reg);
>> + write_buf[SYSMON_I2C_OFS_HIGH_IDX] =
>> + FIELD_GET(SYSMON_I2C_OFS_HIGH_MASK, reg);
>> + write_buf[SYSMON_I2C_INSTR_IDX] = SYSMON_I2C_INSTR_READ;
>> +
>> + ret = i2c_master_send(priv->client, write_buf, SYSMON_I2C_WRITE_SIZE);
>
> sizeof()
>
>> + if (ret < 0)
>> + return ret;
>> + if (ret != SYSMON_I2C_WRITE_SIZE)
>
> sizeof()
>
>> + return -EIO;
>> +
>> + ret = i2c_master_recv(priv->client, read_buf, SYSMON_I2C_READ_SIZE);
>
> sizeof()
>
>> + if (ret < 0)
>> + return ret;
>> + if (ret != SYSMON_I2C_READ_SIZE)
>
> sizeof()
>
> With them the code will have one source of length an be robust to the changes
> of the buffer sizes.
Accepted. Will use sizeof(write_buf) and sizeof(read_buf) throughout
instead of the defines.
>
>> + return -EIO;
>> +
>> + *val = FIELD_PREP(SYSMON_I2C_DATA0_MASK,
>> + read_buf[SYSMON_I2C_DATA0_IDX]) |
>> + FIELD_PREP(SYSMON_I2C_DATA1_MASK,
>> + read_buf[SYSMON_I2C_DATA1_IDX]) |
>> + FIELD_PREP(SYSMON_I2C_DATA2_MASK,
>> + read_buf[SYSMON_I2C_DATA2_IDX]) |
>> + FIELD_PREP(SYSMON_I2C_DATA3_MASK,
>> + read_buf[SYSMON_I2C_DATA3_IDX]);
>> +
>> + return 0;
>> +}
>
> ...
>
>> +static int sysmon_i2c_reg_write(void *context, unsigned int reg,
>> + unsigned int val)
>> +{
>> + u8 write_buf[SYSMON_I2C_WRITE_SIZE] = { 0 };
>
> '0' is redundant.
Accepted. Will use = { } instead.
>
>> + struct sysmon_i2c *priv = context;
>> + int ret;
>> +
>> + write_buf[SYSMON_I2C_DATA0_IDX] =
>> + FIELD_GET(SYSMON_I2C_DATA0_MASK, val);
>> + write_buf[SYSMON_I2C_DATA1_IDX] =
>> + FIELD_GET(SYSMON_I2C_DATA1_MASK, val);
>> + write_buf[SYSMON_I2C_DATA2_IDX] =
>> + FIELD_GET(SYSMON_I2C_DATA2_MASK, val);
>> + write_buf[SYSMON_I2C_DATA3_IDX] =
>> + FIELD_GET(SYSMON_I2C_DATA3_MASK, val);
>> + write_buf[SYSMON_I2C_OFS_LOW_IDX] =
>> + FIELD_GET(SYSMON_I2C_OFS_LOW_MASK, reg);
>> + write_buf[SYSMON_I2C_OFS_HIGH_IDX] =
>> + FIELD_GET(SYSMON_I2C_OFS_HIGH_MASK, reg);
>> + write_buf[SYSMON_I2C_INSTR_IDX] = SYSMON_I2C_INSTR_WRITE;
>
>> + ret = i2c_master_send(priv->client, write_buf, SYSMON_I2C_WRITE_SIZE);
>> + if (ret < 0)
>> + return ret;
>> + if (ret != SYSMON_I2C_WRITE_SIZE)
>> + return -EIO;
>
> sizeof() in both cases.
>
>> + return 0;
>> +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
All items will be addressed in v3.
Salih
next prev parent reply other threads:[~2026-05-15 15:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 11:19 [PATCH v2 0/5] iio: adc: add AMD/Xilinx Versal SysMon driver Salih Erim
2026-05-02 11:19 ` [PATCH v2 1/5] dt-bindings: iio: adc: add xlnx,versal-sysmon binding Salih Erim
2026-05-03 14:20 ` Krzysztof Kozlowski
2026-05-03 22:52 ` Salih Erim
2026-05-02 11:19 ` [PATCH v2 2/5] iio: adc: add Versal SysMon driver Salih Erim
2026-05-04 10:18 ` Andy Shevchenko
2026-05-04 15:50 ` Salih Erim
2026-05-05 7:12 ` Andy Shevchenko
2026-05-04 17:32 ` Jonathan Cameron
2026-05-04 19:26 ` Guenter Roeck
2026-05-12 11:35 ` Salih Erim
2026-05-16 10:20 ` Jonathan Cameron
2026-05-16 15:04 ` Guenter Roeck
2026-05-02 11:19 ` [PATCH v2 3/5] iio: adc: versal-sysmon: add I2C driver Salih Erim
2026-05-04 10:25 ` Andy Shevchenko
2026-05-15 15:50 ` Erim, Salih [this message]
2026-05-02 11:19 ` [PATCH v2 4/5] iio: adc: versal-sysmon: add threshold event support Salih Erim
2026-05-04 10:52 ` Andy Shevchenko
2026-05-04 17:44 ` Jonathan Cameron
2026-05-02 11:19 ` [PATCH v2 5/5] iio: adc: versal-sysmon: add oversampling support Salih Erim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f103bf5-c9fc-480b-9470-258e63d853ad@amd.com \
--to=salih.erim@amd.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conall.ogriofa@amd.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=erimsalih@gmail.com \
--cc=git@amd.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.