From 54763e2c170bfb8dcd09f168f7c2cd866d380399 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sat, 6 Oct 2012 23:01:26 +0200 Subject: driver: print error message when probe fails Signed-off-by: Sascha Hauer --- drivers/base/driver.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/base/driver.c') diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 6c8fd0576c..7bb3ab446e 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -77,6 +77,8 @@ int get_free_deviceid(const char *name_template) static int match(struct driver_d *drv, struct device_d *dev) { + int ret; + if (dev->driver) return -1; @@ -84,8 +86,11 @@ static int match(struct driver_d *drv, struct device_d *dev) if (dev->bus->match(dev, drv)) goto err_out; - if (dev->bus->probe(dev)) + ret = dev->bus->probe(dev); + if (ret) { + dev_err(dev, "probe failed: %s\n", strerror(-ret)); goto err_out; + } list_add(&dev->active, &active); -- cgit v1.2.3 From 85799053140da9c798166ee0c3b66c589845cef0 Mon Sep 17 00:00:00 2001 From: Franck Jullien Date: Tue, 16 Oct 2012 21:58:11 +0200 Subject: cosmetic: remove right alignment on driver list In order to avoid misalignment, just remove the right alignment while printing the drivers list. Signed-off-by: Franck Jullien Signed-off-by: Sascha Hauer --- drivers/base/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/base/driver.c') diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 7bb3ab446e..3ce7953dc6 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -408,7 +408,7 @@ static int do_devinfo(int argc, char *argv[]) printf("\ndrivers:\n"); for_each_driver(drv) - printf("%10s\n",drv->name); + printf("%s\n",drv->name); } else { dev = get_device_by_name(argv[1]); -- cgit v1.2.3 From d54f5b1b48046a418781352d53567130edd5bcde Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 17 Oct 2012 15:05:14 +0200 Subject: driver: add support for requesting resource by name this will allow to avoid issue with resource order Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- drivers/base/driver.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ include/driver.h | 15 +++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'drivers/base/driver.c') diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 3ce7953dc6..3f5f6a2a15 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -252,6 +252,52 @@ void *dev_get_mem_region(struct device_d *dev, int num) } EXPORT_SYMBOL(dev_get_mem_region); +struct resource *dev_get_resource_by_name(struct device_d *dev, + const char *name) +{ + int i; + + for (i = 0; i < dev->num_resources; i++) { + struct resource *res = &dev->resource[i]; + if (resource_type(res) != IORESOURCE_MEM) + continue; + if (!res->name) + continue; + if (!strcmp(name, res->name)) + return res; + } + + return NULL; +} + +void *dev_get_mem_region_by_name(struct device_d *dev, const char *name) +{ + struct resource *res; + + res = dev_get_resource_by_name(dev, name); + if (!res) + return NULL; + + return (void __force *)res->start; +} +EXPORT_SYMBOL(dev_get_mem_region_by_name); + +void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *name) +{ + struct resource *res; + + res = dev_get_resource_by_name(dev, name); + if (!res) + return NULL; + + res = request_iomem_region(dev_name(dev), res->start, res->end); + if (!res) + return NULL; + + return (void __force __iomem *)res->start; +} +EXPORT_SYMBOL(dev_request_mem_region_by_name); + void __iomem *dev_request_mem_region(struct device_d *dev, int num) { struct resource *res; diff --git a/include/driver.h b/include/driver.h index 4918054887..f8d815c619 100644 --- a/include/driver.h +++ b/include/driver.h @@ -192,6 +192,21 @@ static inline const char *dev_name(const struct device_d *dev) return dev_id(dev); } +/* + * get resource base 'name' for a device + */ +struct resource *dev_get_resource_by_name(struct device_d *dev, + const char *name); +/* + * get register base 'name' for a device + */ +void *dev_get_mem_region_by_name(struct device_d *dev, const char *name); + +/* + * exlusively request register base 'name' for a device + */ +void __iomem *dev_request_mem_region_by_name(struct device_d *dev, + const char *name); /* * get register base 'num' for a device */ -- cgit v1.2.3