aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/platform_device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/platform_device.h')
-rw-r--r--include/linux/platform_device.h75
1 files changed, 68 insertions, 7 deletions
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 71ff887ca44e..d7ecad0093bb 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -21,7 +21,7 @@ struct platform_device {
21 u32 num_resources; 21 u32 num_resources;
22 struct resource * resource; 22 struct resource * resource;
23 23
24 struct platform_device_id *id_entry; 24 const struct platform_device_id *id_entry;
25 25
26 /* arch specific additions */ 26 /* arch specific additions */
27 struct pdev_archdata archdata; 27 struct pdev_archdata archdata;
@@ -43,13 +43,69 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, u
43extern int platform_get_irq_byname(struct platform_device *, const char *); 43extern int platform_get_irq_byname(struct platform_device *, const char *);
44extern int platform_add_devices(struct platform_device **, int); 44extern int platform_add_devices(struct platform_device **, int);
45 45
46extern struct platform_device *platform_device_register_simple(const char *, int id, 46extern struct platform_device *platform_device_register_resndata(
47 struct resource *, unsigned int); 47 struct device *parent, const char *name, int id,
48extern struct platform_device *platform_device_register_data(struct device *, 48 const struct resource *res, unsigned int num,
49 const char *, int, const void *, size_t); 49 const void *data, size_t size);
50
51/**
52 * platform_device_register_simple - add a platform-level device and its resources
53 * @name: base name of the device we're adding
54 * @id: instance id
55 * @res: set of resources that needs to be allocated for the device
56 * @num: number of resources
57 *
58 * This function creates a simple platform device that requires minimal
59 * resource and memory management. Canned release function freeing memory
60 * allocated for the device allows drivers using such devices to be
61 * unloaded without waiting for the last reference to the device to be
62 * dropped.
63 *
64 * This interface is primarily intended for use with legacy drivers which
65 * probe hardware directly. Because such drivers create sysfs device nodes
66 * themselves, rather than letting system infrastructure handle such device
67 * enumeration tasks, they don't fully conform to the Linux driver model.
68 * In particular, when such drivers are built as modules, they can't be
69 * "hotplugged".
70 *
71 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
72 */
73static inline struct platform_device *platform_device_register_simple(
74 const char *name, int id,
75 const struct resource *res, unsigned int num)
76{
77 return platform_device_register_resndata(NULL, name, id,
78 res, num, NULL, 0);
79}
80
81/**
82 * platform_device_register_data - add a platform-level device with platform-specific data
83 * @parent: parent device for the device we're adding
84 * @name: base name of the device we're adding
85 * @id: instance id
86 * @data: platform specific data for this platform device
87 * @size: size of platform specific data
88 *
89 * This function creates a simple platform device that requires minimal
90 * resource and memory management. Canned release function freeing memory
91 * allocated for the device allows drivers using such devices to be
92 * unloaded without waiting for the last reference to the device to be
93 * dropped.
94 *
95 * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
96 */
97static inline struct platform_device *platform_device_register_data(
98 struct device *parent, const char *name, int id,
99 const void *data, size_t size)
100{
101 return platform_device_register_resndata(parent, name, id,
102 NULL, 0, data, size);
103}
50 104
51extern struct platform_device *platform_device_alloc(const char *name, int id); 105extern struct platform_device *platform_device_alloc(const char *name, int id);
52extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 106extern int platform_device_add_resources(struct platform_device *pdev,
107 const struct resource *res,
108 unsigned int num);
53extern int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size); 109extern int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size);
54extern int platform_device_add(struct platform_device *pdev); 110extern int platform_device_add(struct platform_device *pdev);
55extern void platform_device_del(struct platform_device *pdev); 111extern void platform_device_del(struct platform_device *pdev);
@@ -62,7 +118,7 @@ struct platform_driver {
62 int (*suspend)(struct platform_device *, pm_message_t state); 118 int (*suspend)(struct platform_device *, pm_message_t state);
63 int (*resume)(struct platform_device *); 119 int (*resume)(struct platform_device *);
64 struct device_driver driver; 120 struct device_driver driver;
65 struct platform_device_id *id_table; 121 const struct platform_device_id *id_table;
66}; 122};
67 123
68extern int platform_driver_register(struct platform_driver *); 124extern int platform_driver_register(struct platform_driver *);
@@ -77,6 +133,11 @@ extern int platform_driver_probe(struct platform_driver *driver,
77#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) 133#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
78#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) 134#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data))
79 135
136extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
137 int (*probe)(struct platform_device *),
138 struct resource *res, unsigned int n_res,
139 const void *data, size_t size);
140
80/* early platform driver interface */ 141/* early platform driver interface */
81struct early_platform_driver { 142struct early_platform_driver {
82 const char *class_str; 143 const char *class_str;