Re: [PATCH v5 3/6] rtc: s35390a: Fix alarm not disabling

Markus Probst <[email protected]>
Newsgroups org.kernel.vger.linux-gpio,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc
Message-ID <[email protected]>
On Thu, 2026-08-20 at 00:25 +0200, Alexandre Belloni wrote:
> On 19/08/2026 22:05:55+0000, Markus Probst wrote:
> > Implement alarm_irq_enable callback.
> > 
> > Fixes: 542dd33a4925 ("drivers/rtc/rtc-s35390a.c: add wakealarm support for rtc-s35390A rtc chip")
> > Signed-off-by: Markus Probst <[email protected]>
> > ---
> >  drivers/rtc/rtc-s35390a.c | 29 ++++++++++++++++++++++++-----
> >  1 file changed, 24 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
> > index 4cfe7034c516..575bb256eb25 100644
> > --- a/drivers/rtc/rtc-s35390a.c
> > +++ b/drivers/rtc/rtc-s35390a.c
> > @@ -270,6 +270,24 @@ static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm)
> >  	return 0;
> >  }
> >  
> > +static int s35390a_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
> > +{
> > +	struct s35390a *s35390a = dev_get_drvdata(dev);
> > +	u8 sts;
> > +	int err;
> > +
> > +	if (enabled)
> > +		sts = S35390A_INT2_MODE_ALARM;
> > +	else
> > +		sts = S35390A_INT2_MODE_NOINTR;
> > +
> > +	err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts));
> > +	if (err < 0)
> > +		return err;
> > +
> > +	return 0;
> > +}
> 
> 
> You can definitively call this from s35390a_rtc_set_alarm instead of
> duplicating code.
At this stage yes.

With the pinctrl patch, it needs to be considered that the other pin
might be used as well, so the state needs to be preserved.

This will be done by reading the S35390A_CMD_STATUS2 register first.

This function will not be called in set_alarm, because this would
introduce additional read operations, as the current
S35390A_CMD_STATUS2 reg is already read inside set_alarm.

Thanks
- Markus Probst

> 
> > +
> >  static int s35390a_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
> >  {
> >  	struct i2c_client *client = to_i2c_client(dev);
> > @@ -410,11 +428,12 @@ static int s35390a_rtc_ioctl(struct device *dev, unsigned int cmd,
> >  }
> >  
> >  static const struct rtc_class_ops s35390a_rtc_ops = {
> > -	.read_time	= s35390a_rtc_read_time,
> > -	.set_time	= s35390a_rtc_set_time,
> > -	.set_alarm	= s35390a_rtc_set_alarm,
> > -	.read_alarm	= s35390a_rtc_read_alarm,
> > -	.ioctl          = s35390a_rtc_ioctl,
> > +	.read_time		= s35390a_rtc_read_time,
> > +	.set_time		= s35390a_rtc_set_time,
> > +	.set_alarm		= s35390a_rtc_set_alarm,
> > +	.read_alarm		= s35390a_rtc_read_alarm,
> > +	.alarm_irq_enable	= s35390a_rtc_alarm_irq_enable,
> > +	.ioctl			= s35390a_rtc_ioctl,
> >  };
> >  
> >  static int s35390a_nvmem_read(void *priv, unsigned int offset, void *val,
> > 
> > -- 
> > 2.54.0
> >
signature.asc (application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmqGLjUbFIAAAAAABAAO
bWFudTIsMi41KzEuMTIsMiwyAAoJEDR2H/jnrUPShlUQALffJ/72tdeDsOjzYA1p
48AIGvY9/qJxcV+JpHYIVl1+QHRUzB8t/J66OmKwspy2q/LszXvaRyYD2d+Loq9E
eBHh9fO+xJgRhOw0btUhAtn5cXBGt9hx3h5eVutDCiRYJZaW+gACYHkNjHNUTsft
7HOtWxd1x/h8cR8jOsazVNPpPxbdk+PdhwIAw0SxCxoCFtjUMJFsWWERHX5HwZsg
rWwCNW6b9cfFDTaNqxM3LjistbAvM/+AV4r8qnBoKHlzB1JkX/J/v+kGRyvnlYEw
JR2Q97W2MXLrcae/Fucw0cixmax/vJppyGHZSdP4eUwhs3CWUoqKEWYH2ej0ujBM
SWAr5A6HZ0upczQ2gRUDIcwX7dt+JEU+0nD2Q82Xpm36A9YruukX2QtBlivU8cB+
GQfbD4OxO+eQlBr5hegPxObs0Mbeb/5GD9MYcnHeb1DkJ/1GbqXTeAQNvsXmIaMg
bHZHMfsHb5X9Qqn7bqlglPMVMPx6HMnETd1k5Gf9wF4dcGaHqU2RO0jC38GAYGzm
lUmO/83Q3q5ZnP601B9zaDOMOHnIx6UhK/gxy8n3AHO83V2xmu6DA5YS1i0DDjWu
UnasGV0WdbGrAwHjPr50FNIgoTg8lJWYegUrrAf5GoDAVcoCnCZsuwV8mjZRcLWD
EjLKxioAGZ+OiENl6SktwAm1
=fwjU
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.