Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1229397
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v6 01/22] driver core: handle -EPROBE_DEFER from bus_type.match() |
| Date | 2015-09-21 16:10 +0200 |
| Message-ID | <qb9X5-rF-41@gated-at.bofh.it> (permalink) |
| References | <qb9X3-rF-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Lets implementations of the match() callback in struct bus_type to
return errors and if it's -EPROBE_DEFER then queue the device for
deferred probing.
This is useful to buses such as AMBA in which devices are registered
before their matching information can be retrieved from the HW
(typically because a clock driver hasn't probed yet).
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/base/dd.c | 24 ++++++++++++++++++++++--
include/linux/device.h | 2 +-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index be0eb4639128..7dc04ee81c8b 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -488,6 +488,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
struct device_attach_data *data = _data;
struct device *dev = data->dev;
bool async_allowed;
+ int ret;
/*
* Check if device has already been claimed. This may
@@ -498,8 +499,17 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
if (dev->driver)
return -EBUSY;
- if (!driver_match_device(drv, dev))
+ ret = driver_match_device(drv, dev);
+ if (!ret)
return 0;
+ else if (ret < 0) {
+ if (ret == -EPROBE_DEFER) {
+ dev_dbg(dev, "Device match requests probe deferral\n");
+ driver_deferred_probe_add(dev);
+ } else
+ dev_warn(dev, "Bus failed to match device: %d", ret);
+ return ret;
+ }
async_allowed = driver_allows_async_probing(drv);
@@ -619,6 +629,7 @@ void device_initial_probe(struct device *dev)
static int __driver_attach(struct device *dev, void *data)
{
struct device_driver *drv = data;
+ int ret;
/*
* Lock device and try to bind to it. We drop the error
@@ -630,8 +641,17 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/
- if (!driver_match_device(drv, dev))
+ ret = driver_match_device(drv, dev);
+ if (!ret)
+ return 0;
+ else if (ret < 0) {
+ if (ret == -EPROBE_DEFER) {
+ dev_dbg(dev, "Device match requests probe deferral\n");
+ driver_deferred_probe_add(dev);
+ } else
+ dev_warn(dev, "Bus failed to match device: %d", ret);
return 0;
+ }
if (dev->parent) /* Needed for USB */
device_lock(dev->parent);
diff --git a/include/linux/device.h b/include/linux/device.h
index 5d7bc6349930..8e7b806f0744 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -70,7 +70,7 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
* @dev_groups: Default attributes of the devices on the bus.
* @drv_groups: Default attributes of the device drivers on the bus.
* @match: Called, perhaps multiple times, whenever a new device or driver
- * is added for this bus. It should return a nonzero value if the
+ * is added for this bus. It should return a positive value if the
* given device can be handled by the given driver.
* @uevent: Called when a device is added, removed, or a few other things
* that generate uevents to add the environment variables.
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v6 0/22] On-demand device probing Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 14/22] usb: phy: Probe phy devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 09/22] drm: Probe panels on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 12/22] pwm: Probe PWM chip devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 01/22] driver core: handle -EPROBE_DEFER from bus_type.match() Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 15/22] clk: Probe clk providers on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 19/22] power-supply: Probe power supplies on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 20/22] driver core: Allow deferring probes until late init Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 16/22] pinctrl: Probe pinctrl devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 17/22] phy: core: Probe phy providers on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 21/22] driver core: Start processing deferred probes earlier Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:10 +0200
[PATCH v6 07/22] regulator: core: Remove regulator_list Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
Re: [PATCH v6 07/22] regulator: core: Remove regulator_list Mark Brown <broonie@kernel.org> - 2015-09-21 21:40 +0200
Re: [PATCH v6 07/22] regulator: core: Remove regulator_list Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-22 09:30 +0200
[PATCH v6 02/22] ARM: amba: Move reading of periphid to amba_match() Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
[PATCH v6 04/22] of: add function to allow probing a device from a OF node Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
[PATCH v6 05/22] gpio: Probe GPIO drivers on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
[PATCH v6 11/22] i2c: core: Probe i2c adapters and devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
[PATCH v6 06/22] gpio: Probe pinctrl devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-21 16:20 +0200
csiph-web