diff options
| -rw-r--r-- | Documentation/driver-model/driver.txt | 7 | ||||
| -rw-r--r-- | Documentation/filesystems/sysfs.txt | 3 | ||||
| -rw-r--r-- | drivers/base/arch_topology.c | 12 | ||||
| -rw-r--r-- | drivers/base/platform.c | 3 | ||||
| -rw-r--r-- | drivers/fpga/altera-cvp.c | 6 | ||||
| -rw-r--r-- | include/linux/device.h | 2 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 49 |
7 files changed, 58 insertions, 24 deletions
diff --git a/Documentation/driver-model/driver.txt b/Documentation/driver-model/driver.txt index 4421135826a2..d661e6f7e6a0 100644 --- a/Documentation/driver-model/driver.txt +++ b/Documentation/driver-model/driver.txt | |||
| @@ -196,12 +196,13 @@ struct driver_attribute { | |||
| 196 | }; | 196 | }; |
| 197 | 197 | ||
| 198 | Device drivers can export attributes via their sysfs directories. | 198 | Device drivers can export attributes via their sysfs directories. |
| 199 | Drivers can declare attributes using a DRIVER_ATTR macro that works | 199 | Drivers can declare attributes using a DRIVER_ATTR_RW and DRIVER_ATTR_RO |
| 200 | identically to the DEVICE_ATTR macro. | 200 | macro that works identically to the DEVICE_ATTR_RW and DEVICE_ATTR_RO |
| 201 | macros. | ||
| 201 | 202 | ||
| 202 | Example: | 203 | Example: |
| 203 | 204 | ||
| 204 | DRIVER_ATTR(debug,0644,show_debug,store_debug); | 205 | DRIVER_ATTR_RW(debug); |
| 205 | 206 | ||
| 206 | This is equivalent to declaring: | 207 | This is equivalent to declaring: |
| 207 | 208 | ||
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index 24da7b32c489..9a3658cc399e 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt | |||
| @@ -366,7 +366,8 @@ struct driver_attribute { | |||
| 366 | 366 | ||
| 367 | Declaring: | 367 | Declaring: |
| 368 | 368 | ||
| 369 | DRIVER_ATTR(_name, _mode, _show, _store) | 369 | DRIVER_ATTR_RO(_name) |
| 370 | DRIVER_ATTR_RW(_name) | ||
| 370 | 371 | ||
| 371 | Creation/Removal: | 372 | Creation/Removal: |
| 372 | 373 | ||
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 41be9ff7d70a..6df7d6676a48 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c | |||
| @@ -166,11 +166,11 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu) | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | #ifdef CONFIG_CPU_FREQ | 168 | #ifdef CONFIG_CPU_FREQ |
| 169 | static cpumask_var_t cpus_to_visit; | 169 | static cpumask_var_t cpus_to_visit __initdata; |
| 170 | static void parsing_done_workfn(struct work_struct *work); | 170 | static void __init parsing_done_workfn(struct work_struct *work); |
| 171 | static DECLARE_WORK(parsing_done_work, parsing_done_workfn); | 171 | static __initdata DECLARE_WORK(parsing_done_work, parsing_done_workfn); |
| 172 | 172 | ||
| 173 | static int | 173 | static int __init |
| 174 | init_cpu_capacity_callback(struct notifier_block *nb, | 174 | init_cpu_capacity_callback(struct notifier_block *nb, |
| 175 | unsigned long val, | 175 | unsigned long val, |
| 176 | void *data) | 176 | void *data) |
| @@ -206,7 +206,7 @@ init_cpu_capacity_callback(struct notifier_block *nb, | |||
| 206 | return 0; | 206 | return 0; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | static struct notifier_block init_cpu_capacity_notifier = { | 209 | static struct notifier_block init_cpu_capacity_notifier __initdata = { |
| 210 | .notifier_call = init_cpu_capacity_callback, | 210 | .notifier_call = init_cpu_capacity_callback, |
| 211 | }; | 211 | }; |
| 212 | 212 | ||
| @@ -232,7 +232,7 @@ static int __init register_cpufreq_notifier(void) | |||
| 232 | } | 232 | } |
| 233 | core_initcall(register_cpufreq_notifier); | 233 | core_initcall(register_cpufreq_notifier); |
| 234 | 234 | ||
| 235 | static void parsing_done_workfn(struct work_struct *work) | 235 | static void __init parsing_done_workfn(struct work_struct *work) |
| 236 | { | 236 | { |
| 237 | cpufreq_unregister_notifier(&init_cpu_capacity_notifier, | 237 | cpufreq_unregister_notifier(&init_cpu_capacity_notifier, |
| 238 | CPUFREQ_POLICY_NOTIFIER); | 238 | CPUFREQ_POLICY_NOTIFIER); |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index d1bd99271066..9045c5f3734e 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
| @@ -868,7 +868,8 @@ static ssize_t driver_override_store(struct device *dev, | |||
| 868 | struct platform_device *pdev = to_platform_device(dev); | 868 | struct platform_device *pdev = to_platform_device(dev); |
| 869 | char *driver_override, *old, *cp; | 869 | char *driver_override, *old, *cp; |
| 870 | 870 | ||
| 871 | if (count > PATH_MAX) | 871 | /* We need to keep extra room for a newline */ |
| 872 | if (count >= (PAGE_SIZE - 1)) | ||
| 872 | return -EINVAL; | 873 | return -EINVAL; |
| 873 | 874 | ||
| 874 | driver_override = kstrndup(buf, count, GFP_KERNEL); | 875 | driver_override = kstrndup(buf, count, GFP_KERNEL); |
diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 08629ee69d11..00e73d28077c 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c | |||
| @@ -361,12 +361,12 @@ static const struct fpga_manager_ops altera_cvp_ops = { | |||
| 361 | .write_complete = altera_cvp_write_complete, | 361 | .write_complete = altera_cvp_write_complete, |
| 362 | }; | 362 | }; |
| 363 | 363 | ||
| 364 | static ssize_t show_chkcfg(struct device_driver *dev, char *buf) | 364 | static ssize_t chkcfg_show(struct device_driver *dev, char *buf) |
| 365 | { | 365 | { |
| 366 | return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg); | 366 | return snprintf(buf, 3, "%d\n", altera_cvp_chkcfg); |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | static ssize_t store_chkcfg(struct device_driver *drv, const char *buf, | 369 | static ssize_t chkcfg_store(struct device_driver *drv, const char *buf, |
| 370 | size_t count) | 370 | size_t count) |
| 371 | { | 371 | { |
| 372 | int ret; | 372 | int ret; |
| @@ -378,7 +378,7 @@ static ssize_t store_chkcfg(struct device_driver *drv, const char *buf, | |||
| 378 | return count; | 378 | return count; |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | static DRIVER_ATTR(chkcfg, 0600, show_chkcfg, store_chkcfg); | 381 | static DRIVER_ATTR_RW(chkcfg); |
| 382 | 382 | ||
| 383 | static int altera_cvp_probe(struct pci_dev *pdev, | 383 | static int altera_cvp_probe(struct pci_dev *pdev, |
| 384 | const struct pci_device_id *dev_id); | 384 | const struct pci_device_id *dev_id); |
diff --git a/include/linux/device.h b/include/linux/device.h index 1d2607923a24..66fe271c2544 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -307,8 +307,6 @@ struct driver_attribute { | |||
| 307 | size_t count); | 307 | size_t count); |
| 308 | }; | 308 | }; |
| 309 | 309 | ||
| 310 | #define DRIVER_ATTR(_name, _mode, _show, _store) \ | ||
| 311 | struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store) | ||
| 312 | #define DRIVER_ATTR_RW(_name) \ | 310 | #define DRIVER_ATTR_RW(_name) \ |
| 313 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) | 311 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) |
| 314 | #define DRIVER_ATTR_RO(_name) \ | 312 | #define DRIVER_ATTR_RO(_name) \ |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index e590523ea476..f237a09a5862 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
| @@ -294,6 +294,26 @@ static void cleanup_uevent_env(struct subprocess_info *info) | |||
| 294 | } | 294 | } |
| 295 | #endif | 295 | #endif |
| 296 | 296 | ||
| 297 | static void zap_modalias_env(struct kobj_uevent_env *env) | ||
| 298 | { | ||
| 299 | static const char modalias_prefix[] = "MODALIAS="; | ||
| 300 | int i; | ||
| 301 | |||
| 302 | for (i = 0; i < env->envp_idx;) { | ||
| 303 | if (strncmp(env->envp[i], modalias_prefix, | ||
| 304 | sizeof(modalias_prefix) - 1)) { | ||
| 305 | i++; | ||
| 306 | continue; | ||
| 307 | } | ||
| 308 | |||
| 309 | if (i != env->envp_idx - 1) | ||
| 310 | memmove(&env->envp[i], &env->envp[i + 1], | ||
| 311 | sizeof(env->envp[i]) * env->envp_idx - 1); | ||
| 312 | |||
| 313 | env->envp_idx--; | ||
| 314 | } | ||
| 315 | } | ||
| 316 | |||
| 297 | /** | 317 | /** |
| 298 | * kobject_uevent_env - send an uevent with environmental data | 318 | * kobject_uevent_env - send an uevent with environmental data |
| 299 | * | 319 | * |
| @@ -409,16 +429,29 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 409 | } | 429 | } |
| 410 | } | 430 | } |
| 411 | 431 | ||
| 412 | /* | 432 | switch (action) { |
| 413 | * Mark "add" and "remove" events in the object to ensure proper | 433 | case KOBJ_ADD: |
| 414 | * events to userspace during automatic cleanup. If the object did | 434 | /* |
| 415 | * send an "add" event, "remove" will automatically generated by | 435 | * Mark "add" event so we can make sure we deliver "remove" |
| 416 | * the core, if not already done by the caller. | 436 | * event to userspace during automatic cleanup. If |
| 417 | */ | 437 | * the object did send an "add" event, "remove" will |
| 418 | if (action == KOBJ_ADD) | 438 | * automatically generated by the core, if not already done |
| 439 | * by the caller. | ||
| 440 | */ | ||
| 419 | kobj->state_add_uevent_sent = 1; | 441 | kobj->state_add_uevent_sent = 1; |
| 420 | else if (action == KOBJ_REMOVE) | 442 | break; |
| 443 | |||
| 444 | case KOBJ_REMOVE: | ||
| 421 | kobj->state_remove_uevent_sent = 1; | 445 | kobj->state_remove_uevent_sent = 1; |
| 446 | break; | ||
| 447 | |||
| 448 | case KOBJ_UNBIND: | ||
| 449 | zap_modalias_env(env); | ||
| 450 | break; | ||
| 451 | |||
| 452 | default: | ||
| 453 | break; | ||
| 454 | } | ||
| 422 | 455 | ||
| 423 | mutex_lock(&uevent_sock_mutex); | 456 | mutex_lock(&uevent_sock_mutex); |
| 424 | /* we will send an event, so request a new sequence number */ | 457 | /* we will send an event, so request a new sequence number */ |
