Re: [driver-core PATCH v4 3/6] device core: Consolidate locking and unlocking of parent and device

From
Bart Van Assche <bvanassche@acm.org>
Date
2018-10-18 17:53:40
Also in
lkml
Reply to
Alexander Duyck, 2018-10-15
On Mon, 2018-10-15 at 08:09 -0700, Alexander Duyck wrote:
This patch is meant to try and consolidate all of the locking and unlocking
of both the parent and device when attaching or removing a driver from a
given device.

To do that I first consolidated the lock pattern into two functions
__device_driver_lock and __device_driver_unlock. After doing that I then
created functions specific to attaching and detaching the driver while
acquiring this locks. By doing this I was able to reduce the number of
            ^^^^
Should "this" perhaps be changed into "these"?
 
quoted hunk ↗ jump to hunk
+/*
+ * __device_driver_lock - acquire locks needed to manipulate dev->drv
+ * @dev: Device we will update driver info for
+ * @parent: Parent device needed if the bus requires parent lock
Please consider splitting that description into two sentences to enhance
clarity, e.g. "Parent device. Needed if the bus requires parent lock."
+ * @parent: Parent device needed if the bus requires parent lock
Same comment here.
quoted hunk ↗ jump to hunk
 /**
+ * device_driver_detach - detach driver from a specific device
+ * @dev: device to detach driver from
+ *
+ * Manually detach driver from device. Will acquire both @dev lock and
+ * @dev->parent lock if needed.
+ */
+void device_driver_detach(struct device *dev)
+{
+	device_release_driver_internal(dev, NULL, dev->parent);
+}
+
+/**
  * driver_detach - detach driver from all devices it controls.
  * @drv: driver.
  */
Elsewhere in the driver core the word "manually" only appears in comments
above exported functions and functions that implement sysfs store methods.
Since device_driver_detach() is neither, I think the word "manually" should
not be used in the comment block above that function. But since the rest of
this patch looks fine to me, feel free to add:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Thread (15 messages) 15 messages, 4 authors, last reply 2018-10-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help