diff options
Diffstat (limited to 'include/linux/platform_device.h')
| -rw-r--r-- | include/linux/platform_device.h | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 27bb05aae70d..2a23f7d1a825 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
| @@ -49,10 +49,54 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, u | |||
| 49 | extern int platform_get_irq_byname(struct platform_device *, const char *); | 49 | extern int platform_get_irq_byname(struct platform_device *, const char *); |
| 50 | extern int platform_add_devices(struct platform_device **, int); | 50 | extern int platform_add_devices(struct platform_device **, int); |
| 51 | 51 | ||
| 52 | extern struct platform_device *platform_device_register_resndata( | 52 | struct platform_device_info { |
| 53 | struct device *parent; | ||
| 54 | |||
| 55 | const char *name; | ||
| 56 | int id; | ||
| 57 | |||
| 58 | const struct resource *res; | ||
| 59 | unsigned int num_res; | ||
| 60 | |||
| 61 | const void *data; | ||
| 62 | size_t size_data; | ||
| 63 | u64 dma_mask; | ||
| 64 | }; | ||
| 65 | extern struct platform_device *platform_device_register_full( | ||
| 66 | struct platform_device_info *pdevinfo); | ||
| 67 | |||
| 68 | /** | ||
| 69 | * platform_device_register_resndata - add a platform-level device with | ||
| 70 | * resources and platform-specific data | ||
| 71 | * | ||
| 72 | * @parent: parent device for the device we're adding | ||
| 73 | * @name: base name of the device we're adding | ||
| 74 | * @id: instance id | ||
| 75 | * @res: set of resources that needs to be allocated for the device | ||
| 76 | * @num: number of resources | ||
| 77 | * @data: platform specific data for this platform device | ||
| 78 | * @size: size of platform specific data | ||
| 79 | * | ||
| 80 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
| 81 | */ | ||
| 82 | static inline struct platform_device *platform_device_register_resndata( | ||
| 53 | struct device *parent, const char *name, int id, | 83 | struct device *parent, const char *name, int id, |
| 54 | const struct resource *res, unsigned int num, | 84 | const struct resource *res, unsigned int num, |
| 55 | const void *data, size_t size); | 85 | const void *data, size_t size) { |
| 86 | |||
| 87 | struct platform_device_info pdevinfo = { | ||
| 88 | .parent = parent, | ||
| 89 | .name = name, | ||
| 90 | .id = id, | ||
| 91 | .res = res, | ||
| 92 | .num_res = num, | ||
| 93 | .data = data, | ||
| 94 | .size_data = size, | ||
| 95 | .dma_mask = 0, | ||
| 96 | }; | ||
| 97 | |||
| 98 | return platform_device_register_full(&pdevinfo); | ||
| 99 | } | ||
| 56 | 100 | ||
| 57 | /** | 101 | /** |
| 58 | * platform_device_register_simple - add a platform-level device and its resources | 102 | * platform_device_register_simple - add a platform-level device and its resources |
| @@ -146,6 +190,23 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data | |||
| 146 | dev_set_drvdata(&pdev->dev, data); | 190 | dev_set_drvdata(&pdev->dev, data); |
| 147 | } | 191 | } |
| 148 | 192 | ||
| 193 | /* module_platform_driver() - Helper macro for drivers that don't do | ||
| 194 | * anything special in module init/exit. This eliminates a lot of | ||
| 195 | * boilerplate. Each module may only use this macro once, and | ||
| 196 | * calling it replaces module_init() and module_exit() | ||
| 197 | */ | ||
| 198 | #define module_platform_driver(__platform_driver) \ | ||
| 199 | static int __init __platform_driver##_init(void) \ | ||
| 200 | { \ | ||
| 201 | return platform_driver_register(&(__platform_driver)); \ | ||
| 202 | } \ | ||
| 203 | module_init(__platform_driver##_init); \ | ||
| 204 | static void __exit __platform_driver##_exit(void) \ | ||
| 205 | { \ | ||
| 206 | platform_driver_unregister(&(__platform_driver)); \ | ||
| 207 | } \ | ||
| 208 | module_exit(__platform_driver##_exit); | ||
| 209 | |||
| 149 | extern struct platform_device *platform_create_bundle(struct platform_driver *driver, | 210 | extern struct platform_device *platform_create_bundle(struct platform_driver *driver, |
| 150 | int (*probe)(struct platform_device *), | 211 | int (*probe)(struct platform_device *), |
| 151 | struct resource *res, unsigned int n_res, | 212 | struct resource *res, unsigned int n_res, |
