diff mbox

[RFC,24/24] xen/arm: Check if the device is available before using it

Message ID 1376687156-6737-25-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall Aug. 16, 2013, 9:05 p.m. UTC
It's possible to have a device description in the DTS but the device is not
wired.

device_init must check if the device is available before doing anything with
it.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/device.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Ian Campbell Aug. 22, 2013, 2:01 p.m. UTC | #1
On Fri, 2013-08-16 at 22:05 +0100, Julien Grall wrote:
> It's possible to have a device description in the DTS but the device is not
> wired.
> 
> device_init must check if the device is available before doing anything with
> it.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff mbox

Patch

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index dc751a9..f86b2e3 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -47,6 +47,9 @@  int __init device_init(struct dt_device_node *dev, enum device_type type,
 
     ASSERT(dev != NULL);
 
+    if ( !dt_device_is_available(dev) )
+        return  -ENODEV;
+
     for ( desc = _sdevice; desc != _edevice; desc++ )
     {
         if ( desc->type != type )