summaryrefslogtreecommitdiff
path: root/include/linux/platform_device.h
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-07-27 20:14:59 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-16 17:32:07 (GMT)
commit689ae231afbac8979f96100b372a5a73458baaa9 (patch)
tree12b0478fa0fdef746f4d571c6e374aa30ab0c545 /include/linux/platform_device.h
parenta525a3ddeaca69f405d98442ab3c0746e53168dc (diff)
downloadlinux-fsl-qoriq-689ae231afbac8979f96100b372a5a73458baaa9.tar.xz
platform: Add support for automatic device IDs
Right now we have support for explicit platform device IDs, as well as ID-less platform devices when a given device type can only have one instance. However there are cases where multiple instances of a device type can exist, and their IDs aren't (and can't be) known in advance and do not matter. In that case we need automatic device IDs to avoid device name collisions. I am using magic ID value -2 (PLATFORM_DEVID_AUTO) for this, similar to -1 for ID-less devices. The automatically allocated device IDs are global (to avoid an additional per-driver cost.) We keep note that the ID was automatically allocated so that it can be freed later. Note that we also restore the ID to PLATFORM_DEVID_AUTO on error and device deletion, to avoid avoid unexpected behavior on retry. I don't really expect retries on platform device addition, but better safe than sorry. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/platform_device.h')
-rw-r--r--include/linux/platform_device.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 60e9994..5711e95 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -14,11 +14,15 @@
#include <linux/device.h>
#include <linux/mod_devicetable.h>
+#define PLATFORM_DEVID_NONE (-1)
+#define PLATFORM_DEVID_AUTO (-2)
+
struct mfd_cell;
struct platform_device {
const char * name;
int id;
+ bool id_auto;
struct device dev;
u32 num_resources;
struct resource * resource;