diff options
Diffstat (limited to 'drivers/base')
| -rw-r--r-- | drivers/base/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/base/class.c | 9 | ||||
| -rw-r--r-- | drivers/base/core.c | 130 | ||||
| -rw-r--r-- | drivers/base/cpu.c | 2 | ||||
| -rw-r--r-- | drivers/base/dd.c | 4 | ||||
| -rw-r--r-- | drivers/base/devtmpfs.c | 5 | ||||
| -rw-r--r-- | drivers/base/firmware_class.c | 206 | ||||
| -rw-r--r-- | drivers/base/module.c | 4 | ||||
| -rw-r--r-- | drivers/base/platform.c | 8 |
9 files changed, 243 insertions, 132 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index fd52c48ee762..ef38aff737eb 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig | |||
| @@ -18,9 +18,9 @@ config UEVENT_HELPER_PATH | |||
| 18 | 18 | ||
| 19 | config DEVTMPFS | 19 | config DEVTMPFS |
| 20 | bool "Maintain a devtmpfs filesystem to mount at /dev" | 20 | bool "Maintain a devtmpfs filesystem to mount at /dev" |
| 21 | depends on HOTPLUG && SHMEM && TMPFS | 21 | depends on HOTPLUG |
| 22 | help | 22 | help |
| 23 | This creates a tmpfs filesystem instance early at bootup. | 23 | This creates a tmpfs/ramfs filesystem instance early at bootup. |
| 24 | In this filesystem, the kernel driver core maintains device | 24 | In this filesystem, the kernel driver core maintains device |
| 25 | nodes with their default names and permissions for all | 25 | nodes with their default names and permissions for all |
| 26 | registered devices with an assigned major/minor number. | 26 | registered devices with an assigned major/minor number. |
| @@ -33,6 +33,9 @@ config DEVTMPFS | |||
| 33 | functional /dev without any further help. It also allows simple | 33 | functional /dev without any further help. It also allows simple |
| 34 | rescue systems, and reliably handles dynamic major/minor numbers. | 34 | rescue systems, and reliably handles dynamic major/minor numbers. |
| 35 | 35 | ||
| 36 | Notice: if CONFIG_TMPFS isn't enabled, the simpler ramfs | ||
| 37 | file system will be used instead. | ||
| 38 | |||
| 36 | config DEVTMPFS_MOUNT | 39 | config DEVTMPFS_MOUNT |
| 37 | bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" | 40 | bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs" |
| 38 | depends on DEVTMPFS | 41 | depends on DEVTMPFS |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 9c6a0d6408e7..8e231d05b400 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
| @@ -63,6 +63,14 @@ static void class_release(struct kobject *kobj) | |||
| 63 | kfree(cp); | 63 | kfree(cp); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject *kobj) | ||
| 67 | { | ||
| 68 | struct class_private *cp = to_class(kobj); | ||
| 69 | struct class *class = cp->class; | ||
| 70 | |||
| 71 | return class->ns_type; | ||
| 72 | } | ||
| 73 | |||
| 66 | static const struct sysfs_ops class_sysfs_ops = { | 74 | static const struct sysfs_ops class_sysfs_ops = { |
| 67 | .show = class_attr_show, | 75 | .show = class_attr_show, |
| 68 | .store = class_attr_store, | 76 | .store = class_attr_store, |
| @@ -71,6 +79,7 @@ static const struct sysfs_ops class_sysfs_ops = { | |||
| 71 | static struct kobj_type class_ktype = { | 79 | static struct kobj_type class_ktype = { |
| 72 | .sysfs_ops = &class_sysfs_ops, | 80 | .sysfs_ops = &class_sysfs_ops, |
| 73 | .release = class_release, | 81 | .release = class_release, |
| 82 | .child_ns_type = class_child_ns_type, | ||
| 74 | }; | 83 | }; |
| 75 | 84 | ||
| 76 | /* Hotplug events for classes go to the class class_subsys */ | 85 | /* Hotplug events for classes go to the class class_subsys */ |
diff --git a/drivers/base/core.c b/drivers/base/core.c index b56a0ba31d4a..9630fbdf4e6c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include <linux/notifier.h> | 20 | #include <linux/notifier.h> |
| 21 | #include <linux/genhd.h> | 21 | #include <linux/genhd.h> |
| 22 | #include <linux/kallsyms.h> | 22 | #include <linux/kallsyms.h> |
| 23 | #include <linux/semaphore.h> | ||
| 24 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
| 25 | #include <linux/async.h> | 24 | #include <linux/async.h> |
| 26 | 25 | ||
| @@ -132,9 +131,21 @@ static void device_release(struct kobject *kobj) | |||
| 132 | kfree(p); | 131 | kfree(p); |
| 133 | } | 132 | } |
| 134 | 133 | ||
| 134 | static const void *device_namespace(struct kobject *kobj) | ||
| 135 | { | ||
| 136 | struct device *dev = to_dev(kobj); | ||
| 137 | const void *ns = NULL; | ||
| 138 | |||
| 139 | if (dev->class && dev->class->ns_type) | ||
| 140 | ns = dev->class->namespace(dev); | ||
| 141 | |||
| 142 | return ns; | ||
| 143 | } | ||
| 144 | |||
| 135 | static struct kobj_type device_ktype = { | 145 | static struct kobj_type device_ktype = { |
| 136 | .release = device_release, | 146 | .release = device_release, |
| 137 | .sysfs_ops = &dev_sysfs_ops, | 147 | .sysfs_ops = &dev_sysfs_ops, |
| 148 | .namespace = device_namespace, | ||
| 138 | }; | 149 | }; |
| 139 | 150 | ||
| 140 | 151 | ||
| @@ -559,10 +570,10 @@ void device_initialize(struct device *dev) | |||
| 559 | dev->kobj.kset = devices_kset; | 570 | dev->kobj.kset = devices_kset; |
| 560 | kobject_init(&dev->kobj, &device_ktype); | 571 | kobject_init(&dev->kobj, &device_ktype); |
| 561 | INIT_LIST_HEAD(&dev->dma_pools); | 572 | INIT_LIST_HEAD(&dev->dma_pools); |
| 562 | init_MUTEX(&dev->sem); | 573 | mutex_init(&dev->mutex); |
| 574 | lockdep_set_novalidate_class(&dev->mutex); | ||
| 563 | spin_lock_init(&dev->devres_lock); | 575 | spin_lock_init(&dev->devres_lock); |
| 564 | INIT_LIST_HEAD(&dev->devres_head); | 576 | INIT_LIST_HEAD(&dev->devres_head); |
| 565 | device_init_wakeup(dev, 0); | ||
| 566 | device_pm_init(dev); | 577 | device_pm_init(dev); |
| 567 | set_dev_node(dev, -1); | 578 | set_dev_node(dev, -1); |
| 568 | } | 579 | } |
| @@ -596,11 +607,59 @@ static struct kobject *virtual_device_parent(struct device *dev) | |||
| 596 | return virtual_dir; | 607 | return virtual_dir; |
| 597 | } | 608 | } |
| 598 | 609 | ||
| 599 | static struct kobject *get_device_parent(struct device *dev, | 610 | struct class_dir { |
| 600 | struct device *parent) | 611 | struct kobject kobj; |
| 612 | struct class *class; | ||
| 613 | }; | ||
| 614 | |||
| 615 | #define to_class_dir(obj) container_of(obj, struct class_dir, kobj) | ||
| 616 | |||
| 617 | static void class_dir_release(struct kobject *kobj) | ||
| 618 | { | ||
| 619 | struct class_dir *dir = to_class_dir(kobj); | ||
| 620 | kfree(dir); | ||
| 621 | } | ||
| 622 | |||
| 623 | static const | ||
| 624 | struct kobj_ns_type_operations *class_dir_child_ns_type(struct kobject *kobj) | ||
| 601 | { | 625 | { |
| 626 | struct class_dir *dir = to_class_dir(kobj); | ||
| 627 | return dir->class->ns_type; | ||
| 628 | } | ||
| 629 | |||
| 630 | static struct kobj_type class_dir_ktype = { | ||
| 631 | .release = class_dir_release, | ||
| 632 | .sysfs_ops = &kobj_sysfs_ops, | ||
| 633 | .child_ns_type = class_dir_child_ns_type | ||
| 634 | }; | ||
| 635 | |||
| 636 | static struct kobject * | ||
| 637 | class_dir_create_and_add(struct class *class, struct kobject *parent_kobj) | ||
| 638 | { | ||
| 639 | struct class_dir *dir; | ||
| 602 | int retval; | 640 | int retval; |
| 603 | 641 | ||
| 642 | dir = kzalloc(sizeof(*dir), GFP_KERNEL); | ||
| 643 | if (!dir) | ||
| 644 | return NULL; | ||
| 645 | |||
| 646 | dir->class = class; | ||
| 647 | kobject_init(&dir->kobj, &class_dir_ktype); | ||
| 648 | |||
| 649 | dir->kobj.kset = &class->p->class_dirs; | ||
| 650 | |||
| 651 | retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name); | ||
| 652 | if (retval < 0) { | ||
| 653 | kobject_put(&dir->kobj); | ||
| 654 | return NULL; | ||
| 655 | } | ||
| 656 | return &dir->kobj; | ||
| 657 | } | ||
| 658 | |||
| 659 | |||
| 660 | static struct kobject *get_device_parent(struct device *dev, | ||
| 661 | struct device *parent) | ||
| 662 | { | ||
| 604 | if (dev->class) { | 663 | if (dev->class) { |
| 605 | static DEFINE_MUTEX(gdp_mutex); | 664 | static DEFINE_MUTEX(gdp_mutex); |
| 606 | struct kobject *kobj = NULL; | 665 | struct kobject *kobj = NULL; |
| @@ -635,18 +694,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
| 635 | } | 694 | } |
| 636 | 695 | ||
| 637 | /* or create a new class-directory at the parent device */ | 696 | /* or create a new class-directory at the parent device */ |
| 638 | k = kobject_create(); | 697 | k = class_dir_create_and_add(dev->class, parent_kobj); |
| 639 | if (!k) { | ||
| 640 | mutex_unlock(&gdp_mutex); | ||
| 641 | return NULL; | ||
| 642 | } | ||
| 643 | k->kset = &dev->class->p->class_dirs; | ||
| 644 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); | ||
| 645 | if (retval < 0) { | ||
| 646 | mutex_unlock(&gdp_mutex); | ||
| 647 | kobject_put(k); | ||
| 648 | return NULL; | ||
| 649 | } | ||
| 650 | /* do not emit an uevent for this simple "glue" directory */ | 698 | /* do not emit an uevent for this simple "glue" directory */ |
| 651 | mutex_unlock(&gdp_mutex); | 699 | mutex_unlock(&gdp_mutex); |
| 652 | return k; | 700 | return k; |
| @@ -738,7 +786,7 @@ out_device: | |||
| 738 | out_busid: | 786 | out_busid: |
| 739 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | 787 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
| 740 | device_is_not_partition(dev)) | 788 | device_is_not_partition(dev)) |
| 741 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, | 789 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, |
| 742 | dev_name(dev)); | 790 | dev_name(dev)); |
| 743 | #else | 791 | #else |
| 744 | /* link in the class directory pointing to the device */ | 792 | /* link in the class directory pointing to the device */ |
| @@ -756,7 +804,7 @@ out_busid: | |||
| 756 | return 0; | 804 | return 0; |
| 757 | 805 | ||
| 758 | out_busid: | 806 | out_busid: |
| 759 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); | 807 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); |
| 760 | #endif | 808 | #endif |
| 761 | 809 | ||
| 762 | out_subsys: | 810 | out_subsys: |
| @@ -784,13 +832,13 @@ static void device_remove_class_symlinks(struct device *dev) | |||
| 784 | 832 | ||
| 785 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && | 833 | if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && |
| 786 | device_is_not_partition(dev)) | 834 | device_is_not_partition(dev)) |
| 787 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, | 835 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, |
| 788 | dev_name(dev)); | 836 | dev_name(dev)); |
| 789 | #else | 837 | #else |
| 790 | if (dev->parent && device_is_not_partition(dev)) | 838 | if (dev->parent && device_is_not_partition(dev)) |
| 791 | sysfs_remove_link(&dev->kobj, "device"); | 839 | sysfs_remove_link(&dev->kobj, "device"); |
| 792 | 840 | ||
| 793 | sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev_name(dev)); | 841 | sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); |
| 794 | #endif | 842 | #endif |
| 795 | 843 | ||
| 796 | sysfs_remove_link(&dev->kobj, "subsystem"); | 844 | sysfs_remove_link(&dev->kobj, "subsystem"); |
| @@ -1372,7 +1420,7 @@ struct device *__root_device_register(const char *name, struct module *owner) | |||
| 1372 | return ERR_PTR(err); | 1420 | return ERR_PTR(err); |
| 1373 | } | 1421 | } |
| 1374 | 1422 | ||
| 1375 | #ifdef CONFIG_MODULE /* gotta find a "cleaner" way to do this */ | 1423 | #ifdef CONFIG_MODULES /* gotta find a "cleaner" way to do this */ |
| 1376 | if (owner) { | 1424 | if (owner) { |
| 1377 | struct module_kobject *mk = &owner->mkobj; | 1425 | struct module_kobject *mk = &owner->mkobj; |
| 1378 | 1426 | ||
| @@ -1576,6 +1624,14 @@ int device_rename(struct device *dev, char *new_name) | |||
| 1576 | goto out; | 1624 | goto out; |
| 1577 | } | 1625 | } |
| 1578 | 1626 | ||
| 1627 | #ifndef CONFIG_SYSFS_DEPRECATED | ||
| 1628 | if (dev->class) { | ||
| 1629 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, | ||
| 1630 | &dev->kobj, old_device_name, new_name); | ||
| 1631 | if (error) | ||
| 1632 | goto out; | ||
| 1633 | } | ||
| 1634 | #endif | ||
| 1579 | error = kobject_rename(&dev->kobj, new_name); | 1635 | error = kobject_rename(&dev->kobj, new_name); |
| 1580 | if (error) | 1636 | if (error) |
| 1581 | goto out; | 1637 | goto out; |
| @@ -1590,11 +1646,6 @@ int device_rename(struct device *dev, char *new_name) | |||
| 1590 | new_class_name); | 1646 | new_class_name); |
| 1591 | } | 1647 | } |
| 1592 | } | 1648 | } |
| 1593 | #else | ||
| 1594 | if (dev->class) { | ||
| 1595 | error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, | ||
| 1596 | &dev->kobj, old_device_name, new_name); | ||
| 1597 | } | ||
| 1598 | #endif | 1649 | #endif |
| 1599 | 1650 | ||
| 1600 | out: | 1651 | out: |
| @@ -1735,10 +1786,25 @@ EXPORT_SYMBOL_GPL(device_move); | |||
| 1735 | */ | 1786 | */ |
| 1736 | void device_shutdown(void) | 1787 | void device_shutdown(void) |
| 1737 | { | 1788 | { |
| 1738 | struct device *dev, *devn; | 1789 | struct device *dev; |
| 1790 | |||
| 1791 | spin_lock(&devices_kset->list_lock); | ||
| 1792 | /* | ||
| 1793 | * Walk the devices list backward, shutting down each in turn. | ||
| 1794 | * Beware that device unplug events may also start pulling | ||
| 1795 | * devices offline, even as the system is shutting down. | ||
| 1796 | */ | ||
| 1797 | while (!list_empty(&devices_kset->list)) { | ||
| 1798 | dev = list_entry(devices_kset->list.prev, struct device, | ||
| 1799 | kobj.entry); | ||
| 1800 | get_device(dev); | ||
| 1801 | /* | ||
| 1802 | * Make sure the device is off the kset list, in the | ||
| 1803 | * event that dev->*->shutdown() doesn't remove it. | ||
| 1804 | */ | ||
| 1805 | list_del_init(&dev->kobj.entry); | ||
| 1806 | spin_unlock(&devices_kset->list_lock); | ||
| 1739 | 1807 | ||
| 1740 | list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list, | ||
| 1741 | kobj.entry) { | ||
| 1742 | if (dev->bus && dev->bus->shutdown) { | 1808 | if (dev->bus && dev->bus->shutdown) { |
| 1743 | dev_dbg(dev, "shutdown\n"); | 1809 | dev_dbg(dev, "shutdown\n"); |
| 1744 | dev->bus->shutdown(dev); | 1810 | dev->bus->shutdown(dev); |
| @@ -1746,6 +1812,10 @@ void device_shutdown(void) | |||
| 1746 | dev_dbg(dev, "shutdown\n"); | 1812 | dev_dbg(dev, "shutdown\n"); |
| 1747 | dev->driver->shutdown(dev); | 1813 | dev->driver->shutdown(dev); |
| 1748 | } | 1814 | } |
| 1815 | put_device(dev); | ||
| 1816 | |||
| 1817 | spin_lock(&devices_kset->list_lock); | ||
| 1749 | } | 1818 | } |
| 1819 | spin_unlock(&devices_kset->list_lock); | ||
| 1750 | async_synchronize_full(); | 1820 | async_synchronize_full(); |
| 1751 | } | 1821 | } |
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index f35719aab3c1..251acea3d359 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
| @@ -186,7 +186,7 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, | |||
| 186 | /* display offline cpus < nr_cpu_ids */ | 186 | /* display offline cpus < nr_cpu_ids */ |
| 187 | if (!alloc_cpumask_var(&offline, GFP_KERNEL)) | 187 | if (!alloc_cpumask_var(&offline, GFP_KERNEL)) |
| 188 | return -ENOMEM; | 188 | return -ENOMEM; |
| 189 | cpumask_complement(offline, cpu_online_mask); | 189 | cpumask_andnot(offline, cpu_possible_mask, cpu_online_mask); |
| 190 | n = cpulist_scnprintf(buf, len, offline); | 190 | n = cpulist_scnprintf(buf, len, offline); |
| 191 | free_cpumask_var(offline); | 191 | free_cpumask_var(offline); |
| 192 | 192 | ||
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index c89291f8a16b..503c2620bbcc 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
| @@ -40,11 +40,11 @@ static void driver_bound(struct device *dev) | |||
| 40 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev), | 40 | pr_debug("driver: '%s': %s: bound to device '%s'\n", dev_name(dev), |
| 41 | __func__, dev->driver->name); | 41 | __func__, dev->driver->name); |
| 42 | 42 | ||
| 43 | klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); | ||
| 44 | |||
| 43 | if (dev->bus) | 45 | if (dev->bus) |
| 44 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, | 46 | blocking_notifier_call_chain(&dev->bus->p->bus_notifier, |
| 45 | BUS_NOTIFY_BOUND_DRIVER, dev); | 47 | BUS_NOTIFY_BOUND_DRIVER, dev); |
| 46 | |||
| 47 | klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); | ||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | static int driver_sysfs_add(struct device *dev) | 50 | static int driver_sysfs_add(struct device *dev) |
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 057cf11326bf..af0600143d1c 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/namei.h> | 20 | #include <linux/namei.h> |
| 21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
| 22 | #include <linux/shmem_fs.h> | 22 | #include <linux/shmem_fs.h> |
| 23 | #include <linux/ramfs.h> | ||
| 23 | #include <linux/cred.h> | 24 | #include <linux/cred.h> |
| 24 | #include <linux/sched.h> | 25 | #include <linux/sched.h> |
| 25 | #include <linux/init_task.h> | 26 | #include <linux/init_task.h> |
| @@ -45,7 +46,11 @@ __setup("devtmpfs.mount=", mount_param); | |||
| 45 | static int dev_get_sb(struct file_system_type *fs_type, int flags, | 46 | static int dev_get_sb(struct file_system_type *fs_type, int flags, |
| 46 | const char *dev_name, void *data, struct vfsmount *mnt) | 47 | const char *dev_name, void *data, struct vfsmount *mnt) |
| 47 | { | 48 | { |
| 49 | #ifdef CONFIG_TMPFS | ||
| 48 | return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt); | 50 | return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt); |
| 51 | #else | ||
| 52 | return get_sb_single(fs_type, flags, data, ramfs_fill_super, mnt); | ||
| 53 | #endif | ||
| 49 | } | 54 | } |
| 50 | 55 | ||
| 51 | static struct file_system_type dev_fs_type = { | 56 | static struct file_system_type dev_fs_type = { |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 985da11174e7..3f093b0dd217 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
| @@ -27,6 +27,52 @@ MODULE_AUTHOR("Manuel Estrada Sainz"); | |||
| 27 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); | 27 | MODULE_DESCRIPTION("Multi purpose firmware loading support"); |
| 28 | MODULE_LICENSE("GPL"); | 28 | MODULE_LICENSE("GPL"); |
| 29 | 29 | ||
| 30 | /* Builtin firmware support */ | ||
| 31 | |||
| 32 | #ifdef CONFIG_FW_LOADER | ||
| 33 | |||
| 34 | extern struct builtin_fw __start_builtin_fw[]; | ||
| 35 | extern struct builtin_fw __end_builtin_fw[]; | ||
| 36 | |||
| 37 | static bool fw_get_builtin_firmware(struct firmware *fw, const char *name) | ||
| 38 | { | ||
| 39 | struct builtin_fw *b_fw; | ||
| 40 | |||
| 41 | for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { | ||
| 42 | if (strcmp(name, b_fw->name) == 0) { | ||
| 43 | fw->size = b_fw->size; | ||
| 44 | fw->data = b_fw->data; | ||
| 45 | return true; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | return false; | ||
| 50 | } | ||
| 51 | |||
| 52 | static bool fw_is_builtin_firmware(const struct firmware *fw) | ||
| 53 | { | ||
| 54 | struct builtin_fw *b_fw; | ||
| 55 | |||
| 56 | for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) | ||
| 57 | if (fw->data == b_fw->data) | ||
| 58 | return true; | ||
| 59 | |||
| 60 | return false; | ||
| 61 | } | ||
| 62 | |||
| 63 | #else /* Module case - no builtin firmware support */ | ||
| 64 | |||
| 65 | static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name) | ||
| 66 | { | ||
| 67 | return false; | ||
| 68 | } | ||
| 69 | |||
| 70 | static inline bool fw_is_builtin_firmware(const struct firmware *fw) | ||
| 71 | { | ||
| 72 | return false; | ||
| 73 | } | ||
| 74 | #endif | ||
| 75 | |||
| 30 | enum { | 76 | enum { |
| 31 | FW_STATUS_LOADING, | 77 | FW_STATUS_LOADING, |
| 32 | FW_STATUS_DONE, | 78 | FW_STATUS_DONE, |
| @@ -40,7 +86,6 @@ static int loading_timeout = 60; /* In seconds */ | |||
| 40 | static DEFINE_MUTEX(fw_lock); | 86 | static DEFINE_MUTEX(fw_lock); |
| 41 | 87 | ||
| 42 | struct firmware_priv { | 88 | struct firmware_priv { |
| 43 | char *fw_id; | ||
| 44 | struct completion completion; | 89 | struct completion completion; |
| 45 | struct bin_attribute attr_data; | 90 | struct bin_attribute attr_data; |
| 46 | struct firmware *fw; | 91 | struct firmware *fw; |
| @@ -48,18 +93,11 @@ struct firmware_priv { | |||
| 48 | struct page **pages; | 93 | struct page **pages; |
| 49 | int nr_pages; | 94 | int nr_pages; |
| 50 | int page_array_size; | 95 | int page_array_size; |
| 51 | const char *vdata; | ||
| 52 | struct timer_list timeout; | 96 | struct timer_list timeout; |
| 97 | bool nowait; | ||
| 98 | char fw_id[]; | ||
| 53 | }; | 99 | }; |
| 54 | 100 | ||
| 55 | #ifdef CONFIG_FW_LOADER | ||
| 56 | extern struct builtin_fw __start_builtin_fw[]; | ||
| 57 | extern struct builtin_fw __end_builtin_fw[]; | ||
| 58 | #else /* Module case. Avoid ifdefs later; it'll all optimise out */ | ||
| 59 | static struct builtin_fw *__start_builtin_fw; | ||
| 60 | static struct builtin_fw *__end_builtin_fw; | ||
| 61 | #endif | ||
| 62 | |||
| 63 | static void | 101 | static void |
| 64 | fw_load_abort(struct firmware_priv *fw_priv) | 102 | fw_load_abort(struct firmware_priv *fw_priv) |
| 65 | { | 103 | { |
| @@ -100,9 +138,25 @@ firmware_timeout_store(struct class *class, | |||
| 100 | return count; | 138 | return count; |
| 101 | } | 139 | } |
| 102 | 140 | ||
| 103 | static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); | 141 | static struct class_attribute firmware_class_attrs[] = { |
| 142 | __ATTR(timeout, S_IWUSR | S_IRUGO, | ||
| 143 | firmware_timeout_show, firmware_timeout_store), | ||
| 144 | __ATTR_NULL | ||
| 145 | }; | ||
| 146 | |||
| 147 | static void fw_dev_release(struct device *dev) | ||
| 148 | { | ||
| 149 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
| 150 | int i; | ||
| 151 | |||
| 152 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
| 153 | __free_page(fw_priv->pages[i]); | ||
| 154 | kfree(fw_priv->pages); | ||
| 155 | kfree(fw_priv); | ||
| 156 | kfree(dev); | ||
| 104 | 157 | ||
| 105 | static void fw_dev_release(struct device *dev); | 158 | module_put(THIS_MODULE); |
| 159 | } | ||
| 106 | 160 | ||
| 107 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | 161 | static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 108 | { | 162 | { |
| @@ -112,12 +166,15 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 112 | return -ENOMEM; | 166 | return -ENOMEM; |
| 113 | if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) | 167 | if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) |
| 114 | return -ENOMEM; | 168 | return -ENOMEM; |
| 169 | if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait)) | ||
| 170 | return -ENOMEM; | ||
| 115 | 171 | ||
| 116 | return 0; | 172 | return 0; |
| 117 | } | 173 | } |
| 118 | 174 | ||
| 119 | static struct class firmware_class = { | 175 | static struct class firmware_class = { |
| 120 | .name = "firmware", | 176 | .name = "firmware", |
| 177 | .class_attrs = firmware_class_attrs, | ||
| 121 | .dev_uevent = firmware_uevent, | 178 | .dev_uevent = firmware_uevent, |
| 122 | .dev_release = fw_dev_release, | 179 | .dev_release = fw_dev_release, |
| 123 | }; | 180 | }; |
| @@ -130,6 +187,17 @@ static ssize_t firmware_loading_show(struct device *dev, | |||
| 130 | return sprintf(buf, "%d\n", loading); | 187 | return sprintf(buf, "%d\n", loading); |
| 131 | } | 188 | } |
| 132 | 189 | ||
| 190 | static void firmware_free_data(const struct firmware *fw) | ||
| 191 | { | ||
| 192 | int i; | ||
| 193 | vunmap(fw->data); | ||
| 194 | if (fw->pages) { | ||
| 195 | for (i = 0; i < PFN_UP(fw->size); i++) | ||
| 196 | __free_page(fw->pages[i]); | ||
| 197 | kfree(fw->pages); | ||
| 198 | } | ||
| 199 | } | ||
| 200 | |||
| 133 | /* Some architectures don't have PAGE_KERNEL_RO */ | 201 | /* Some architectures don't have PAGE_KERNEL_RO */ |
| 134 | #ifndef PAGE_KERNEL_RO | 202 | #ifndef PAGE_KERNEL_RO |
| 135 | #define PAGE_KERNEL_RO PAGE_KERNEL | 203 | #define PAGE_KERNEL_RO PAGE_KERNEL |
| @@ -162,21 +230,21 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
| 162 | mutex_unlock(&fw_lock); | 230 | mutex_unlock(&fw_lock); |
| 163 | break; | 231 | break; |
| 164 | } | 232 | } |
| 165 | vfree(fw_priv->fw->data); | 233 | firmware_free_data(fw_priv->fw); |
| 166 | fw_priv->fw->data = NULL; | 234 | memset(fw_priv->fw, 0, sizeof(struct firmware)); |
| 235 | /* If the pages are not owned by 'struct firmware' */ | ||
| 167 | for (i = 0; i < fw_priv->nr_pages; i++) | 236 | for (i = 0; i < fw_priv->nr_pages; i++) |
| 168 | __free_page(fw_priv->pages[i]); | 237 | __free_page(fw_priv->pages[i]); |
| 169 | kfree(fw_priv->pages); | 238 | kfree(fw_priv->pages); |
| 170 | fw_priv->pages = NULL; | 239 | fw_priv->pages = NULL; |
| 171 | fw_priv->page_array_size = 0; | 240 | fw_priv->page_array_size = 0; |
| 172 | fw_priv->nr_pages = 0; | 241 | fw_priv->nr_pages = 0; |
| 173 | fw_priv->fw->size = 0; | ||
| 174 | set_bit(FW_STATUS_LOADING, &fw_priv->status); | 242 | set_bit(FW_STATUS_LOADING, &fw_priv->status); |
| 175 | mutex_unlock(&fw_lock); | 243 | mutex_unlock(&fw_lock); |
| 176 | break; | 244 | break; |
| 177 | case 0: | 245 | case 0: |
| 178 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { | 246 | if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { |
| 179 | vfree(fw_priv->fw->data); | 247 | vunmap(fw_priv->fw->data); |
| 180 | fw_priv->fw->data = vmap(fw_priv->pages, | 248 | fw_priv->fw->data = vmap(fw_priv->pages, |
| 181 | fw_priv->nr_pages, | 249 | fw_priv->nr_pages, |
| 182 | 0, PAGE_KERNEL_RO); | 250 | 0, PAGE_KERNEL_RO); |
| @@ -184,7 +252,10 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
| 184 | dev_err(dev, "%s: vmap() failed\n", __func__); | 252 | dev_err(dev, "%s: vmap() failed\n", __func__); |
| 185 | goto err; | 253 | goto err; |
| 186 | } | 254 | } |
| 187 | /* Pages will be freed by vfree() */ | 255 | /* Pages are now owned by 'struct firmware' */ |
| 256 | fw_priv->fw->pages = fw_priv->pages; | ||
| 257 | fw_priv->pages = NULL; | ||
| 258 | |||
| 188 | fw_priv->page_array_size = 0; | 259 | fw_priv->page_array_size = 0; |
| 189 | fw_priv->nr_pages = 0; | 260 | fw_priv->nr_pages = 0; |
| 190 | complete(&fw_priv->completion); | 261 | complete(&fw_priv->completion); |
| @@ -207,8 +278,9 @@ static ssize_t firmware_loading_store(struct device *dev, | |||
| 207 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); | 278 | static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); |
| 208 | 279 | ||
| 209 | static ssize_t | 280 | static ssize_t |
| 210 | firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 281 | firmware_data_read(struct file *filp, struct kobject *kobj, |
| 211 | char *buffer, loff_t offset, size_t count) | 282 | struct bin_attribute *bin_attr, char *buffer, loff_t offset, |
| 283 | size_t count) | ||
| 212 | { | 284 | { |
| 213 | struct device *dev = to_dev(kobj); | 285 | struct device *dev = to_dev(kobj); |
| 214 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 286 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); |
| @@ -291,6 +363,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
| 291 | 363 | ||
| 292 | /** | 364 | /** |
| 293 | * firmware_data_write - write method for firmware | 365 | * firmware_data_write - write method for firmware |
| 366 | * @filp: open sysfs file | ||
| 294 | * @kobj: kobject for the device | 367 | * @kobj: kobject for the device |
| 295 | * @bin_attr: bin_attr structure | 368 | * @bin_attr: bin_attr structure |
| 296 | * @buffer: buffer being written | 369 | * @buffer: buffer being written |
| @@ -301,8 +374,9 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) | |||
| 301 | * the driver as a firmware image. | 374 | * the driver as a firmware image. |
| 302 | **/ | 375 | **/ |
| 303 | static ssize_t | 376 | static ssize_t |
| 304 | firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 377 | firmware_data_write(struct file* filp, struct kobject *kobj, |
| 305 | char *buffer, loff_t offset, size_t count) | 378 | struct bin_attribute *bin_attr, char *buffer, |
| 379 | loff_t offset, size_t count) | ||
| 306 | { | 380 | { |
| 307 | struct device *dev = to_dev(kobj); | 381 | struct device *dev = to_dev(kobj); |
| 308 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | 382 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); |
| @@ -353,21 +427,6 @@ static struct bin_attribute firmware_attr_data_tmpl = { | |||
| 353 | .write = firmware_data_write, | 427 | .write = firmware_data_write, |
| 354 | }; | 428 | }; |
| 355 | 429 | ||
| 356 | static void fw_dev_release(struct device *dev) | ||
| 357 | { | ||
| 358 | struct firmware_priv *fw_priv = dev_get_drvdata(dev); | ||
| 359 | int i; | ||
| 360 | |||
| 361 | for (i = 0; i < fw_priv->nr_pages; i++) | ||
| 362 | __free_page(fw_priv->pages[i]); | ||
| 363 | kfree(fw_priv->pages); | ||
| 364 | kfree(fw_priv->fw_id); | ||
| 365 | kfree(fw_priv); | ||
| 366 | kfree(dev); | ||
| 367 | |||
| 368 | module_put(THIS_MODULE); | ||
| 369 | } | ||
| 370 | |||
| 371 | static void | 430 | static void |
| 372 | firmware_class_timeout(u_long data) | 431 | firmware_class_timeout(u_long data) |
| 373 | { | 432 | { |
| @@ -379,8 +438,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
| 379 | struct device *device) | 438 | struct device *device) |
| 380 | { | 439 | { |
| 381 | int retval; | 440 | int retval; |
| 382 | struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), | 441 | struct firmware_priv *fw_priv = |
| 383 | GFP_KERNEL); | 442 | kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); |
| 384 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); | 443 | struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); |
| 385 | 444 | ||
| 386 | *dev_p = NULL; | 445 | *dev_p = NULL; |
| @@ -391,16 +450,9 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, | |||
| 391 | goto error_kfree; | 450 | goto error_kfree; |
| 392 | } | 451 | } |
| 393 | 452 | ||
| 453 | strcpy(fw_priv->fw_id, fw_name); | ||
| 394 | init_completion(&fw_priv->completion); | 454 | init_completion(&fw_priv->completion); |
| 395 | fw_priv->attr_data = firmware_attr_data_tmpl; | 455 | fw_priv->attr_data = firmware_attr_data_tmpl; |
| 396 | fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); | ||
| 397 | if (!fw_priv->fw_id) { | ||
| 398 | dev_err(device, "%s: Firmware name allocation failed\n", | ||
| 399 | __func__); | ||
| 400 | retval = -ENOMEM; | ||
| 401 | goto error_kfree; | ||
| 402 | } | ||
| 403 | |||
| 404 | fw_priv->timeout.function = firmware_class_timeout; | 456 | fw_priv->timeout.function = firmware_class_timeout; |
| 405 | fw_priv->timeout.data = (u_long) fw_priv; | 457 | fw_priv->timeout.data = (u_long) fw_priv; |
| 406 | init_timer(&fw_priv->timeout); | 458 | init_timer(&fw_priv->timeout); |
| @@ -427,7 +479,7 @@ error_kfree: | |||
| 427 | 479 | ||
| 428 | static int fw_setup_device(struct firmware *fw, struct device **dev_p, | 480 | static int fw_setup_device(struct firmware *fw, struct device **dev_p, |
| 429 | const char *fw_name, struct device *device, | 481 | const char *fw_name, struct device *device, |
| 430 | int uevent) | 482 | int uevent, bool nowait) |
| 431 | { | 483 | { |
| 432 | struct device *f_dev; | 484 | struct device *f_dev; |
| 433 | struct firmware_priv *fw_priv; | 485 | struct firmware_priv *fw_priv; |
| @@ -443,6 +495,8 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, | |||
| 443 | 495 | ||
| 444 | fw_priv = dev_get_drvdata(f_dev); | 496 | fw_priv = dev_get_drvdata(f_dev); |
| 445 | 497 | ||
| 498 | fw_priv->nowait = nowait; | ||
| 499 | |||
| 446 | fw_priv->fw = fw; | 500 | fw_priv->fw = fw; |
| 447 | sysfs_bin_attr_init(&fw_priv->attr_data); | 501 | sysfs_bin_attr_init(&fw_priv->attr_data); |
| 448 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); | 502 | retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); |
| @@ -470,12 +524,11 @@ out: | |||
| 470 | 524 | ||
| 471 | static int | 525 | static int |
| 472 | _request_firmware(const struct firmware **firmware_p, const char *name, | 526 | _request_firmware(const struct firmware **firmware_p, const char *name, |
| 473 | struct device *device, int uevent) | 527 | struct device *device, int uevent, bool nowait) |
| 474 | { | 528 | { |
| 475 | struct device *f_dev; | 529 | struct device *f_dev; |
| 476 | struct firmware_priv *fw_priv; | 530 | struct firmware_priv *fw_priv; |
| 477 | struct firmware *firmware; | 531 | struct firmware *firmware; |
| 478 | struct builtin_fw *builtin; | ||
| 479 | int retval; | 532 | int retval; |
| 480 | 533 | ||
| 481 | if (!firmware_p) | 534 | if (!firmware_p) |
| @@ -489,21 +542,16 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
| 489 | goto out; | 542 | goto out; |
| 490 | } | 543 | } |
| 491 | 544 | ||
| 492 | for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; | 545 | if (fw_get_builtin_firmware(firmware, name)) { |
| 493 | builtin++) { | 546 | dev_dbg(device, "firmware: using built-in firmware %s\n", name); |
| 494 | if (strcmp(name, builtin->name)) | ||
| 495 | continue; | ||
| 496 | dev_info(device, "firmware: using built-in firmware %s\n", | ||
| 497 | name); | ||
| 498 | firmware->size = builtin->size; | ||
| 499 | firmware->data = builtin->data; | ||
| 500 | return 0; | 547 | return 0; |
| 501 | } | 548 | } |
| 502 | 549 | ||
| 503 | if (uevent) | 550 | if (uevent) |
| 504 | dev_info(device, "firmware: requesting %s\n", name); | 551 | dev_dbg(device, "firmware: requesting %s\n", name); |
| 505 | 552 | ||
| 506 | retval = fw_setup_device(firmware, &f_dev, name, device, uevent); | 553 | retval = fw_setup_device(firmware, &f_dev, name, device, |
| 554 | uevent, nowait); | ||
| 507 | if (retval) | 555 | if (retval) |
| 508 | goto error_kfree_fw; | 556 | goto error_kfree_fw; |
| 509 | 557 | ||
| @@ -560,26 +608,18 @@ request_firmware(const struct firmware **firmware_p, const char *name, | |||
| 560 | struct device *device) | 608 | struct device *device) |
| 561 | { | 609 | { |
| 562 | int uevent = 1; | 610 | int uevent = 1; |
| 563 | return _request_firmware(firmware_p, name, device, uevent); | 611 | return _request_firmware(firmware_p, name, device, uevent, false); |
| 564 | } | 612 | } |
| 565 | 613 | ||
| 566 | /** | 614 | /** |
| 567 | * release_firmware: - release the resource associated with a firmware image | 615 | * release_firmware: - release the resource associated with a firmware image |
| 568 | * @fw: firmware resource to release | 616 | * @fw: firmware resource to release |
| 569 | **/ | 617 | **/ |
| 570 | void | 618 | void release_firmware(const struct firmware *fw) |
| 571 | release_firmware(const struct firmware *fw) | ||
| 572 | { | 619 | { |
| 573 | struct builtin_fw *builtin; | ||
| 574 | |||
| 575 | if (fw) { | 620 | if (fw) { |
| 576 | for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; | 621 | if (!fw_is_builtin_firmware(fw)) |
| 577 | builtin++) { | 622 | firmware_free_data(fw); |
| 578 | if (fw->data == builtin->data) | ||
| 579 | goto free_fw; | ||
| 580 | } | ||
| 581 | vfree(fw->data); | ||
| 582 | free_fw: | ||
| 583 | kfree(fw); | 623 | kfree(fw); |
| 584 | } | 624 | } |
| 585 | } | 625 | } |
| @@ -606,7 +646,7 @@ request_firmware_work_func(void *arg) | |||
| 606 | return 0; | 646 | return 0; |
| 607 | } | 647 | } |
| 608 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, | 648 | ret = _request_firmware(&fw, fw_work->name, fw_work->device, |
| 609 | fw_work->uevent); | 649 | fw_work->uevent, true); |
| 610 | 650 | ||
| 611 | fw_work->cont(fw, fw_work->context); | 651 | fw_work->cont(fw, fw_work->context); |
| 612 | 652 | ||
| @@ -670,26 +710,12 @@ request_firmware_nowait( | |||
| 670 | return 0; | 710 | return 0; |
| 671 | } | 711 | } |
| 672 | 712 | ||
| 673 | static int __init | 713 | static int __init firmware_class_init(void) |
| 674 | firmware_class_init(void) | ||
| 675 | { | 714 | { |
| 676 | int error; | 715 | return class_register(&firmware_class); |
| 677 | error = class_register(&firmware_class); | ||
| 678 | if (error) { | ||
| 679 | printk(KERN_ERR "%s: class_register failed\n", __func__); | ||
| 680 | return error; | ||
| 681 | } | ||
| 682 | error = class_create_file(&firmware_class, &class_attr_timeout); | ||
| 683 | if (error) { | ||
| 684 | printk(KERN_ERR "%s: class_create_file failed\n", | ||
| 685 | __func__); | ||
| 686 | class_unregister(&firmware_class); | ||
| 687 | } | ||
| 688 | return error; | ||
| 689 | |||
| 690 | } | 716 | } |
| 691 | static void __exit | 717 | |
| 692 | firmware_class_exit(void) | 718 | static void __exit firmware_class_exit(void) |
| 693 | { | 719 | { |
| 694 | class_unregister(&firmware_class); | 720 | class_unregister(&firmware_class); |
| 695 | } | 721 | } |
diff --git a/drivers/base/module.c b/drivers/base/module.c index f32f2f9b7be5..db930d3ee312 100644 --- a/drivers/base/module.c +++ b/drivers/base/module.c | |||
| @@ -15,12 +15,10 @@ static char *make_driver_name(struct device_driver *drv) | |||
| 15 | { | 15 | { |
| 16 | char *driver_name; | 16 | char *driver_name; |
| 17 | 17 | ||
| 18 | driver_name = kmalloc(strlen(drv->name) + strlen(drv->bus->name) + 2, | 18 | driver_name = kasprintf(GFP_KERNEL, "%s:%s", drv->bus->name, drv->name); |
| 19 | GFP_KERNEL); | ||
| 20 | if (!driver_name) | 19 | if (!driver_name) |
| 21 | return NULL; | 20 | return NULL; |
| 22 | 21 | ||
| 23 | sprintf(driver_name, "%s:%s", drv->bus->name, drv->name); | ||
| 24 | return driver_name; | 22 | return driver_name; |
| 25 | } | 23 | } |
| 26 | 24 | ||
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ada6397c23a5..4d99c8bdfedc 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
| @@ -735,7 +735,7 @@ static void platform_pm_complete(struct device *dev) | |||
| 735 | 735 | ||
| 736 | #ifdef CONFIG_SUSPEND | 736 | #ifdef CONFIG_SUSPEND |
| 737 | 737 | ||
| 738 | static int platform_pm_suspend(struct device *dev) | 738 | int __weak platform_pm_suspend(struct device *dev) |
| 739 | { | 739 | { |
| 740 | struct device_driver *drv = dev->driver; | 740 | struct device_driver *drv = dev->driver; |
| 741 | int ret = 0; | 741 | int ret = 0; |
| @@ -753,7 +753,7 @@ static int platform_pm_suspend(struct device *dev) | |||
| 753 | return ret; | 753 | return ret; |
| 754 | } | 754 | } |
| 755 | 755 | ||
| 756 | static int platform_pm_suspend_noirq(struct device *dev) | 756 | int __weak platform_pm_suspend_noirq(struct device *dev) |
| 757 | { | 757 | { |
| 758 | struct device_driver *drv = dev->driver; | 758 | struct device_driver *drv = dev->driver; |
| 759 | int ret = 0; | 759 | int ret = 0; |
| @@ -769,7 +769,7 @@ static int platform_pm_suspend_noirq(struct device *dev) | |||
| 769 | return ret; | 769 | return ret; |
| 770 | } | 770 | } |
| 771 | 771 | ||
| 772 | static int platform_pm_resume(struct device *dev) | 772 | int __weak platform_pm_resume(struct device *dev) |
| 773 | { | 773 | { |
| 774 | struct device_driver *drv = dev->driver; | 774 | struct device_driver *drv = dev->driver; |
| 775 | int ret = 0; | 775 | int ret = 0; |
| @@ -787,7 +787,7 @@ static int platform_pm_resume(struct device *dev) | |||
| 787 | return ret; | 787 | return ret; |
| 788 | } | 788 | } |
| 789 | 789 | ||
| 790 | static int platform_pm_resume_noirq(struct device *dev) | 790 | int __weak platform_pm_resume_noirq(struct device *dev) |
| 791 | { | 791 | { |
| 792 | struct device_driver *drv = dev->driver; | 792 | struct device_driver *drv = dev->driver; |
| 793 | int ret = 0; | 793 | int ret = 0; |
