* [rtc-linux] [PATCH 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 9:59 [rtc-linux] [PATCH 0/2] bq32000 fixes Daniel Romell
@ 2016-08-11 9:59 ` Daniel Romell
2016-08-11 9:59 ` [rtc-linux] [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Daniel Romell @ 2016-08-11 9:59 UTC (permalink / raw)
To: a.zummo; +Cc: alexandre.belloni, rtc-linux, linux-kernel, daro, jao, mago
From: Jan =C3=96stlund <jao@hms.se>
The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
value. This is no functional change.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 0299988..5a0c137 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -94,7 +94,7 @@ static int bq32k_rtc_read_time(struct device *dev, struct=
rtc_time *tm)
return error;
=20
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
- tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
+ tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
tm->tm_mday =3D bcd2bin(regs.date);
tm->tm_wday =3D bcd2bin(regs.day) - 1;
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread* [rtc-linux] [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag
2016-08-11 9:59 [rtc-linux] [PATCH 0/2] bq32000 fixes Daniel Romell
2016-08-11 9:59 ` [rtc-linux] [PATCH 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
@ 2016-08-11 9:59 ` Daniel Romell
2016-08-11 10:15 ` [rtc-linux] " Alexandre Belloni
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 0/2] bq32000 fixes Daniel Romell
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Daniel Romell @ 2016-08-11 9:59 UTC (permalink / raw)
To: a.zummo; +Cc: alexandre.belloni, rtc-linux, linux-kernel, daro, jao, mago
From: Jan =C3=96stlund <jao@hms.se>
While the oscillator failure flag is set, the RTC registers
should be considered invalid. bq32k_rtc_read_time() now
returns an error instead of an invalid time.
The failure flag is cleared the next time the clock is set.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 5a0c137..3fc6f7c 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -93,6 +93,13 @@ static int bq32k_rtc_read_time(struct device *dev, struc=
t rtc_time *tm)
if (error)
return error;
=20
+ /*
+ * In case of oscillator failure, the register contents should be
+ * considered invalid. The flag is cleared the next time the RTC is set.
+ */
+ if (regs.minutes & BQ32K_OF)
+ return -EIO;
+
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
@@ -204,13 +211,10 @@ static int bq32k_probe(struct i2c_client *client,
=20
/* Check Oscillator Failure flag */
error =3D bq32k_read(dev, ®, BQ32K_MINUTES, 1);
- if (!error && (reg & BQ32K_OF)) {
- dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
- reg &=3D ~BQ32K_OF;
- error =3D bq32k_write(dev, ®, BQ32K_MINUTES, 1);
- }
if (error)
return error;
+ if (reg & BQ32K_OF)
+ dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
=20
if (client->dev.of_node)
trickle_charger_of_init(dev, client->dev.of_node);
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread* [rtc-linux] Re: [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag
2016-08-11 9:59 ` [rtc-linux] [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
@ 2016-08-11 10:15 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2016-08-11 10:15 UTC (permalink / raw)
To: Daniel Romell; +Cc: a.zummo, rtc-linux, linux-kernel, daro, jao, mago
On 11/08/2016 at 11:59:15 +0200, Daniel Romell wrote :
> From: Jan =C3=96stlund <jao@hms.se>
>=20
> While the oscillator failure flag is set, the RTC registers
> should be considered invalid. bq32k_rtc_read_time() now
> returns an error instead of an invalid time.
>=20
> The failure flag is cleared the next time the clock is set.
>=20
> Signed-off-by: Daniel Romell <daro@hms.se>
> ---
> drivers/rtc/rtc-bq32k.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>=20
> diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
> index 5a0c137..3fc6f7c 100644
> --- a/drivers/rtc/rtc-bq32k.c
> +++ b/drivers/rtc/rtc-bq32k.c
> @@ -93,6 +93,13 @@ static int bq32k_rtc_read_time(struct device *dev, str=
uct rtc_time *tm)
> if (error)
> return error;
> =20
> + /*
> + * In case of oscillator failure, the register contents should be
> + * considered invalid. The flag is cleared the next time the RTC is set=
.
> + */
> + if (regs.minutes & BQ32K_OF)
> + return -EIO;
The other drivers return -EINVAL in that case. Else, the change is fine.
> +
> tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
> tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
> tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
> @@ -204,13 +211,10 @@ static int bq32k_probe(struct i2c_client *client,
> =20
> /* Check Oscillator Failure flag */
> error =3D bq32k_read(dev, ®, BQ32K_MINUTES, 1);
> - if (!error && (reg & BQ32K_OF)) {
> - dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
> - reg &=3D ~BQ32K_OF;
> - error =3D bq32k_write(dev, ®, BQ32K_MINUTES, 1);
> - }
> if (error)
> return error;
> + if (reg & BQ32K_OF)
> + dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
> =20
> if (client->dev.of_node)
> trickle_charger_of_init(dev, client->dev.of_node);
> --=20
> 2.7.4
>=20
--=20
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [rtc-linux] [PATCH v2 0/2] bq32000 fixes
2016-08-11 9:59 [rtc-linux] [PATCH 0/2] bq32000 fixes Daniel Romell
2016-08-11 9:59 ` [rtc-linux] [PATCH 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
2016-08-11 9:59 ` [rtc-linux] [PATCH 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
@ 2016-08-11 11:31 ` Daniel Romell
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
4 siblings, 0 replies; 12+ messages in thread
From: Daniel Romell @ 2016-08-11 11:31 UTC (permalink / raw)
To: a.zummo; +Cc: alexandre.belloni, rtc-linux, linux-kernel, daro, jao, mago
Changes since v1:
* Return -EINVAL instead of -EIO when failure flag is set.
Jan =C3=96stlund (2):
rtc: bq32k: Use correct mask name for 'minutes' register.
rtc: bq32k: Fix handling of oscillator failure flag
drivers/rtc/rtc-bq32k.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
--
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [rtc-linux] [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 9:59 [rtc-linux] [PATCH 0/2] bq32000 fixes Daniel Romell
` (2 preceding siblings ...)
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 0/2] bq32000 fixes Daniel Romell
@ 2016-08-11 11:31 ` Daniel Romell
2016-08-11 13:42 ` [rtc-linux] " Alexandre Belloni
2016-08-15 7:10 ` [rtc-linux] " Jan Östlund
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
4 siblings, 2 replies; 12+ messages in thread
From: Daniel Romell @ 2016-08-11 11:31 UTC (permalink / raw)
To: a.zummo; +Cc: alexandre.belloni, rtc-linux, linux-kernel, daro, jao, mago
From: Jan =C3=96stlund <jao@hms.se>
The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
value. This is no functional change.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 0299988..5a0c137 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -94,7 +94,7 @@ static int bq32k_rtc_read_time(struct device *dev, struct=
rtc_time *tm)
return error;
=20
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
- tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
+ tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
tm->tm_mday =3D bcd2bin(regs.date);
tm->tm_wday =3D bcd2bin(regs.day) - 1;
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread* [rtc-linux] Re: [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
@ 2016-08-11 13:42 ` Alexandre Belloni
2016-08-11 14:56 ` danielromell
2016-08-15 7:10 ` [rtc-linux] " Jan Östlund
1 sibling, 1 reply; 12+ messages in thread
From: Alexandre Belloni @ 2016-08-11 13:42 UTC (permalink / raw)
To: Daniel Romell; +Cc: a.zummo, rtc-linux, linux-kernel, daro, jao, mago
On 11/08/2016 at 13:31:43 +0200, Daniel Romell wrote :
> From: Jan =C3=96stlund <jao@hms.se>
>=20
> The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
> value. This is no functional change.
>=20
> Signed-off-by: Daniel Romell <daro@hms.se>
Sorry, I saw it only before trying apply but both patches also need Jan's S=
oB.
> ---
> drivers/rtc/rtc-bq32k.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>=20
> diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
> index 0299988..5a0c137 100644
> --- a/drivers/rtc/rtc-bq32k.c
> +++ b/drivers/rtc/rtc-bq32k.c
> @@ -94,7 +94,7 @@ static int bq32k_rtc_read_time(struct device *dev, stru=
ct rtc_time *tm)
> return error;
> =20
> tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
> - tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
> + tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
> tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
> tm->tm_mday =3D bcd2bin(regs.date);
> tm->tm_wday =3D bcd2bin(regs.day) - 1;
> --=20
> 2.7.4
>=20
--=20
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [rtc-linux] Re: [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 13:42 ` [rtc-linux] " Alexandre Belloni
@ 2016-08-11 14:56 ` danielromell
2016-08-11 21:13 ` Alexandre Belloni
0 siblings, 1 reply; 12+ messages in thread
From: danielromell @ 2016-08-11 14:56 UTC (permalink / raw)
To: rtc-linux; +Cc: danielromell, a.zummo, linux-kernel, daro, jao, mago
[-- Attachment #1.1: Type: text/plain, Size: 2119 bytes --]
Den torsdag 11 augusti 2016 kl. 15:42:58 UTC+2 skrev alexandre.belloni:
>
> On 11/08/2016 at 13:31:43 +0200, Daniel Romell wrote :
> > From: Jan Östlund <j...@hms.se <javascript:>>
> >
> > The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
> > value. This is no functional change.
> >
> > Signed-off-by: Daniel Romell <da...@hms.se <javascript:>>
>
> Sorry, I saw it only before trying apply but both patches also need Jan's
> SoB.
>
Ah, sorry, my bad. I'll ask him to add that.
Is it ok if he just reply to the emails with his SoB line, or do you need a
new patch set?
>
> > ---
> > drivers/rtc/rtc-bq32k.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
> > index 0299988..5a0c137 100644
> > --- a/drivers/rtc/rtc-bq32k.c
> > +++ b/drivers/rtc/rtc-bq32k.c
> > @@ -94,7 +94,7 @@ static int bq32k_rtc_read_time(struct device *dev,
> struct rtc_time *tm)
> > return error;
> >
> > tm->tm_sec = bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
> > - tm->tm_min = bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
> > + tm->tm_min = bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
> > tm->tm_hour = bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
> > tm->tm_mday = bcd2bin(regs.date);
> > tm->tm_wday = bcd2bin(regs.day) - 1;
> > --
> > 2.7.4
> >
>
> --
> Alexandre Belloni, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
>
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #1.2: Type: text/html, Size: 3796 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [rtc-linux] Re: [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 14:56 ` danielromell
@ 2016-08-11 21:13 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2016-08-11 21:13 UTC (permalink / raw)
To: danielromell; +Cc: rtc-linux, a.zummo, linux-kernel, daro, jao, mago
On 11/08/2016 at 07:56:03 -0700, danielromell@gmail.com wrote :
>
>
> Den torsdag 11 augusti 2016 kl. 15:42:58 UTC+2 skrev alexandre.belloni:
> >
> > On 11/08/2016 at 13:31:43 +0200, Daniel Romell wrote :
> > > From: Jan Östlund <j...@hms.se <javascript:>>
> > >
> > > The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
> > > value. This is no functional change.
> > >
> > > Signed-off-by: Daniel Romell <da...@hms.se <javascript:>>
> >
> > Sorry, I saw it only before trying apply but both patches also need Jan's
> > SoB.
> >
>
> Ah, sorry, my bad. I'll ask him to add that.
> Is it ok if he just reply to the emails with his SoB line, or do you need a
> new patch set?
>
That's a bit unconventional but I'm fine with a simple mail.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [rtc-linux] RE: [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register.
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
2016-08-11 13:42 ` [rtc-linux] " Alexandre Belloni
@ 2016-08-15 7:10 ` Jan Östlund
1 sibling, 0 replies; 12+ messages in thread
From: Jan Östlund @ 2016-08-15 7:10 UTC (permalink / raw)
To: Daniel Romell, a.zummo@towertech.it
Cc: alexandre.belloni@free-electrons.com, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org, Daniel Romell, Magnus Olsson
Signed-off-by: Jan =C3=96stlund <jao@hms.se>
-----Original Message-----
From: Daniel Romell [mailto:danielromell@gmail.com]=20
Sent: den 11 augusti 2016 13:32
To: a.zummo@towertech.it
Cc: alexandre.belloni@free-electrons.com; rtc-linux@googlegroups.com; linux=
-kernel@vger.kernel.org; Daniel Romell <Daro@hms.se>; Jan =C3=96stlund <jao=
@hms.se>; Magnus Olsson <Mago@hms.se>
Subject: [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' reg=
ister.
From: Jan =C3=96stlund <jao@hms.se>
The BQ32K_SECONDS_MASK and BQ32K_MINUTES_MASK both has the same
value. This is no functional change.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 0299988..5a0c137 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -94,7 +94,7 @@ static int bq32k_rtc_read_time(struct device *dev, struct=
rtc_time *tm)
return error;
=20
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
- tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
+ tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
tm->tm_mday =3D bcd2bin(regs.date);
tm->tm_wday =3D bcd2bin(regs.day) - 1;
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [rtc-linux] [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag
2016-08-11 9:59 [rtc-linux] [PATCH 0/2] bq32000 fixes Daniel Romell
` (3 preceding siblings ...)
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 1/2] rtc: bq32k: Use correct mask name for 'minutes' register Daniel Romell
@ 2016-08-11 11:31 ` Daniel Romell
2016-08-15 7:10 ` [rtc-linux] " Jan Östlund
4 siblings, 1 reply; 12+ messages in thread
From: Daniel Romell @ 2016-08-11 11:31 UTC (permalink / raw)
To: a.zummo; +Cc: alexandre.belloni, rtc-linux, linux-kernel, daro, jao, mago
From: Jan =C3=96stlund <jao@hms.se>
While the oscillator failure flag is set, the RTC registers
should be considered invalid. bq32k_rtc_read_time() now
returns an error instead of an invalid time.
The failure flag is cleared the next time the clock is set.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 5a0c137..3977424 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -93,6 +93,13 @@ static int bq32k_rtc_read_time(struct device *dev, struc=
t rtc_time *tm)
if (error)
return error;
=20
+ /*
+ * In case of oscillator failure, the register contents should be
+ * considered invalid. The flag is cleared the next time the RTC is set.
+ */
+ if (regs.minutes & BQ32K_OF)
+ return -EINVAL;
+
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
@@ -204,13 +211,10 @@ static int bq32k_probe(struct i2c_client *client,
=20
/* Check Oscillator Failure flag */
error =3D bq32k_read(dev, ®, BQ32K_MINUTES, 1);
- if (!error && (reg & BQ32K_OF)) {
- dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
- reg &=3D ~BQ32K_OF;
- error =3D bq32k_write(dev, ®, BQ32K_MINUTES, 1);
- }
if (error)
return error;
+ if (reg & BQ32K_OF)
+ dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
=20
if (client->dev.of_node)
trickle_charger_of_init(dev, client->dev.of_node);
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread* [rtc-linux] RE: [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag
2016-08-11 11:31 ` [rtc-linux] [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag Daniel Romell
@ 2016-08-15 7:10 ` Jan Östlund
0 siblings, 0 replies; 12+ messages in thread
From: Jan Östlund @ 2016-08-15 7:10 UTC (permalink / raw)
To: Daniel Romell, a.zummo@towertech.it
Cc: alexandre.belloni@free-electrons.com, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org, Daniel Romell, Magnus Olsson
Signed-off-by: Jan =C3=96stlund <jao@hms.se>
-----Original Message-----
From: Daniel Romell [mailto:danielromell@gmail.com]=20
Sent: den 11 augusti 2016 13:32
To: a.zummo@towertech.it
Cc: alexandre.belloni@free-electrons.com; rtc-linux@googlegroups.com; linux=
-kernel@vger.kernel.org; Daniel Romell <Daro@hms.se>; Jan =C3=96stlund <jao=
@hms.se>; Magnus Olsson <Mago@hms.se>
Subject: [PATCH v2 2/2] rtc: bq32k: Fix handling of oscillator failure flag
From: Jan =C3=96stlund <jao@hms.se>
While the oscillator failure flag is set, the RTC registers
should be considered invalid. bq32k_rtc_read_time() now
returns an error instead of an invalid time.
The failure flag is cleared the next time the clock is set.
Signed-off-by: Daniel Romell <daro@hms.se>
---
drivers/rtc/rtc-bq32k.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 5a0c137..3977424 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -93,6 +93,13 @@ static int bq32k_rtc_read_time(struct device *dev, struc=
t rtc_time *tm)
if (error)
return error;
=20
+ /*
+ * In case of oscillator failure, the register contents should be
+ * considered invalid. The flag is cleared the next time the RTC is set.
+ */
+ if (regs.minutes & BQ32K_OF)
+ return -EINVAL;
+
tm->tm_sec =3D bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
tm->tm_min =3D bcd2bin(regs.minutes & BQ32K_MINUTES_MASK);
tm->tm_hour =3D bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
@@ -204,13 +211,10 @@ static int bq32k_probe(struct i2c_client *client,
=20
/* Check Oscillator Failure flag */
error =3D bq32k_read(dev, ®, BQ32K_MINUTES, 1);
- if (!error && (reg & BQ32K_OF)) {
- dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
- reg &=3D ~BQ32K_OF;
- error =3D bq32k_write(dev, ®, BQ32K_MINUTES, 1);
- }
if (error)
return error;
+ if (reg & BQ32K_OF)
+ dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
=20
if (client->dev.of_node)
trickle_charger_of_init(dev, client->dev.of_node);
--=20
2.7.4
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 12+ messages in thread