Linux-RTC Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] rtc: max31335: remove unecessary locking
@ 2024-01-15 23:22 alexandre.belloni
  2024-01-15 23:22 ` [PATCH 2/2] rtc: max31335: use regmap_update_bits_check alexandre.belloni
  2024-01-16 10:47 ` [PATCH 1/2] rtc: max31335: remove unecessary locking Miclaus, Antoniu
  0 siblings, 2 replies; 4+ messages in thread
From: alexandre.belloni @ 2024-01-15 23:22 UTC (permalink / raw
  To: Antoniu Miclaus, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

There is no race condition when accessing MAX31335_STATUS1 because it is
always about clearing the alarm interrupt bit.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-max31335.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
index 3ddfe71bbb56..2ce23f60a7f3 100644
--- a/drivers/rtc/rtc-max31335.c
+++ b/drivers/rtc/rtc-max31335.c
@@ -348,27 +348,19 @@ static int max31335_alarm_irq_enable(struct device *dev, unsigned int enabled)
 static irqreturn_t max31335_handle_irq(int irq, void *dev_id)
 {
 	struct max31335_data *max31335 = dev_id;
-	struct mutex *lock = &max31335->rtc->ops_lock;
 	int ret, status;
 
-	mutex_lock(lock);
-
 	ret = regmap_read(max31335->regmap, MAX31335_STATUS1, &status);
 	if (ret)
-		goto exit;
+		return IRQ_HANDLED;
 
 	if (FIELD_GET(MAX31335_STATUS1_A1F, status)) {
-		ret = regmap_update_bits(max31335->regmap, MAX31335_STATUS1,
-					 MAX31335_STATUS1_A1F, 0);
-		if (ret)
-			goto exit;
+		regmap_update_bits(max31335->regmap, MAX31335_STATUS1,
+				   MAX31335_STATUS1_A1F, 0);
 
 		rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF);
 	}
 
-exit:
-	mutex_unlock(lock);
-
 	return IRQ_HANDLED;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rtc: max31335: use regmap_update_bits_check
  2024-01-15 23:22 [PATCH 1/2] rtc: max31335: remove unecessary locking alexandre.belloni
@ 2024-01-15 23:22 ` alexandre.belloni
  2024-01-16 10:48   ` Miclaus, Antoniu
  2024-01-16 10:47 ` [PATCH 1/2] rtc: max31335: remove unecessary locking Miclaus, Antoniu
  1 sibling, 1 reply; 4+ messages in thread
From: alexandre.belloni @ 2024-01-15 23:22 UTC (permalink / raw
  To: Antoniu Miclaus, Alexandre Belloni; +Cc: linux-rtc, linux-kernel

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

Simplify the IRQ handler by using regmap_update_bits_check.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-max31335.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
index 2ce23f60a7f3..a38d303d9df4 100644
--- a/drivers/rtc/rtc-max31335.c
+++ b/drivers/rtc/rtc-max31335.c
@@ -348,18 +348,16 @@ static int max31335_alarm_irq_enable(struct device *dev, unsigned int enabled)
 static irqreturn_t max31335_handle_irq(int irq, void *dev_id)
 {
 	struct max31335_data *max31335 = dev_id;
-	int ret, status;
+	bool status;
+	int ret;
 
-	ret = regmap_read(max31335->regmap, MAX31335_STATUS1, &status);
+	ret = regmap_update_bits_check(max31335->regmap, MAX31335_STATUS1,
+				       MAX31335_STATUS1_A1F, 0, &status);
 	if (ret)
 		return IRQ_HANDLED;
 
-	if (FIELD_GET(MAX31335_STATUS1_A1F, status)) {
-		regmap_update_bits(max31335->regmap, MAX31335_STATUS1,
-				   MAX31335_STATUS1_A1F, 0);
-
+	if (status)
 		rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF);
-	}
 
 	return IRQ_HANDLED;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH 1/2] rtc: max31335: remove unecessary locking
  2024-01-15 23:22 [PATCH 1/2] rtc: max31335: remove unecessary locking alexandre.belloni
  2024-01-15 23:22 ` [PATCH 2/2] rtc: max31335: use regmap_update_bits_check alexandre.belloni
@ 2024-01-16 10:47 ` Miclaus, Antoniu
  1 sibling, 0 replies; 4+ messages in thread
From: Miclaus, Antoniu @ 2024-01-16 10:47 UTC (permalink / raw
  To: alexandre.belloni@bootlin.com
  Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org

> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> There is no race condition when accessing MAX31335_STATUS1 because it is
> always about clearing the alarm interrupt bit.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  drivers/rtc/rtc-max31335.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
> index 3ddfe71bbb56..2ce23f60a7f3 100644
> --- a/drivers/rtc/rtc-max31335.c
> +++ b/drivers/rtc/rtc-max31335.c
> @@ -348,27 +348,19 @@ static int max31335_alarm_irq_enable(struct device
> *dev, unsigned int enabled)
>  static irqreturn_t max31335_handle_irq(int irq, void *dev_id)
>  {
>  	struct max31335_data *max31335 = dev_id;
> -	struct mutex *lock = &max31335->rtc->ops_lock;
>  	int ret, status;
> 
> -	mutex_lock(lock);
> -
>  	ret = regmap_read(max31335->regmap, MAX31335_STATUS1,
> &status);
>  	if (ret)
> -		goto exit;
> +		return IRQ_HANDLED;
> 
>  	if (FIELD_GET(MAX31335_STATUS1_A1F, status)) {
> -		ret = regmap_update_bits(max31335->regmap,
> MAX31335_STATUS1,
> -					 MAX31335_STATUS1_A1F, 0);
> -		if (ret)
> -			goto exit;
> +		regmap_update_bits(max31335->regmap,
> MAX31335_STATUS1,
> +				   MAX31335_STATUS1_A1F, 0);
> 
>  		rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF);
>  	}
> 
> -exit:
> -	mutex_unlock(lock);
> -
>  	return IRQ_HANDLED;
>  }
> 
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH 2/2] rtc: max31335: use regmap_update_bits_check
  2024-01-15 23:22 ` [PATCH 2/2] rtc: max31335: use regmap_update_bits_check alexandre.belloni
@ 2024-01-16 10:48   ` Miclaus, Antoniu
  0 siblings, 0 replies; 4+ messages in thread
From: Miclaus, Antoniu @ 2024-01-16 10:48 UTC (permalink / raw
  To: alexandre.belloni@bootlin.com
  Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org

> From: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> Simplify the IRQ handler by using regmap_update_bits_check.
> 
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  drivers/rtc/rtc-max31335.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-max31335.c b/drivers/rtc/rtc-max31335.c
> index 2ce23f60a7f3..a38d303d9df4 100644
> --- a/drivers/rtc/rtc-max31335.c
> +++ b/drivers/rtc/rtc-max31335.c
> @@ -348,18 +348,16 @@ static int max31335_alarm_irq_enable(struct device
> *dev, unsigned int enabled)
>  static irqreturn_t max31335_handle_irq(int irq, void *dev_id)
>  {
>  	struct max31335_data *max31335 = dev_id;
> -	int ret, status;
> +	bool status;
> +	int ret;
> 
> -	ret = regmap_read(max31335->regmap, MAX31335_STATUS1,
> &status);
> +	ret = regmap_update_bits_check(max31335->regmap,
> MAX31335_STATUS1,
> +				       MAX31335_STATUS1_A1F, 0, &status);
>  	if (ret)
>  		return IRQ_HANDLED;
> 
> -	if (FIELD_GET(MAX31335_STATUS1_A1F, status)) {
> -		regmap_update_bits(max31335->regmap,
> MAX31335_STATUS1,
> -				   MAX31335_STATUS1_A1F, 0);
> -
> +	if (status)
>  		rtc_update_irq(max31335->rtc, 1, RTC_AF | RTC_IRQF);
> -	}
> 
>  	return IRQ_HANDLED;
>  }
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-16 10:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 23:22 [PATCH 1/2] rtc: max31335: remove unecessary locking alexandre.belloni
2024-01-15 23:22 ` [PATCH 2/2] rtc: max31335: use regmap_update_bits_check alexandre.belloni
2024-01-16 10:48   ` Miclaus, Antoniu
2024-01-16 10:47 ` [PATCH 1/2] rtc: max31335: remove unecessary locking Miclaus, Antoniu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).