diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:13:54 -0400 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-08-06 13:13:54 -0400 |
| commit | 11e4afb49b7fa1fc8e1ffd850c1806dd86a08204 (patch) | |
| tree | 9e57efcb106ae912f7bec718feb3f8ec607559bb /drivers/base/platform.c | |
| parent | 162500b3a3ff39d941d29db49b41a16667ae44f0 (diff) | |
| parent | 9b2a606d3898fcb2eedb6faded3bb37549590ac4 (diff) | |
Merge branches 'gemini' and 'misc' into devel
Diffstat (limited to 'drivers/base/platform.c')
| -rw-r--r-- | drivers/base/platform.c | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1ba9d617d241..4d99c8bdfedc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
| @@ -187,7 +187,7 @@ EXPORT_SYMBOL_GPL(platform_device_alloc); | |||
| 187 | * released. | 187 | * released. |
| 188 | */ | 188 | */ |
| 189 | int platform_device_add_resources(struct platform_device *pdev, | 189 | int platform_device_add_resources(struct platform_device *pdev, |
| 190 | struct resource *res, unsigned int num) | 190 | const struct resource *res, unsigned int num) |
| 191 | { | 191 | { |
| 192 | struct resource *r; | 192 | struct resource *r; |
| 193 | 193 | ||
| @@ -362,10 +362,12 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); | |||
| 362 | * enumeration tasks, they don't fully conform to the Linux driver model. | 362 | * enumeration tasks, they don't fully conform to the Linux driver model. |
| 363 | * In particular, when such drivers are built as modules, they can't be | 363 | * In particular, when such drivers are built as modules, they can't be |
| 364 | * "hotplugged". | 364 | * "hotplugged". |
| 365 | * | ||
| 366 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
| 365 | */ | 367 | */ |
| 366 | struct platform_device *platform_device_register_simple(const char *name, | 368 | struct platform_device *platform_device_register_simple(const char *name, |
| 367 | int id, | 369 | int id, |
| 368 | struct resource *res, | 370 | const struct resource *res, |
| 369 | unsigned int num) | 371 | unsigned int num) |
| 370 | { | 372 | { |
| 371 | struct platform_device *pdev; | 373 | struct platform_device *pdev; |
| @@ -408,6 +410,8 @@ EXPORT_SYMBOL_GPL(platform_device_register_simple); | |||
| 408 | * allocated for the device allows drivers using such devices to be | 410 | * allocated for the device allows drivers using such devices to be |
| 409 | * unloaded without waiting for the last reference to the device to be | 411 | * unloaded without waiting for the last reference to the device to be |
| 410 | * dropped. | 412 | * dropped. |
| 413 | * | ||
| 414 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
| 411 | */ | 415 | */ |
| 412 | struct platform_device *platform_device_register_data( | 416 | struct platform_device *platform_device_register_data( |
| 413 | struct device *parent, | 417 | struct device *parent, |
| @@ -559,6 +563,8 @@ EXPORT_SYMBOL_GPL(platform_driver_probe); | |||
| 559 | * | 563 | * |
| 560 | * Use this in legacy-style modules that probe hardware directly and | 564 | * Use this in legacy-style modules that probe hardware directly and |
| 561 | * register a single platform device and corresponding platform driver. | 565 | * register a single platform device and corresponding platform driver. |
| 566 | * | ||
| 567 | * Returns &struct platform_device pointer on success, or ERR_PTR() on error. | ||
| 562 | */ | 568 | */ |
| 563 | struct platform_device * __init_or_module platform_create_bundle( | 569 | struct platform_device * __init_or_module platform_create_bundle( |
| 564 | struct platform_driver *driver, | 570 | struct platform_driver *driver, |
| @@ -729,7 +735,7 @@ static void platform_pm_complete(struct device *dev) | |||
| 729 | 735 | ||
| 730 | #ifdef CONFIG_SUSPEND | 736 | #ifdef CONFIG_SUSPEND |
| 731 | 737 | ||
| 732 | static int platform_pm_suspend(struct device *dev) | 738 | int __weak platform_pm_suspend(struct device *dev) |
| 733 | { | 739 | { |
| 734 | struct device_driver *drv = dev->driver; | 740 | struct device_driver *drv = dev->driver; |
| 735 | int ret = 0; | 741 | int ret = 0; |
| @@ -747,7 +753,7 @@ static int platform_pm_suspend(struct device *dev) | |||
| 747 | return ret; | 753 | return ret; |
| 748 | } | 754 | } |
| 749 | 755 | ||
| 750 | static int platform_pm_suspend_noirq(struct device *dev) | 756 | int __weak platform_pm_suspend_noirq(struct device *dev) |
| 751 | { | 757 | { |
| 752 | struct device_driver *drv = dev->driver; | 758 | struct device_driver *drv = dev->driver; |
| 753 | int ret = 0; | 759 | int ret = 0; |
| @@ -763,7 +769,7 @@ static int platform_pm_suspend_noirq(struct device *dev) | |||
| 763 | return ret; | 769 | return ret; |
| 764 | } | 770 | } |
| 765 | 771 | ||
| 766 | static int platform_pm_resume(struct device *dev) | 772 | int __weak platform_pm_resume(struct device *dev) |
| 767 | { | 773 | { |
| 768 | struct device_driver *drv = dev->driver; | 774 | struct device_driver *drv = dev->driver; |
| 769 | int ret = 0; | 775 | int ret = 0; |
| @@ -781,7 +787,7 @@ static int platform_pm_resume(struct device *dev) | |||
| 781 | return ret; | 787 | return ret; |
| 782 | } | 788 | } |
| 783 | 789 | ||
| 784 | static int platform_pm_resume_noirq(struct device *dev) | 790 | int __weak platform_pm_resume_noirq(struct device *dev) |
| 785 | { | 791 | { |
| 786 | struct device_driver *drv = dev->driver; | 792 | struct device_driver *drv = dev->driver; |
| 787 | int ret = 0; | 793 | int ret = 0; |
| @@ -961,17 +967,17 @@ static int platform_pm_restore_noirq(struct device *dev) | |||
| 961 | 967 | ||
| 962 | int __weak platform_pm_runtime_suspend(struct device *dev) | 968 | int __weak platform_pm_runtime_suspend(struct device *dev) |
| 963 | { | 969 | { |
| 964 | return -ENOSYS; | 970 | return pm_generic_runtime_suspend(dev); |
| 965 | }; | 971 | }; |
| 966 | 972 | ||
| 967 | int __weak platform_pm_runtime_resume(struct device *dev) | 973 | int __weak platform_pm_runtime_resume(struct device *dev) |
| 968 | { | 974 | { |
| 969 | return -ENOSYS; | 975 | return pm_generic_runtime_resume(dev); |
| 970 | }; | 976 | }; |
| 971 | 977 | ||
| 972 | int __weak platform_pm_runtime_idle(struct device *dev) | 978 | int __weak platform_pm_runtime_idle(struct device *dev) |
| 973 | { | 979 | { |
| 974 | return -ENOSYS; | 980 | return pm_generic_runtime_idle(dev); |
| 975 | }; | 981 | }; |
| 976 | 982 | ||
| 977 | #else /* !CONFIG_PM_RUNTIME */ | 983 | #else /* !CONFIG_PM_RUNTIME */ |
| @@ -1052,9 +1058,11 @@ static __initdata LIST_HEAD(early_platform_driver_list); | |||
| 1052 | static __initdata LIST_HEAD(early_platform_device_list); | 1058 | static __initdata LIST_HEAD(early_platform_device_list); |
| 1053 | 1059 | ||
| 1054 | /** | 1060 | /** |
| 1055 | * early_platform_driver_register | 1061 | * early_platform_driver_register - register early platform driver |
| 1056 | * @epdrv: early_platform driver structure | 1062 | * @epdrv: early_platform driver structure |
| 1057 | * @buf: string passed from early_param() | 1063 | * @buf: string passed from early_param() |
| 1064 | * | ||
| 1065 | * Helper function for early_platform_init() / early_platform_init_buffer() | ||
| 1058 | */ | 1066 | */ |
| 1059 | int __init early_platform_driver_register(struct early_platform_driver *epdrv, | 1067 | int __init early_platform_driver_register(struct early_platform_driver *epdrv, |
| 1060 | char *buf) | 1068 | char *buf) |
| @@ -1106,9 +1114,12 @@ int __init early_platform_driver_register(struct early_platform_driver *epdrv, | |||
| 1106 | } | 1114 | } |
| 1107 | 1115 | ||
| 1108 | /** | 1116 | /** |
| 1109 | * early_platform_add_devices - add a numbers of early platform devices | 1117 | * early_platform_add_devices - adds a number of early platform devices |
| 1110 | * @devs: array of early platform devices to add | 1118 | * @devs: array of early platform devices to add |
| 1111 | * @num: number of early platform devices in array | 1119 | * @num: number of early platform devices in array |
| 1120 | * | ||
| 1121 | * Used by early architecture code to register early platform devices and | ||
| 1122 | * their platform data. | ||
| 1112 | */ | 1123 | */ |
| 1113 | void __init early_platform_add_devices(struct platform_device **devs, int num) | 1124 | void __init early_platform_add_devices(struct platform_device **devs, int num) |
| 1114 | { | 1125 | { |
| @@ -1128,8 +1139,12 @@ void __init early_platform_add_devices(struct platform_device **devs, int num) | |||
| 1128 | } | 1139 | } |
| 1129 | 1140 | ||
| 1130 | /** | 1141 | /** |
| 1131 | * early_platform_driver_register_all | 1142 | * early_platform_driver_register_all - register early platform drivers |
| 1132 | * @class_str: string to identify early platform driver class | 1143 | * @class_str: string to identify early platform driver class |
| 1144 | * | ||
| 1145 | * Used by architecture code to register all early platform drivers | ||
| 1146 | * for a certain class. If omitted then only early platform drivers | ||
| 1147 | * with matching kernel command line class parameters will be registered. | ||
| 1133 | */ | 1148 | */ |
| 1134 | void __init early_platform_driver_register_all(char *class_str) | 1149 | void __init early_platform_driver_register_all(char *class_str) |
| 1135 | { | 1150 | { |
| @@ -1151,7 +1166,7 @@ void __init early_platform_driver_register_all(char *class_str) | |||
| 1151 | } | 1166 | } |
| 1152 | 1167 | ||
| 1153 | /** | 1168 | /** |
| 1154 | * early_platform_match | 1169 | * early_platform_match - find early platform device matching driver |
| 1155 | * @epdrv: early platform driver structure | 1170 | * @epdrv: early platform driver structure |
| 1156 | * @id: id to match against | 1171 | * @id: id to match against |
| 1157 | */ | 1172 | */ |
| @@ -1169,7 +1184,7 @@ early_platform_match(struct early_platform_driver *epdrv, int id) | |||
| 1169 | } | 1184 | } |
| 1170 | 1185 | ||
| 1171 | /** | 1186 | /** |
| 1172 | * early_platform_left | 1187 | * early_platform_left - check if early platform driver has matching devices |
| 1173 | * @epdrv: early platform driver structure | 1188 | * @epdrv: early platform driver structure |
| 1174 | * @id: return true if id or above exists | 1189 | * @id: return true if id or above exists |
| 1175 | */ | 1190 | */ |
| @@ -1187,7 +1202,7 @@ static __init int early_platform_left(struct early_platform_driver *epdrv, | |||
| 1187 | } | 1202 | } |
| 1188 | 1203 | ||
| 1189 | /** | 1204 | /** |
| 1190 | * early_platform_driver_probe_id | 1205 | * early_platform_driver_probe_id - probe drivers matching class_str and id |
| 1191 | * @class_str: string to identify early platform driver class | 1206 | * @class_str: string to identify early platform driver class |
| 1192 | * @id: id to match against | 1207 | * @id: id to match against |
| 1193 | * @nr_probe: number of platform devices to successfully probe before exiting | 1208 | * @nr_probe: number of platform devices to successfully probe before exiting |
| @@ -1239,6 +1254,26 @@ static int __init early_platform_driver_probe_id(char *class_str, | |||
| 1239 | } | 1254 | } |
| 1240 | 1255 | ||
| 1241 | if (match) { | 1256 | if (match) { |
| 1257 | /* | ||
| 1258 | * Set up a sensible init_name to enable | ||
| 1259 | * dev_name() and others to be used before the | ||
| 1260 | * rest of the driver core is initialized. | ||
| 1261 | */ | ||
| 1262 | if (!match->dev.init_name && slab_is_available()) { | ||
| 1263 | if (match->id != -1) | ||
| 1264 | match->dev.init_name = | ||
| 1265 | kasprintf(GFP_KERNEL, "%s.%d", | ||
| 1266 | match->name, | ||
| 1267 | match->id); | ||
| 1268 | else | ||
| 1269 | match->dev.init_name = | ||
| 1270 | kasprintf(GFP_KERNEL, "%s", | ||
| 1271 | match->name); | ||
| 1272 | |||
| 1273 | if (!match->dev.init_name) | ||
| 1274 | return -ENOMEM; | ||
| 1275 | } | ||
| 1276 | |||
| 1242 | if (epdrv->pdrv->probe(match)) | 1277 | if (epdrv->pdrv->probe(match)) |
| 1243 | pr_warning("%s: unable to probe %s early.\n", | 1278 | pr_warning("%s: unable to probe %s early.\n", |
| 1244 | class_str, match->name); | 1279 | class_str, match->name); |
| @@ -1257,10 +1292,14 @@ static int __init early_platform_driver_probe_id(char *class_str, | |||
| 1257 | } | 1292 | } |
| 1258 | 1293 | ||
| 1259 | /** | 1294 | /** |
| 1260 | * early_platform_driver_probe | 1295 | * early_platform_driver_probe - probe a class of registered drivers |
| 1261 | * @class_str: string to identify early platform driver class | 1296 | * @class_str: string to identify early platform driver class |
| 1262 | * @nr_probe: number of platform devices to successfully probe before exiting | 1297 | * @nr_probe: number of platform devices to successfully probe before exiting |
| 1263 | * @user_only: only probe user specified early platform devices | 1298 | * @user_only: only probe user specified early platform devices |
| 1299 | * | ||
| 1300 | * Used by architecture code to probe registered early platform drivers | ||
| 1301 | * within a certain class. For probe to happen a registered early platform | ||
| 1302 | * device matching a registered early platform driver is needed. | ||
| 1264 | */ | 1303 | */ |
| 1265 | int __init early_platform_driver_probe(char *class_str, | 1304 | int __init early_platform_driver_probe(char *class_str, |
| 1266 | int nr_probe, | 1305 | int nr_probe, |
