Skip to content

Commit fbc35b4

Browse files
glikelygregkh
authored andcommitted
Add documentation on meaning of -EPROBE_DEFER
Add a bit of documentation on what it means when a driver .probe() hook returns the -EPROBE_DEFER error code, including the limitation that -EPROBE_DEFER should be returned as early as possible, before the driver starts to register child devices. Also: minor markup fixes in the same file Cc: Greg Kroah-Hartman <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Saravana Kannan <[email protected]> Cc: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Grant Likely <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 45bb08d commit fbc35b4

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

Documentation/driver-api/driver-model/driver.rst

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Device Drivers
44

55
See the kerneldoc for the struct device_driver.
66

7-
87
Allocation
98
~~~~~~~~~~
109

@@ -167,9 +166,26 @@ the driver to that device.
167166

168167
A driver's probe() may return a negative errno value to indicate that
169168
the driver did not bind to this device, in which case it should have
170-
released all resources it allocated::
169+
released all resources it allocated.
170+
171+
Optionally, probe() may return -EPROBE_DEFER if the driver depends on
172+
resources that are not yet available (e.g., supplied by a driver that
173+
hasn't initialized yet). The driver core will put the device onto the
174+
deferred probe list and will try to call it again later. If a driver
175+
must defer, it should return -EPROBE_DEFER as early as possible to
176+
reduce the amount of time spent on setup work that will need to be
177+
unwound and reexecuted at a later time.
178+
179+
.. warning::
180+
-EPROBE_DEFER must not be returned if probe() has already created
181+
child devices, even if those child devices are removed again
182+
in a cleanup path. If -EPROBE_DEFER is returned after a child
183+
device has been registered, it may result in an infinite loop of
184+
.probe() calls to the same driver.
185+
186+
::
171187

172-
void (*sync_state)(struct device *dev);
188+
void (*sync_state) (struct device *dev);
173189

174190
sync_state is called only once for a device. It's called when all the consumer
175191
devices of the device have successfully probed. The list of consumers of the
@@ -212,6 +228,8 @@ over management of devices from the bootloader, the usage of sync_state() is
212228
not restricted to that. Use it whenever it makes sense to take an action after
213229
all the consumers of a device have probed::
214230

231+
::
232+
215233
int (*remove) (struct device *dev);
216234

217235
remove is called to unbind a driver from a device. This may be
@@ -224,11 +242,15 @@ not. It should free any resources allocated specifically for the
224242
device; i.e. anything in the device's driver_data field.
225243

226244
If the device is still present, it should quiesce the device and place
227-
it into a supported low-power state::
245+
it into a supported low-power state.
246+
247+
::
228248

229249
int (*suspend) (struct device *dev, pm_message_t state);
230250

231-
suspend is called to put the device in a low power state::
251+
suspend is called to put the device in a low power state.
252+
253+
::
232254

233255
int (*resume) (struct device *dev);
234256

0 commit comments

Comments
 (0)