rtc: introduce rtc_device.ops_lock guard()
Subsystems (6)
[email protected]
maintainerPATCH 1/19 rtc: introduce rtc_device.ops_lock guard()
From: Alexandre Belloni <[email protected]>
Add guard class for rtc_device.ops_lock locks. This allows to simplify error handling in interrupt handlers.
--- include/linux/rtc.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/rtc.h +3 -0
@@ -168,6 +168,9 @@ struct rtc_device {#define rtc_lock (d) mutex_lock(&d->ops_lock)#define rtc_unlock (d) mutex_unlock(&d->ops_lock) +DEFINE_GUARD(rtc_ops, struct rtc_device *, mutex_lock(&_T->ops_lock), +mutex_unlock (&_T->ops_lock)) + /* useful timestamps */#define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL/* 0000-01-01 00:00:00 */ #define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL/* 1900-01-01 00:00:00 */
Signature · 1 line
2.56.0
[email protected]
maintainerPATCH 2/19 rtc: ac100: use guard
From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-ac100.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ac100.c +4 -6
@@ -529,12 +529,12 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)unsigned int val =0 ;int ret; -rtc_lock (chip->rtc); +guard (rtc_ops)(chip->rtc);/* read status */ ret =regmap_read (regmap,AC100_ALM_INT_STA , &val);if (ret) - goto out; +return IRQ_HANDLED ;if (val &AC100_ALM_INT_ENABLE ) {/* signal rtc framework */
@@ -543,16 +543,14 @@ static irqreturn_t ac100_rtc_irq(int irq, void *data)/* clear status */ ret =regmap_write (regmap,AC100_ALM_INT_STA , val);if (ret) - goto out; +return IRQ_HANDLED ;/* disable interrupt */ ret =ac100_rtc_alarm_irq_enable (chip->dev,0 );if (ret) - goto out; +return IRQ_HANDLED ; } -out: -rtc_unlock (chip->rtc);return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 02/19] rtc: ac100: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
maintainerPATCH 3/19 rtc: asm9260: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-asm9260.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-asm9260.c +1 -3
@@ -116,15 +116,13 @@ static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)u32 isr;unsigned long events =0 ; -rtc_lock (priv->rtc); +guard (rtc_ops)(priv->rtc); isr =ioread32 (priv->iobase +HW_CIIR );if (!isr) { -rtc_unlock (priv->rtc);return IRQ_NONE ; }iowrite32 (0 , priv->iobase +HW_CIIR ); -rtc_unlock (priv->rtc); events |=RTC_AF |RTC_IRQF ;
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 03/19] rtc: asm9260: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
maintainerPATCH 4/19 rtc: atcrtc100: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-atcrtc100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-atcrtc100.c +1 -2
@@ -147,7 +147,7 @@ static void atcrtc_alarm_clear(struct work_struct *work) container_of(work, struct atcrtc_dev, rtc_work);int ret; -rtc_lock (rtc->rtc_dev); +guard (rtc_ops)(rtc->rtc_dev);if (!rtc->alarm_en) { ret =atcrtc_check_write_done (rtc);
@@ -159,7 +159,6 @@ static void atcrtc_alarm_clear(struct work_struct *work)regmap_update_bits (rtc->regmap,RTC_CR ,ALARM_WAKEUP |ALARM_INT ,0 ); } -rtc_unlock (rtc->rtc_dev); }static int atcrtc_read_time (struct device *dev,struct rtc_time *tm)
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 04/19] rtc: atcrtc100: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
maintainerPATCH 5/19 rtc: ds1305: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-ds1305.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-ds1305.c +1 -3
@@ -440,7 +440,7 @@ static void ds1305_work(struct work_struct *work)int status;/* lock to protect ds1305->ctrl */ -rtc_lock (ds1305->rtc); +guard (rtc_ops)(ds1305->rtc);/* Disable the IRQ, and clear its status ... for now, we "know" * that if more than one alarm is active, they're in sync.
@@ -458,8 +458,6 @@ static void ds1305_work(struct work_struct *work)if (status <0 )dev_dbg (&spi->dev,"clear irq --> %d\n" , status); -rtc_unlock (ds1305->rtc); -if (!test_bit (FLAG_EXITING , &ds1305->flags))enable_irq (spi->irq);
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 05/19] rtc: ds1305: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
maintainerPATCH 6/19 rtc: ds1307: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-ds1307.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/rtc/rtc-ds1307.c +6 -7
@@ -579,28 +579,27 @@ static irqreturn_t rx8130_irq(int irq, void *dev_id)u8 ctl[3 ];int ret; -rtc_lock (ds1307->rtc); +guard (rtc_ops)(ds1307->rtc);/* Read control registers. */ ret =regmap_bulk_read (ds1307->regmap,RX8130_REG_EXTENSION , ctl,sizeof (ctl));if (ret <0 ) - goto out; +return IRQ_HANDLED ; +if (!(ctl[1 ] &RX8130_REG_FLAG_AF )) - goto out; +return IRQ_HANDLED ; + ctl[1 ] &= ~RX8130_REG_FLAG_AF ; ctl[2 ] &= ~RX8130_REG_CONTROL0_AIE ; ret =regmap_bulk_write (ds1307->regmap,RX8130_REG_EXTENSION , ctl,sizeof (ctl));if (ret <0 ) - goto out; +return IRQ_HANDLED ;rtc_update_irq (ds1307->rtc,1 ,RTC_AF |RTC_IRQF ); -out: -rtc_unlock (ds1307->rtc); -return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 06/19] rtc: ds1307: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
maintainerPATCH 7/19 rtc: ds1343: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-ds1343.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/rtc/rtc-ds1343.c +2 -4
@@ -312,11 +312,11 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)unsigned int stat;int res =0 ; -rtc_lock (priv->rtc); +guard (rtc_ops)(priv->rtc); res =regmap_read (priv->map,DS1343_STATUS_REG , &stat);if (res) - goto out; +return IRQ_HANDLED ;if (stat &DS1343_IRQF0 ) { stat &= ~DS1343_IRQF0 ;
@@ -328,8 +328,6 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id) DS1343_A0IE, 0); } -out: -rtc_unlock (priv->rtc);return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 07/19] rtc: ds1343: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
[email protected]
maintainerPATCH 8/19 rtc: ds1685: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-ds1685.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-ds1685.c +1 -2
@@ -666,7 +666,7 @@ ds1685_rtc_irq_handler(int irq, void *dev_id)if (unlikely (!rtc))return IRQ_HANDLED ; -rtc_lock (rtc->dev); +guard (rtc_ops)(rtc->dev);/* Ctrlb holds the interrupt-enable bits and ctrlc the flag bits. */ ctrlb = rtc->read (rtc,RTC_CTRL_B );
@@ -711,7 +711,6 @@ ds1685_rtc_irq_handler(int irq, void *dev_id) } }rtc_update_irq (rtc->dev, num_irqs, events); -rtc_unlock (rtc->dev);return events ?IRQ_HANDLED :IRQ_NONE ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 08/19] rtc: ds1685: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Re: [PATCH 08/19] rtc: ds1685: use guard
In reply to [email protected]Quoted 23 lines · On 10/19/2026 17:18, [email protected] wrote:
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>--- drivers/rtc/rtc-ds1685.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/rtc/rtc-ds1685.c +1
-1@@ -666,7 +666,7 @@ ds1685_rtc_irq_handler(int irq, void *dev_id)if (unlikely (!rtc))return IRQ_HANDLED ; -rtc_lock (rtc->dev); +guard (rtc_ops)(rtc->dev);/* Ctrlb holds the interrupt-enable bits and ctrlc the flag bits. */ ctrlb = rtc->read (rtc,RTC_CTRL_B );
drivers/rtc/rtc-ds1685.c ds1685_rtc_irq_handler(int irq, void *dev_id) · line 716
Quoted 7 lines
drivers/rtc/rtc-ds1685.c +0
-1@@ -711,7 +711,6 @@ ds1685_rtc_irq_handler(int irq, void *dev_id) } }rtc_update_irq (rtc->dev, num_irqs, events); -rtc_unlock (rtc->dev);return events ?IRQ_HANDLED :IRQ_NONE ; }
Looks reasonable to me. Thanks!
[email protected]
maintainerPATCH 9/19 rtc: ds3232: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-ds3232.c | 50 ++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 28 deletions(-)
drivers/rtc/rtc-ds3232.c +22 -28
@@ -389,45 +389,39 @@ static irqreturn_t ds3232_irq(int irq, void *dev_id)int ret;int stat, control; -rtc_lock (ds3232->rtc); +guard (rtc_ops)(ds3232->rtc); ret =regmap_read (ds3232->regmap,DS3232_REG_SR , &stat);if (ret) - goto unlock; +return IRQ_HANDLED ;if (stat &DS3232_REG_SR_A1F ) { ret =regmap_read (ds3232->regmap,DS3232_REG_CR , &control);if (ret) {dev_warn (ds3232->dev,"Read Control Register error %d\n" , ret); - }else { -/* disable alarm1 interrupt */ - control &= ~(DS3232_REG_CR_A1IE ); - ret =regmap_write (ds3232->regmap,DS3232_REG_CR , - control); -if (ret) { -dev_warn (ds3232->dev, -"Write Control Register error %d\n" , - ret); - goto unlock; - } - -/* clear the alarm pend flag */ - stat &= ~DS3232_REG_SR_A1F ; - ret =regmap_write (ds3232->regmap,DS3232_REG_SR , stat); -if (ret) { -dev_warn (ds3232->dev, -"Write Status Register error %d\n" , - ret); - goto unlock; - } - -rtc_update_irq (ds3232->rtc,1 ,RTC_AF |RTC_IRQF ); +return IRQ_HANDLED ; + } +/* disable alarm1 interrupt */ + control &= ~(DS3232_REG_CR_A1IE ); + ret =regmap_write (ds3232->regmap,DS3232_REG_CR , control); +if (ret) { +dev_warn (ds3232->dev, +"Write Control Register error %d\n" , ret); +return IRQ_HANDLED ; } - } -unlock: -rtc_unlock (ds3232->rtc); +/* clear the alarm pend flag */ + stat &= ~DS3232_REG_SR_A1F ; + ret =regmap_write (ds3232->regmap,DS3232_REG_SR , stat); +if (ret) { +dev_warn (ds3232->dev, +"Write Status Register error %d\n" , ret); +return IRQ_HANDLED ; + } + +rtc_update_irq (ds3232->rtc,1 ,RTC_AF |RTC_IRQF ); + }return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 09/19] rtc: ds3232: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
[email protected]
maintainerPATCH 10/19 rtc: hym8563: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-hym8563.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/rtc/rtc-hym8563.c +2 -4
@@ -417,7 +417,7 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)struct i2c_client *client = hym8563->client;int data, ret; -rtc_lock (hym8563->rtc); +guard (rtc_ops)(hym8563->rtc);/* Clear the alarm flag */
@@ -425,7 +425,7 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id)if (data <0 ) {dev_err (&client->dev,"%s: error reading i2c data %d\n" , __func__, data); - goto out; +return IRQ_HANDLED ; } data &= ~HYM8563_CTL2_AF ;
@@ -436,8 +436,6 @@ static irqreturn_t hym8563_irq(int irq, void *dev_id) __func__, ret); } -out: -rtc_unlock (hym8563->rtc);return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 10/19] rtc: hym8563: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
[email protected]
maintainerPATCH 11/19 rtc: m41t80: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-m41t80.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/rtc/rtc-m41t80.c +3 -9
@@ -162,19 +162,15 @@ static irqreturn_t m41t80_handle_irq(int irq, void *dev_id)unsigned long events =0 ;int flags, flags_afe; -rtc_lock (m41t80->rtc); +guard (rtc_ops)(m41t80->rtc); flags_afe =i2c_smbus_read_byte_data (client,M41T80_REG_ALARM_MON ); -if (flags_afe <0 ) { -rtc_unlock (m41t80->rtc); +if (flags_afe <0 )return IRQ_NONE ; - } flags =i2c_smbus_read_byte_data (client,M41T80_REG_FLAGS ); -if (flags <=0 ) { -rtc_unlock (m41t80->rtc); +if (flags <=0 )return IRQ_NONE ; - }if (flags &M41T80_FLAGS_AF ) { flags &= ~M41T80_FLAGS_AF ;
@@ -189,8 +185,6 @@ static irqreturn_t m41t80_handle_irq(int irq, void *dev_id) flags_afe); } -rtc_unlock (m41t80->rtc); -return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 11/19] rtc: m41t80: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
[email protected]
maintainerPATCH 12/19 rtc: mcp795: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-mcp795.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-mcp795.c +1 -2
@@ -352,7 +352,7 @@ static irqreturn_t mcp795_irq(int irq, void *data)struct rtc_device *rtc =spi_get_drvdata (spi);int ret; -rtc_lock (rtc); +guard (rtc_ops)(rtc);/* Disable alarm. * There is no need to clear ALM0IF (Alarm 0 Interrupt Flag) bit,
@@ -364,7 +364,6 @@ static irqreturn_t mcp795_irq(int irq, void *data) "Failed to disable alarm in IRQ (ret=%d)\n", ret);rtc_update_irq (rtc,1 ,RTC_AF |RTC_IRQF ); -rtc_unlock (rtc);return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 12/19] rtc: mcp795: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
[email protected]
maintainerPATCH 13/19 rtc: nct6694: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-nct6694.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-nct6694.c +2 -6
@@ -210,20 +210,16 @@ static irqreturn_t nct6694_irq(int irq, void *dev_id) };int ret; -rtc_lock (data->rtc); +guard (rtc_ops)(data->rtc); sts->irq_en =NCT6694_RTC_IRQ_EN ; sts->irq_pend =NCT6694_RTC_IRQ_STS ; ret =nct6694_write_msg (data->nct6694, &cmd_hd, sts); -if (ret) { -rtc_unlock (data->rtc); +if (ret)return IRQ_NONE ; - }rtc_update_irq (data->rtc,1 ,RTC_IRQF |RTC_AF ); -rtc_unlock (data->rtc); -return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 13/19] rtc: nct6694: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=13
[email protected]
maintainerPATCH 14/19 rtc: pcf2123: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-pcf2123.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/rtc/rtc-pcf2123.c +2 -3
@@ -310,7 +310,8 @@ static irqreturn_t pcf2123_rtc_irq(int irq, void *dev)unsigned int val =0 ;int ret =IRQ_NONE ; -rtc_lock (pcf2123->rtc); +guard (rtc_ops)(pcf2123->rtc); +regmap_read (pcf2123->map,PCF2123_REG_CTRL2 , &val);/* Alarm? */
@@ -323,8 +324,6 @@ static irqreturn_t pcf2123_rtc_irq(int irq, void *dev)rtc_update_irq (pcf2123->rtc,1 ,RTC_IRQF |RTC_AF ); } -rtc_unlock (pcf2123->rtc); -return ret; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 14/19] rtc: pcf2123: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
[email protected]
maintainerPATCH 15/19 rtc: rv3029c2: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-rv3029c2.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/rtc/rtc-rv3029c2.c +1 -4
@@ -270,19 +270,17 @@ static irqreturn_t rv3029_handle_irq(int irq, void *dev_id)unsigned long events =0 ;int ret; -rtc_lock (rv3029->rtc); +guard (rtc_ops)(rv3029->rtc); ret =regmap_read (rv3029->regmap,RV3029_IRQ_CTRL , &controls);if (ret) {dev_warn (dev,"Read IRQ Control Register error %d\n" , ret); -rtc_unlock (rv3029->rtc);return IRQ_NONE ; } ret =regmap_read (rv3029->regmap,RV3029_IRQ_FLAGS , &flags);if (ret) {dev_warn (dev,"Read IRQ Flags Register error %d\n" , ret); -rtc_unlock (rv3029->rtc);return IRQ_NONE ; }
@@ -297,7 +295,6 @@ static irqreturn_t rv3029_handle_irq(int irq, void *dev_id)regmap_write (rv3029->regmap,RV3029_IRQ_FLAGS , flags);regmap_write (rv3029->regmap,RV3029_IRQ_CTRL , controls); } -rtc_unlock (rv3029->rtc);return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 15/19] rtc: rv3029c2: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15
[email protected]
maintainerPATCH 16/19 rtc: rx8010: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-rx8010.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-rx8010.c +1 -3
@@ -73,11 +73,10 @@ static irqreturn_t rx8010_irq_1_handler(int irq, void *dev_id)struct rx8010_data *rx8010 =i2c_get_clientdata (client);int flagreg, err; -rtc_lock (rx8010->rtc); +guard (rtc_ops)(rx8010->rtc); err =regmap_read (rx8010->regs,RX8010_FLAG , &flagreg);if (err) { -rtc_unlock (rx8010->rtc);return IRQ_NONE ; }
@@ -100,7 +99,6 @@ static irqreturn_t rx8010_irq_1_handler(int irq, void *dev_id) } err =regmap_write (rx8010->regs,RX8010_FLAG , flagreg); -rtc_unlock (rx8010->rtc);return err ?IRQ_NONE :IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 16/19] rtc: rx8010: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
[email protected]
maintainerPATCH 17/19 rtc: rx8025: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify error handling
--- drivers/rtc/rtc-rx8025.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/rtc/rtc-rx8025.c +4 -6
@@ -180,10 +180,11 @@ static irqreturn_t rx8025_handle_irq(int irq, void *dev_id)struct rx8025_data *rx8025 =i2c_get_clientdata (client);int status, xstp; -rtc_lock (rx8025->rtc); +guard (rtc_ops)(rx8025->rtc); + status =rx8025_read_reg (client,RX8025_REG_CTRL2 );if (status <0 ) - goto out; +return IRQ_HANDLED ; xstp =rx8025_is_osc_stopped (rx8025->model, status);if (xstp)
@@ -201,13 +202,10 @@ static irqreturn_t rx8025_handle_irq(int irq, void *dev_id) status &=RX8025_BIT_CTRL2_DAFG ;if (rx8025_write_reg (client,RX8025_REG_CTRL1 , rx8025->ctrl1 & ~RX8025_BIT_CTRL1_DALE )) - goto out; +return IRQ_HANDLED ;rtc_update_irq (rx8025->rtc,1 ,RTC_AF |RTC_IRQF ); } -out: -rtc_unlock (rx8025->rtc); -return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 17/19] rtc: rx8025: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify error handlingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
[email protected]
maintainerPATCH 18/19 rtc: stm32: use guard
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use guard() to simplify locking
--- drivers/rtc/rtc-stm32.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-stm32.c +1 -3
@@ -465,7 +465,7 @@ static irqreturn_t stm32_rtc_alarm_irq(int irq, void *dev_id)const struct stm32_rtc_events *evts = &rtc->data->events;unsigned int status, cr; -rtc_lock (rtc->rtc_dev); +guard (rtc_ops)(rtc->rtc_dev); status =readl_relaxed (rtc->base + regs->sr); cr =readl_relaxed (rtc->base + regs->cr);
@@ -482,8 +482,6 @@ static irqreturn_t stm32_rtc_alarm_irq(int irq, void *dev_id)stm32_rtc_clear_event_flags (rtc, evts->alra); } -rtc_unlock (rtc->rtc_dev); -return IRQ_HANDLED ; }
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 18/19] rtc: stm32: use guard
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines
From: Alexandre Belloni <[email protected]>
Use
guard()to simplify lockingSigned-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18
[email protected]
maintainerPATCH 19/19 rtc: abx80x: simplify locking
In reply to [email protected]From: Alexandre Belloni <[email protected]>
Use the ops_lock that is used by the core to lock operations. This ensures we will never get any ABBA deadlock.
--- drivers/rtc/rtc-abx80x.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/rtc/rtc-abx80x.c +7 -20
@@ -15,7 +15,6 @@#include <linux/i2c.h> #include <linux/kstrtox.h> #include <linux/module.h> -#include <linux/mutex.h> #include <linux/of.h> #include <linux/regmap.h> #include <linux/rtc.h>
@@ -138,7 +137,6 @@ struct abx80x_priv {struct rtc_device *rtc;struct regmap *regmap;struct watchdog_device wdog; -struct mutex lock;int irq; };
@@ -249,8 +247,6 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm) buf[ABX8XX_REG_YR ] =bin2bcd (tm->tm_year -100 ); buf[ABX8XX_REG_WD ] = tm->tm_wday; -guard (mutex)(&priv->lock); - err =regmap_bulk_write (priv->regmap,ABX8XX_REG_HTH , buf,sizeof (buf));if (err <0 ) {
@@ -274,7 +270,7 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)unsigned int status, status_flags_clear;int err; -guard (mutex)(&priv->lock); +guard (rtc_ops)(rtc); err =regmap_read (priv->regmap,ABX8XX_REG_STATUS , &status);if (err <0 )
@@ -349,8 +345,6 @@ static int abx80x_set_alarm(struct device *dev, struct rtc_wkalrm *t) alarm[4 ] =bin2bcd (t->time.tm_mday); alarm[5 ] =bin2bcd (t->time.tm_mon +1 ); -guard (mutex)(&priv->lock); - err =regmap_bulk_write (priv->regmap,ABX8XX_REG_AHTH , alarm,sizeof (alarm));if (err <0 ) {
@@ -391,7 +385,7 @@ static int abx80x_rtc_set_autocalibration(struct device *dev, flags |= (ABX8XX_OSC_ACAL_1024 |ABX8XX_OSC_ACAL_512 ); } -guard (mutex)(&priv->lock); +guard (rtc_ops)(priv->rtc);/* Unlock write access to Oscillator Control Register */ if (abx80x_write_config_key (dev,ABX8XX_CFG_KEY_OSC ) <0 )
@@ -473,7 +467,7 @@ static ssize_t oscillator_store(struct device *dev,return -EINVAL ; } -guard (mutex)(&priv->lock); +guard (rtc_ops)(priv->rtc);/* Unlock write access on Oscillator Control register */ if (abx80x_write_config_key (dev->parent,ABX8XX_CFG_KEY_OSC ) <0 )
@@ -523,8 +517,6 @@ static int abx80x_alarm_irq_enable(struct device *dev, unsigned int enabled)struct abx80x_priv *priv =dev_get_drvdata (dev);int err; -guard (mutex)(&priv->lock); -if (enabled) err =regmap_write (priv->regmap,ABX8XX_REG_IRQ ,ABX8XX_IRQ_IM_1_4 |ABX8XX_IRQ_AIE );
@@ -551,10 +543,8 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)return put_user (tmp, (unsigned int __user *)arg);case RTC_VL_CLR : - scoped_guard(mutex, &priv->lock) { - err =regmap_update_bits (priv->regmap,ABX8XX_REG_STATUS , -ABX8XX_STATUS_BLF ,0 ); - } + err =regmap_update_bits (priv->regmap,ABX8XX_REG_STATUS , +ABX8XX_STATUS_BLF ,0 );return err;
@@ -623,7 +613,7 @@ static int __abx80x_wdog_set_timeout(struct watchdog_device *wdog,struct abx80x_priv *priv =watchdog_get_drvdata (wdog);u8 val =ABX8XX_WDT_WDS |timeout_bits (timeout); -guard (mutex)(&priv->lock); +guard (rtc_ops)(priv->rtc);/* * Writing any timeout to the WDT register resets the watchdog timer.
@@ -710,7 +700,7 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset, len =min (lower + bytes, (size_t )ABX8XX_SRAM_WIN_SIZE ) - lower; len =min_t (u8, len,I2C_SMBUS_BLOCK_MAX ); -guard (mutex)(&priv->lock); +guard (rtc_ops)(priv->rtc); ret =regmap_update_bits (priv->regmap,ABX8XX_REG_EXTRAM ,ABX8XX_EXTRAM_XADS , upper);
@@ -806,9 +796,6 @@ static int abx80x_probe(struct device *dev, struct regmap *regmap, int irq, priv->rtc->ops = &abx80x_rtc_ops; priv->irq = irq; priv->regmap = regmap; - err =devm_mutex_init (dev, &priv->lock); -if (err) -return err;dev_set_drvdata (dev, priv);
Signature · 1 line
2.56.0
[email protected]
AI reviewRe: [PATCH 19/19] rtc: abx80x: simplify locking
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Alexandre Belloni <[email protected]>
Use the
ops_lockthat is used by the core to lock operations. This ensures we will never get any ABBA deadlock.Signed-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=19
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 6 lines
From: Alexandre Belloni <[email protected]>
Add guard class for rtc_device.ops_lock locks. This allows to simplify error handling in interrupt handlers.
Signed-off-by Alexandre Belloni <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1