Skip to contentSkip to conversation

rtc: hid-sensor-time: Add missing spin_lock_init

PATCH Applied Axel Lin 4 participants 5 messages Jan 17, 2013 – Jan 20, 2013 Real time clock (RTC)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 rtc: hid-sensor-time: Add missing spin_lock_init

---
 drivers/rtc/rtc-hid-sensor-time.c |    1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-hid-sensor-time.c +1 -0
index 0438c9e..31c5728 100644
@@ -225,6 +225,7 @@ static int hid_time_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, time_state);
 
+	spin_lock_init(&time_state->lock_last_time);
 	init_completion(&time_state->comp_last_time);
 	time_state->common_attributes.hsdev = hsdev;
 	time_state->common_attributes.pdev = pdev;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Axel Lin
---
 drivers/rtc/rtc-hid-sensor-time.c |    1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-hid-sensor-time.c +0 -0
index 0438c9e..31c5728 100644

drivers/rtc/rtc-hid-sensor-time.c static int hid_time_probe(struct platform_device *pdev) · line 228

Quoted 4 lines
drivers/rtc/rtc-hid-sensor-time.c +1 -0
@@ -225,6 +225,7 @@ static int hid_time_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, time_state);
 
+       spin_lock_init(&time_state->lock_last_time);

Can you explain in the commit message why it is missing?

For people not familiar with this code that isn't obvious.

#2 lore raw

Am 17.01.2013 02:58, schrieb Thiago Farina:

Quoted 12 lines · Axel Lin
Quoted 11 lines
---
  drivers/rtc/rtc-hid-sensor-time.c |    1 +
  1 file changed, 1 insertion(+)
drivers/rtc/rtc-hid-sensor-time.c +0 -0
index 0438c9e..31c5728 100644
@@ -225,6 +225,7 @@ static int hid_time_probe(struct platform_device *pdev)
 
Quoted 7 lines

drivers/rtc/rtc-hid-sensor-time.c static int hid_time_probe(struct platform_device *pdev) · line 228

Quoted 3 lines
drivers/rtc/rtc-hid-sensor-time.c +1 -0
         platform_set_drvdata(pdev, time_state);
 
+       spin_lock_init(&time_state->lock_last_time);

Can you explain in the commit message why it is missing?

For people not familiar with this code that isn't obvious.

Every spinlock must be initialized once (to SPIN_LOCK_UNLOCKED or by using spin_lock_init()). On most architectures SPIN_LOCK_UNLOCKED is just zero, therefor the kzalloc of the time_state does it (which likely is the case why I haven't spotted any error without the initialization), but that doesn't isn't true for all architectures.

Regards,

Alexander

Acked-by on v1 1/1
#3 lore raw
In reply to Axel Lin

Am 17.01.2013 02:49, schrieb Axel Lin:

Thanks, yes, I missed it the initialization of the spinlock.

Below is my ack.

Regards,

Alexander

Quoted 1 line
Quoted 17 lines
---
  drivers/rtc/rtc-hid-sensor-time.c |    1 +
  1 file changed, 1 insertion(+)
drivers/rtc/rtc-hid-sensor-time.c +1 -0
index 0438c9e..31c5728 100644
@@ -225,6 +225,7 @@ static int hid_time_probe(struct platform_device *pdev)
 
  	platform_set_drvdata(pdev, time_state);
 
+	spin_lock_init(&time_state->lock_last_time);
  	init_completion(&time_state->comp_last_time);
  	time_state->common_attributes.hsdev = hsdev;
  	time_state->common_attributes.pdev = pdev;
#4 lore raw
Quoted 6 lines · Alexander Holler

Am 17.01.2013 02:49, schrieb Axel Lin:

Thanks, yes, I missed it the initialization of the spinlock.

Below is my ack.

Quoted 7 lines

Regards,

Alexander

Quoted 1 line

Applied to togreg branch of iio.git.

Thanks,

Quoted 19 lines
Quoted 18 lines
---
  drivers/rtc/rtc-hid-sensor-time.c |    1 +
  1 file changed, 1 insertion(+)
drivers/rtc/rtc-hid-sensor-time.c +1 -0
index 0438c9e..31c5728 100644
@@ -225,6 +225,7 @@ static int hid_time_probe(struct platform_device *pdev)
 
      platform_set_drvdata(pdev, time_state);
 
+    spin_lock_init(&time_state->lock_last_time);
      init_completion(&time_state->comp_last_time);
      time_state->common_attributes.hsdev = hsdev;
      time_state->common_attributes.pdev = pdev;