Skip to contentSkip to conversation

media: rc: remove unneeded mutex in rc_register_device

PATCH Superseded Heiner Kallweit 2 participants 3 messages Mar 16, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: rc: remove unneeded mutex in rc_register_device

Access to dev->initialized is atomic, therefore we don't have to protect it with a mutex.

---
 drivers/media/rc/rc-main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/rc/rc-main.c +0 -2
index 4e9bbe7..68541b1 100644
@@ -1492,9 +1492,7 @@ int rc_register_device(struct rc_dev *dev)
 	}
 
 	/* Allow the RC sysfs nodes to be accessible */
-	mutex_lock(&dev->lock);
 	atomic_set(&dev->initialized, 1);
-	mutex_unlock(&dev->lock);
 
 	IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
 		   dev->minor,
Signature · 1 line
2.7.3
#1 lore raw
Quoted 2 lines · Heiner Kallweit

Access to dev->initialized is atomic, therefore we don't have to protect it with a mutex.

Mutexes are used to split the code to mutually exclusive execution blocks, so not arguing about the apparently correct change itself I want to emphasize that the given explanation of the change in the commit message is wrong. Atomic access does not cancel a specific care about execution ordering.

Indirectly it applies to ("rc-core: allow calling rc_open with device not initialized"), where "initialized" bool property was changed to atomic_t type --- this (sub-)change is just useless.

Please grasp the topic and reword the commit message.

Quoted 11 lines
---
 drivers/media/rc/rc-main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/rc/rc-main.c +0 -0
index 4e9bbe7..68541b1 100644

drivers/media/rc/rc-main.c int rc_register_device(struct rc_dev *dev) · line 1498

Quoted 9 lines
drivers/media/rc/rc-main.c +0 -2
@@ -1492,9 +1492,7 @@ int rc_register_device(struct rc_dev *dev)
 	}
 
 	/* Allow the RC sysfs nodes to be accessible */
-	mutex_lock(&dev->lock);
 	atomic_set(&dev->initialized, 1);
-	mutex_unlock(&dev->lock);
 
 	IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
 		   dev->minor,

--
With best wishes,
Vladimir

#2 lore raw

Am 16.03.2016 um 20:33 schrieb Vladimir Zapolskiy:

Quoted 10 lines · Heiner Kallweit
Quoted 2 lines

Access to dev->initialized is atomic, therefore we don't have to protect it with a mutex.

Mutexes are used to split the code to mutually exclusive execution blocks, so not arguing about the apparently correct change itself I want to emphasize that the given explanation of the change in the commit message is wrong. Atomic access does not cancel a specific care about execution ordering.

Quoted 6 lines

Indirectly it applies to ("rc-core: allow calling rc_open with device not initialized"), where "initialized" bool property was changed to atomic_t type --- this (sub-)change is just useless.

Please grasp the topic and reword the commit message.

Thanks for the hint, you're right.
Will change the commit message and send a v2.

Regards, Heiner

Quoted 25 lines
Quoted 11 lines
---
 drivers/media/rc/rc-main.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/rc/rc-main.c +0 -0
index 4e9bbe7..68541b1 100644

drivers/media/rc/rc-main.c int rc_register_device(struct rc_dev *dev) · line 1498

Quoted 9 lines
drivers/media/rc/rc-main.c +0 -2
@@ -1492,9 +1492,7 @@ int rc_register_device(struct rc_dev *dev)
 	}
 
 	/* Allow the RC sysfs nodes to be accessible */
-	mutex_lock(&dev->lock);
 	atomic_set(&dev->initialized, 1);
-	mutex_unlock(&dev->lock);
 
 	IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
 		   dev->minor,

--
With best wishes,
Vladimir