Re: [PATCH 2/2] regmap: sdw: Remove 8-bit value size restriction

From: Pierre-Louis Bossart
Date: Thu Jan 12 2023 - 13:11:24 EST




> -static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val)
> +static int regmap_sdw_write(void *context, const void *val_buf, size_t val_size)
> {
> struct device *dev = context;
> struct sdw_slave *slave = dev_to_sdw_dev(dev);
> + /* First word of buffer contains the destination address */
> + u32 addr = le32_to_cpu(*(const __le32 *)val_buf);
> + const u8 *val = val_buf;
>
> - return sdw_write_no_pm(slave, reg, val);
> + return sdw_nwrite_no_pm(slave, addr, val_size - sizeof(addr), val + sizeof(addr));
> }
>
> -static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val)
> +static int regmap_sdw_gather_write(void *context,
> + const void *reg_buf, size_t reg_size,
> + const void *val_buf, size_t val_size)
> {
> struct device *dev = context;
> struct sdw_slave *slave = dev_to_sdw_dev(dev);
> - int read;
> + u32 addr = le32_to_cpu(*(const __le32 *)reg_buf);

what's the difference between regmap_sdw_write() and
regmap_sdw_gather_write()? Seems to me that it's the same functionality
of writing at consecutive addresses. It's not a true 'gather' in the
sense that only the first address is used?

>
> - read = sdw_read_no_pm(slave, reg);
> - if (read < 0)
> - return read;
> + return sdw_nwrite_no_pm(slave, addr, val_size, val_buf);
> +}
>
> - *val = read;
> - return 0;