[PATCH 3/8] rtc: make all reg_write callbacks take const void *
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Jul 15 11:01:23 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Implicit pointer conversions discard the 'const' qualifier, causing compiler warnings.
--
--- Patch [3]: [PATCH 3/8] rtc: make all reg_write callbacks take const void * ---
commit dcceba66c45aeb1e0da5dfaf4cd7b3e0828ec69e
Author: Link Mauve <linkmauve at linkmauve.fr>
rtc: make all reg_write callbacks take const void *
This commit updates various RTC drivers to use a const void * parameter for
their nvmem_config write callbacks, aligning with the updated nvmem_config API.
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index fa04ece151b8b..09da71a0009e8 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
[ ... ]
> @@ -659,7 +659,7 @@ static int cmos_nvram_read(void *priv, unsigned int off, void *val,
> return 0;
> }
>
> -static int cmos_nvram_write(void *priv, unsigned int off, void *val,
> +static int cmos_nvram_write(void *priv, unsigned int off, const void *val,
> size_t count)
> {
> struct cmos_rtc *cmos = priv;
[Severity: Low]
Does this cause a compiler warning for discarded qualifiers?
In the body of cmos_nvram_write(), the code assigns val to a non-const
pointer just below the diff context:
unsigned char *buf = val;
Should buf also be declared as const unsigned char * to avoid breaking
builds where warnings are treated as errors?
> diff --git a/drivers/rtc/rtc-rv3032.c b/drivers/rtc/rtc-rv3032.c
> index 6bafdec637aea..b6b401be09bb5 100644
> --- a/drivers/rtc/rtc-rv3032.c
> +++ b/drivers/rtc/rtc-rv3032.c
[ ... ]
> @@ -493,7 +493,7 @@ static int rv3032_nvram_read(void *priv, unsigned int offset, void *val, size_t
> return regmap_bulk_read(priv, RV3032_RAM1 + offset, val, bytes);
> }
>
> -static int rv3032_eeprom_write(void *priv, unsigned int offset, void *val, size_t bytes)
> +static int rv3032_eeprom_write(void *priv, unsigned int offset, const void *val, size_t bytes)
> {
> struct rv3032_data *rv3032 = priv;
> u32 status, eerd;
[Severity: Low]
Similar to the cmos driver, does this discard the const qualifier?
The rv3032_eeprom_write() function assigns the new const void *val to a
non-const pointer just below the quoted diff context:
u8 *buf = val;
Should this be updated to const u8 *buf as well?
> diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> index b72eef4fb0997..73ff0491f6750 100644
> --- a/drivers/rtc/rtc-s35390a.c
> +++ b/drivers/rtc/rtc-s35390a.c
[ ... ]
> @@ -67,7 +67,7 @@ struct s35390a {
> int twentyfourhour;
> };
>
> -static int s35390a_set_reg(struct s35390a *s35390a, int reg, u8 *buf, int len)
> +static int s35390a_set_reg(struct s35390a *s35390a, int reg, const u8 *buf, int len)
> {
> struct i2c_client *client = s35390a->client[reg];
> struct i2c_msg msg[] = {
[Severity: Low]
Does this assignment in s35390a_set_reg() trigger a discarded qualifiers
warning?
The struct i2c_msg defines its buf member as __u8 * (non-const). When the
msg array is initialized just below this hunk:
struct i2c_msg msg[] = {
{
.addr = client->addr,
.len = len,
.buf = buf
},
};
Will assigning the const u8 *buf to the non-const .buf field cause a compiler
warning? Would it be better to explicitly cast it like (u8 *)buf to satisfy
the i2c_msg struct definition?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260715175229.24672-1-linkmauve@linkmauve.fr?part=3
More information about the linux-amlogic
mailing list