aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Kconfig7
-rw-r--r--drivers/base/attribute_container.c2
-rw-r--r--drivers/base/bus.c14
-rw-r--r--drivers/base/core.c8
-rw-r--r--drivers/base/devres.c4
-rw-r--r--drivers/base/firmware_class.c52
-rw-r--r--drivers/base/platform.c4
7 files changed, 53 insertions, 38 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index b34b5cda5ae1..c8b453939da2 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -57,7 +57,7 @@ config DEVTMPFS_MOUNT
57 on the rootfs is completely empty. 57 on the rootfs is completely empty.
58 58
59config STANDALONE 59config STANDALONE
60 bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL 60 bool "Select only drivers that don't need compile-time external firmware"
61 default y 61 default y
62 help 62 help
63 Select this option if you don't have magic firmware for drivers that 63 Select this option if you don't have magic firmware for drivers that
@@ -185,7 +185,6 @@ config DMA_SHARED_BUFFER
185 bool 185 bool
186 default n 186 default n
187 select ANON_INODES 187 select ANON_INODES
188 depends on EXPERIMENTAL
189 help 188 help
190 This option enables the framework for buffer-sharing between 189 This option enables the framework for buffer-sharing between
191 multiple drivers. A buffer is associated with a file using driver 190 multiple drivers. A buffer is associated with a file using driver
@@ -193,8 +192,8 @@ config DMA_SHARED_BUFFER
193 driver. 192 driver.
194 193
195config CMA 194config CMA
196 bool "Contiguous Memory Allocator (EXPERIMENTAL)" 195 bool "Contiguous Memory Allocator"
197 depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK && EXPERIMENTAL 196 depends on HAVE_DMA_CONTIGUOUS && HAVE_MEMBLOCK
198 select MIGRATION 197 select MIGRATION
199 select MEMORY_ISOLATION 198 select MEMORY_ISOLATION
200 help 199 help
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index 8fc200b2e2c0..d78b204e65c1 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -158,7 +158,7 @@ attribute_container_add_device(struct device *dev,
158 158
159 ic = kzalloc(sizeof(*ic), GFP_KERNEL); 159 ic = kzalloc(sizeof(*ic), GFP_KERNEL);
160 if (!ic) { 160 if (!ic) {
161 dev_printk(KERN_ERR, dev, "failed to allocate class container\n"); 161 dev_err(dev, "failed to allocate class container\n");
162 continue; 162 continue;
163 } 163 }
164 164
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 181ed2660b33..24eb07868344 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -164,8 +164,6 @@ static const struct kset_uevent_ops bus_uevent_ops = {
164 164
165static struct kset *bus_kset; 165static struct kset *bus_kset;
166 166
167
168#ifdef CONFIG_HOTPLUG
169/* Manually detach a device from its associated driver. */ 167/* Manually detach a device from its associated driver. */
170static ssize_t driver_unbind(struct device_driver *drv, 168static ssize_t driver_unbind(struct device_driver *drv,
171 const char *buf, size_t count) 169 const char *buf, size_t count)
@@ -252,7 +250,6 @@ static ssize_t store_drivers_probe(struct bus_type *bus,
252 return -EINVAL; 250 return -EINVAL;
253 return count; 251 return count;
254} 252}
255#endif
256 253
257static struct device *next_device(struct klist_iter *i) 254static struct device *next_device(struct klist_iter *i)
258{ 255{
@@ -618,11 +615,6 @@ static void driver_remove_attrs(struct bus_type *bus,
618 } 615 }
619} 616}
620 617
621#ifdef CONFIG_HOTPLUG
622/*
623 * Thanks to drivers making their tables __devinit, we can't allow manual
624 * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled.
625 */
626static int __must_check add_bind_files(struct device_driver *drv) 618static int __must_check add_bind_files(struct device_driver *drv)
627{ 619{
628 int ret; 620 int ret;
@@ -666,12 +658,6 @@ static void remove_probe_files(struct bus_type *bus)
666 bus_remove_file(bus, &bus_attr_drivers_autoprobe); 658 bus_remove_file(bus, &bus_attr_drivers_autoprobe);
667 bus_remove_file(bus, &bus_attr_drivers_probe); 659 bus_remove_file(bus, &bus_attr_drivers_probe);
668} 660}
669#else
670static inline int add_bind_files(struct device_driver *drv) { return 0; }
671static inline void remove_bind_files(struct device_driver *drv) {}
672static inline int add_probe_files(struct bus_type *bus) { return 0; }
673static inline void remove_probe_files(struct bus_type *bus) {}
674#endif
675 661
676static ssize_t driver_uevent_store(struct device_driver *drv, 662static ssize_t driver_uevent_store(struct device_driver *drv,
677 const char *buf, size_t count) 663 const char *buf, size_t count)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 150a41580fad..417913974df8 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1399,7 +1399,7 @@ struct root_device {
1399 struct module *owner; 1399 struct module *owner;
1400}; 1400};
1401 1401
1402inline struct root_device *to_root_device(struct device *d) 1402static inline struct root_device *to_root_device(struct device *d)
1403{ 1403{
1404 return container_of(d, struct root_device, dev); 1404 return container_of(d, struct root_device, dev);
1405} 1405}
@@ -1840,10 +1840,12 @@ void device_shutdown(void)
1840 pm_runtime_barrier(dev); 1840 pm_runtime_barrier(dev);
1841 1841
1842 if (dev->bus && dev->bus->shutdown) { 1842 if (dev->bus && dev->bus->shutdown) {
1843 dev_dbg(dev, "shutdown\n"); 1843 if (initcall_debug)
1844 dev_info(dev, "shutdown\n");
1844 dev->bus->shutdown(dev); 1845 dev->bus->shutdown(dev);
1845 } else if (dev->driver && dev->driver->shutdown) { 1846 } else if (dev->driver && dev->driver->shutdown) {
1846 dev_dbg(dev, "shutdown\n"); 1847 if (initcall_debug)
1848 dev_info(dev, "shutdown\n");
1847 dev->driver->shutdown(dev); 1849 dev->driver->shutdown(dev);
1848 } 1850 }
1849 1851
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 8731979d668a..668390664764 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -50,8 +50,8 @@ static void devres_log(struct device *dev, struct devres_node *node,
50 const char *op) 50 const char *op)
51{ 51{
52 if (unlikely(log_devres)) 52 if (unlikely(log_devres))
53 dev_printk(KERN_ERR, dev, "DEVRES %3s %p %s (%lu bytes)\n", 53 dev_err(dev, "DEVRES %3s %p %s (%lu bytes)\n",
54 op, node, node->name, (unsigned long)node->size); 54 op, node, node->name, (unsigned long)node->size);
55} 55}
56#else /* CONFIG_DEBUG_DEVRES */ 56#else /* CONFIG_DEBUG_DEVRES */
57#define set_node_dbginfo(node, n, s) do {} while (0) 57#define set_node_dbginfo(node, n, s) do {} while (0)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8945f4e489ed..d81460309182 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -143,7 +143,7 @@ struct fw_cache_entry {
143}; 143};
144 144
145struct firmware_priv { 145struct firmware_priv {
146 struct timer_list timeout; 146 struct delayed_work timeout_work;
147 bool nowait; 147 bool nowait;
148 struct device dev; 148 struct device dev;
149 struct firmware_buf *buf; 149 struct firmware_buf *buf;
@@ -246,7 +246,6 @@ static void __fw_free_buf(struct kref *ref)
246 __func__, buf->fw_id, buf, buf->data, 246 __func__, buf->fw_id, buf, buf->data,
247 (unsigned int)buf->size); 247 (unsigned int)buf->size);
248 248
249 spin_lock(&fwc->lock);
250 list_del(&buf->list); 249 list_del(&buf->list);
251 spin_unlock(&fwc->lock); 250 spin_unlock(&fwc->lock);
252 251
@@ -263,19 +262,32 @@ static void __fw_free_buf(struct kref *ref)
263 262
264static void fw_free_buf(struct firmware_buf *buf) 263static void fw_free_buf(struct firmware_buf *buf)
265{ 264{
266 kref_put(&buf->ref, __fw_free_buf); 265 struct firmware_cache *fwc = buf->fwc;
266 spin_lock(&fwc->lock);
267 if (!kref_put(&buf->ref, __fw_free_buf))
268 spin_unlock(&fwc->lock);
267} 269}
268 270
269/* direct firmware loading support */ 271/* direct firmware loading support */
270static const char *fw_path[] = { 272static char fw_path_para[256];
273static const char * const fw_path[] = {
274 fw_path_para,
271 "/lib/firmware/updates/" UTS_RELEASE, 275 "/lib/firmware/updates/" UTS_RELEASE,
272 "/lib/firmware/updates", 276 "/lib/firmware/updates",
273 "/lib/firmware/" UTS_RELEASE, 277 "/lib/firmware/" UTS_RELEASE,
274 "/lib/firmware" 278 "/lib/firmware"
275}; 279};
276 280
281/*
282 * Typical usage is that passing 'firmware_class.path=$CUSTOMIZED_PATH'
283 * from kernel command line because firmware_class is generally built in
284 * kernel instead of module.
285 */
286module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
287MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
288
277/* Don't inline this: 'struct kstat' is biggish */ 289/* Don't inline this: 'struct kstat' is biggish */
278static noinline long fw_file_size(struct file *file) 290static noinline_for_stack long fw_file_size(struct file *file)
279{ 291{
280 struct kstat st; 292 struct kstat st;
281 if (vfs_getattr(file->f_path.mnt, file->f_path.dentry, &st)) 293 if (vfs_getattr(file->f_path.mnt, file->f_path.dentry, &st))
@@ -315,6 +327,11 @@ static bool fw_get_filesystem_firmware(struct firmware_buf *buf)
315 327
316 for (i = 0; i < ARRAY_SIZE(fw_path); i++) { 328 for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
317 struct file *file; 329 struct file *file;
330
331 /* skip the unset customized path */
332 if (!fw_path[i][0])
333 continue;
334
318 snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id); 335 snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id);
319 336
320 file = filp_open(path, O_RDONLY, 0); 337 file = filp_open(path, O_RDONLY, 0);
@@ -667,11 +684,18 @@ static struct bin_attribute firmware_attr_data = {
667 .write = firmware_data_write, 684 .write = firmware_data_write,
668}; 685};
669 686
670static void firmware_class_timeout(u_long data) 687static void firmware_class_timeout_work(struct work_struct *work)
671{ 688{
672 struct firmware_priv *fw_priv = (struct firmware_priv *) data; 689 struct firmware_priv *fw_priv = container_of(work,
690 struct firmware_priv, timeout_work.work);
673 691
692 mutex_lock(&fw_lock);
693 if (test_bit(FW_STATUS_DONE, &(fw_priv->buf->status))) {
694 mutex_unlock(&fw_lock);
695 return;
696 }
674 fw_load_abort(fw_priv); 697 fw_load_abort(fw_priv);
698 mutex_unlock(&fw_lock);
675} 699}
676 700
677static struct firmware_priv * 701static struct firmware_priv *
@@ -690,8 +714,8 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
690 714
691 fw_priv->nowait = nowait; 715 fw_priv->nowait = nowait;
692 fw_priv->fw = firmware; 716 fw_priv->fw = firmware;
693 setup_timer(&fw_priv->timeout, 717 INIT_DELAYED_WORK(&fw_priv->timeout_work,
694 firmware_class_timeout, (u_long) fw_priv); 718 firmware_class_timeout_work);
695 719
696 f_dev = &fw_priv->dev; 720 f_dev = &fw_priv->dev;
697 721
@@ -858,7 +882,9 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
858 dev_dbg(f_dev->parent, "firmware: direct-loading" 882 dev_dbg(f_dev->parent, "firmware: direct-loading"
859 " firmware %s\n", buf->fw_id); 883 " firmware %s\n", buf->fw_id);
860 884
885 mutex_lock(&fw_lock);
861 set_bit(FW_STATUS_DONE, &buf->status); 886 set_bit(FW_STATUS_DONE, &buf->status);
887 mutex_unlock(&fw_lock);
862 complete_all(&buf->completion); 888 complete_all(&buf->completion);
863 direct_load = 1; 889 direct_load = 1;
864 goto handle_fw; 890 goto handle_fw;
@@ -894,15 +920,14 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
894 dev_set_uevent_suppress(f_dev, false); 920 dev_set_uevent_suppress(f_dev, false);
895 dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id); 921 dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
896 if (timeout != MAX_SCHEDULE_TIMEOUT) 922 if (timeout != MAX_SCHEDULE_TIMEOUT)
897 mod_timer(&fw_priv->timeout, 923 schedule_delayed_work(&fw_priv->timeout_work, timeout);
898 round_jiffies_up(jiffies + timeout));
899 924
900 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); 925 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
901 } 926 }
902 927
903 wait_for_completion(&buf->completion); 928 wait_for_completion(&buf->completion);
904 929
905 del_timer_sync(&fw_priv->timeout); 930 cancel_delayed_work_sync(&fw_priv->timeout_work);
906 931
907handle_fw: 932handle_fw:
908 mutex_lock(&fw_lock); 933 mutex_lock(&fw_lock);
@@ -963,6 +988,9 @@ err_put_dev:
963 * firmware image for this or any other device. 988 * firmware image for this or any other device.
964 * 989 *
965 * Caller must hold the reference count of @device. 990 * Caller must hold the reference count of @device.
991 *
992 * The function can be called safely inside device's suspend and
993 * resume callback.
966 **/ 994 **/
967int 995int
968request_firmware(const struct firmware **firmware_p, const char *name, 996request_firmware(const struct firmware **firmware_p, const char *name,
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b2ee3bcd5a41..c0b8df38402b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -45,7 +45,7 @@ EXPORT_SYMBOL_GPL(platform_bus);
45 * be setup before the platform_notifier is called. So if a user needs to 45 * be setup before the platform_notifier is called. So if a user needs to
46 * manipulate any relevant information in the pdev_archdata they can do: 46 * manipulate any relevant information in the pdev_archdata they can do:
47 * 47 *
48 * platform_devic_alloc() 48 * platform_device_alloc()
49 * ... manipulate ... 49 * ... manipulate ...
50 * platform_device_add() 50 * platform_device_add()
51 * 51 *
@@ -123,7 +123,7 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
123EXPORT_SYMBOL_GPL(platform_get_resource_byname); 123EXPORT_SYMBOL_GPL(platform_get_resource_byname);
124 124
125/** 125/**
126 * platform_get_irq - get an IRQ for a device 126 * platform_get_irq_byname - get an IRQ for a device by name
127 * @dev: platform device 127 * @dev: platform device
128 * @name: IRQ name 128 * @name: IRQ name
129 */ 129 */