summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/core/device-remove.c3
-rw-r--r--drivers/core/device.c2
-rw-r--r--include/dm/device.h3
3 files changed, 8 insertions, 0 deletions
diff --git a/drivers/core/device-remove.c b/drivers/core/device-remove.c
index 6b87f86..45d6543 100644
--- a/drivers/core/device-remove.c
+++ b/drivers/core/device-remove.c
@@ -61,6 +61,9 @@ int device_unbind(struct udevice *dev)
if (dev->flags & DM_FLAG_ACTIVATED)
return -EINVAL;
+ if (!(dev->flags & DM_FLAG_BOUND))
+ return -EINVAL;
+
drv = dev->driver;
assert(drv);
diff --git a/drivers/core/device.c b/drivers/core/device.c
index d65717d..bf6f271 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -132,6 +132,8 @@ int device_bind(struct udevice *parent, const struct driver *drv,
dm_dbg("Bound device %s to %s\n", dev->name, parent->name);
*devp = dev;
+ dev->flags |= DM_FLAG_BOUND;
+
return 0;
fail_child_post_bind:
diff --git a/include/dm/device.h b/include/dm/device.h
index 12fd02d..4cd7ba3 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -36,6 +36,9 @@ struct driver_info;
/* Allocate driver private data on a DMA boundary */
#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5)
+/* Device is bound */
+#define DM_FLAG_BOUND (1 << 6)
+
/**
* struct udevice - An instance of a driver
*