diff options
-rw-r--r-- | Documentation/driver-model/devres.txt | 5 | ||||
-rw-r--r-- | Documentation/sysfs-rules.txt | 21 | ||||
-rw-r--r-- | MAINTAINERS | 7 | ||||
-rw-r--r-- | drivers/base/Kconfig | 21 | ||||
-rw-r--r-- | drivers/base/Makefile | 1 | ||||
-rw-r--r-- | drivers/base/attribute_container.c | 14 | ||||
-rw-r--r-- | drivers/base/core.c | 9 | ||||
-rw-r--r-- | drivers/base/dd.c | 2 | ||||
-rw-r--r-- | drivers/base/devcoredump.c | 265 | ||||
-rw-r--r-- | drivers/base/devres.c | 15 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 3 | ||||
-rw-r--r-- | drivers/base/node.c | 1 | ||||
-rw-r--r-- | include/linux/devcoredump.h | 35 | ||||
-rw-r--r-- | include/linux/device.h | 4 | ||||
-rw-r--r-- | include/linux/dynamic_debug.h | 12 | ||||
-rw-r--r-- | lib/dynamic_debug.c | 50 |
16 files changed, 411 insertions, 54 deletions
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index d14710b04439..40677443c0c5 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -281,7 +281,9 @@ IOMAP | |||
281 | 281 | ||
282 | IRQ | 282 | IRQ |
283 | devm_free_irq() | 283 | devm_free_irq() |
284 | devm_request_any_context_irq() | ||
284 | devm_request_irq() | 285 | devm_request_irq() |
286 | devm_request_threaded_irq() | ||
285 | 287 | ||
286 | MDIO | 288 | MDIO |
287 | devm_mdiobus_alloc() | 289 | devm_mdiobus_alloc() |
@@ -291,11 +293,14 @@ MDIO | |||
291 | MEM | 293 | MEM |
292 | devm_free_pages() | 294 | devm_free_pages() |
293 | devm_get_free_pages() | 295 | devm_get_free_pages() |
296 | devm_kasprintf() | ||
294 | devm_kcalloc() | 297 | devm_kcalloc() |
295 | devm_kfree() | 298 | devm_kfree() |
296 | devm_kmalloc() | 299 | devm_kmalloc() |
297 | devm_kmalloc_array() | 300 | devm_kmalloc_array() |
298 | devm_kmemdup() | 301 | devm_kmemdup() |
302 | devm_kstrdup() | ||
303 | devm_kvasprintf() | ||
299 | devm_kzalloc() | 304 | devm_kzalloc() |
300 | 305 | ||
301 | PCI | 306 | PCI |
diff --git a/Documentation/sysfs-rules.txt b/Documentation/sysfs-rules.txt index a5f985ee1822..ce60ffa94d2d 100644 --- a/Documentation/sysfs-rules.txt +++ b/Documentation/sysfs-rules.txt | |||
@@ -161,3 +161,24 @@ versions of the sysfs interface. | |||
161 | the device that matches the expected subsystem. Depending on a specific | 161 | the device that matches the expected subsystem. Depending on a specific |
162 | position of a parent device or exposing relative paths using "../" to | 162 | position of a parent device or exposing relative paths using "../" to |
163 | access the chain of parents is a bug in the application. | 163 | access the chain of parents is a bug in the application. |
164 | |||
165 | - When reading and writing sysfs device attribute files, avoid dependency | ||
166 | on specific error codes wherever possible. This minimizes coupling to | ||
167 | the error handling implementation within the kernel. | ||
168 | |||
169 | In general, failures to read or write sysfs device attributes shall | ||
170 | propagate errors wherever possible. Common errors include, but are not | ||
171 | limited to: | ||
172 | |||
173 | -EIO: The read or store operation is not supported, typically returned by | ||
174 | the sysfs system itself if the read or store pointer is NULL. | ||
175 | |||
176 | -ENXIO: The read or store operation failed | ||
177 | |||
178 | Error codes will not be changed without good reason, and should a change | ||
179 | to error codes result in user-space breakage, it will be fixed, or the | ||
180 | the offending change will be reverted. | ||
181 | |||
182 | Userspace applications can, however, expect the format and contents of | ||
183 | the attribute files to remain consistent in the absence of a version | ||
184 | attribute change in the context of a given attribute. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 1297bc58d441..27bd1cc05a6b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2877,6 +2877,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git | |||
2877 | S: Maintained | 2877 | S: Maintained |
2878 | F: drivers/usb/dwc3/ | 2878 | F: drivers/usb/dwc3/ |
2879 | 2879 | ||
2880 | DEVICE COREDUMP (DEV_COREDUMP) | ||
2881 | M: Johannes Berg <johannes@sipsolutions.net> | ||
2882 | L: linux-kernel@vger.kernel.org | ||
2883 | S: Maintained | ||
2884 | F: drivers/base/devcoredump.c | ||
2885 | F: include/linux/devcoredump.h | ||
2886 | |||
2880 | DEVICE FREQUENCY (DEVFREQ) | 2887 | DEVICE FREQUENCY (DEVFREQ) |
2881 | M: MyungJoo Ham <myungjoo.ham@samsung.com> | 2888 | M: MyungJoo Ham <myungjoo.ham@samsung.com> |
2882 | M: Kyungmin Park <kyungmin.park@samsung.com> | 2889 | M: Kyungmin Park <kyungmin.park@samsung.com> |
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 4e7f0ff83ae7..134f763d90fd 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig | |||
@@ -165,6 +165,27 @@ config FW_LOADER_USER_HELPER_FALLBACK | |||
165 | 165 | ||
166 | If you are unsure about this, say N here. | 166 | If you are unsure about this, say N here. |
167 | 167 | ||
168 | config WANT_DEV_COREDUMP | ||
169 | bool | ||
170 | help | ||
171 | Drivers should "select" this option if they desire to use the | ||
172 | device coredump mechanism. | ||
173 | |||
174 | config DISABLE_DEV_COREDUMP | ||
175 | bool "Disable device coredump" if EXPERT | ||
176 | help | ||
177 | Disable the device coredump mechanism despite drivers wanting to | ||
178 | use it; this allows for more sensitive systems or systems that | ||
179 | don't want to ever access the information to not have the code, | ||
180 | nor keep any data. | ||
181 | |||
182 | If unsure, say N. | ||
183 | |||
184 | config DEV_COREDUMP | ||
185 | bool | ||
186 | default y if WANT_DEV_COREDUMP | ||
187 | depends on !DISABLE_DEV_COREDUMP | ||
188 | |||
168 | config DEBUG_DRIVER | 189 | config DEBUG_DRIVER |
169 | bool "Driver Core verbose debug messages" | 190 | bool "Driver Core verbose debug messages" |
170 | depends on DEBUG_KERNEL | 191 | depends on DEBUG_KERNEL |
diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 4aab26ec0292..6922cd6850a2 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile | |||
@@ -21,6 +21,7 @@ obj-$(CONFIG_SYS_HYPERVISOR) += hypervisor.o | |||
21 | obj-$(CONFIG_REGMAP) += regmap/ | 21 | obj-$(CONFIG_REGMAP) += regmap/ |
22 | obj-$(CONFIG_SOC_BUS) += soc.o | 22 | obj-$(CONFIG_SOC_BUS) += soc.o |
23 | obj-$(CONFIG_PINCTRL) += pinctrl.o | 23 | obj-$(CONFIG_PINCTRL) += pinctrl.o |
24 | obj-$(CONFIG_DEV_COREDUMP) += devcoredump.o | ||
24 | 25 | ||
25 | ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG | 26 | ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG |
26 | 27 | ||
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index b84ca8f13f9e..3ead3af4be61 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c | |||
@@ -74,9 +74,9 @@ int | |||
74 | attribute_container_register(struct attribute_container *cont) | 74 | attribute_container_register(struct attribute_container *cont) |
75 | { | 75 | { |
76 | INIT_LIST_HEAD(&cont->node); | 76 | INIT_LIST_HEAD(&cont->node); |
77 | klist_init(&cont->containers,internal_container_klist_get, | 77 | klist_init(&cont->containers, internal_container_klist_get, |
78 | internal_container_klist_put); | 78 | internal_container_klist_put); |
79 | 79 | ||
80 | mutex_lock(&attribute_container_mutex); | 80 | mutex_lock(&attribute_container_mutex); |
81 | list_add_tail(&cont->node, &attribute_container_list); | 81 | list_add_tail(&cont->node, &attribute_container_list); |
82 | mutex_unlock(&attribute_container_mutex); | 82 | mutex_unlock(&attribute_container_mutex); |
@@ -104,14 +104,14 @@ attribute_container_unregister(struct attribute_container *cont) | |||
104 | spin_unlock(&cont->containers.k_lock); | 104 | spin_unlock(&cont->containers.k_lock); |
105 | mutex_unlock(&attribute_container_mutex); | 105 | mutex_unlock(&attribute_container_mutex); |
106 | return retval; | 106 | return retval; |
107 | 107 | ||
108 | } | 108 | } |
109 | EXPORT_SYMBOL_GPL(attribute_container_unregister); | 109 | EXPORT_SYMBOL_GPL(attribute_container_unregister); |
110 | 110 | ||
111 | /* private function used as class release */ | 111 | /* private function used as class release */ |
112 | static void attribute_container_release(struct device *classdev) | 112 | static void attribute_container_release(struct device *classdev) |
113 | { | 113 | { |
114 | struct internal_container *ic | 114 | struct internal_container *ic |
115 | = container_of(classdev, struct internal_container, classdev); | 115 | = container_of(classdev, struct internal_container, classdev); |
116 | struct device *dev = classdev->parent; | 116 | struct device *dev = classdev->parent; |
117 | 117 | ||
@@ -184,8 +184,8 @@ attribute_container_add_device(struct device *dev, | |||
184 | struct klist_node *n = klist_next(iter); \ | 184 | struct klist_node *n = klist_next(iter); \ |
185 | n ? container_of(n, typeof(*pos), member) : \ | 185 | n ? container_of(n, typeof(*pos), member) : \ |
186 | ({ klist_iter_exit(iter) ; NULL; }); \ | 186 | ({ klist_iter_exit(iter) ; NULL; }); \ |
187 | }) ) != NULL; ) | 187 | })) != NULL;) |
188 | 188 | ||
189 | 189 | ||
190 | /** | 190 | /** |
191 | * attribute_container_remove_device - make device eligible for removal. | 191 | * attribute_container_remove_device - make device eligible for removal. |
@@ -247,7 +247,7 @@ attribute_container_remove_device(struct device *dev, | |||
247 | * container, then use attribute_container_trigger() instead. | 247 | * container, then use attribute_container_trigger() instead. |
248 | */ | 248 | */ |
249 | void | 249 | void |
250 | attribute_container_device_trigger(struct device *dev, | 250 | attribute_container_device_trigger(struct device *dev, |
251 | int (*fn)(struct attribute_container *, | 251 | int (*fn)(struct attribute_container *, |
252 | struct device *, | 252 | struct device *, |
253 | struct device *)) | 253 | struct device *)) |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 20da3ad1696b..28b808c73e8e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -2007,6 +2007,8 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) | |||
2007 | return 0; | 2007 | return 0; |
2008 | 2008 | ||
2009 | pos += snprintf(hdr + pos, hdrlen - pos, "SUBSYSTEM=%s", subsys); | 2009 | pos += snprintf(hdr + pos, hdrlen - pos, "SUBSYSTEM=%s", subsys); |
2010 | if (pos >= hdrlen) | ||
2011 | goto overflow; | ||
2010 | 2012 | ||
2011 | /* | 2013 | /* |
2012 | * Add device identifier DEVICE=: | 2014 | * Add device identifier DEVICE=: |
@@ -2038,7 +2040,14 @@ create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) | |||
2038 | "DEVICE=+%s:%s", subsys, dev_name(dev)); | 2040 | "DEVICE=+%s:%s", subsys, dev_name(dev)); |
2039 | } | 2041 | } |
2040 | 2042 | ||
2043 | if (pos >= hdrlen) | ||
2044 | goto overflow; | ||
2045 | |||
2041 | return pos; | 2046 | return pos; |
2047 | |||
2048 | overflow: | ||
2049 | dev_WARN(dev, "device/subsystem name too long"); | ||
2050 | return 0; | ||
2042 | } | 2051 | } |
2043 | 2052 | ||
2044 | int dev_vprintk_emit(int level, const struct device *dev, | 2053 | int dev_vprintk_emit(int level, const struct device *dev, |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index e4ffbcf2f519..cdc779cf79a3 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -54,7 +54,7 @@ static LIST_HEAD(deferred_probe_active_list); | |||
54 | static struct workqueue_struct *deferred_wq; | 54 | static struct workqueue_struct *deferred_wq; |
55 | static atomic_t deferred_trigger_count = ATOMIC_INIT(0); | 55 | static atomic_t deferred_trigger_count = ATOMIC_INIT(0); |
56 | 56 | ||
57 | /** | 57 | /* |
58 | * deferred_probe_work_func() - Retry probing devices in the active list. | 58 | * deferred_probe_work_func() - Retry probing devices in the active list. |
59 | */ | 59 | */ |
60 | static void deferred_probe_work_func(struct work_struct *work) | 60 | static void deferred_probe_work_func(struct work_struct *work) |
diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c new file mode 100644 index 000000000000..96614b04544c --- /dev/null +++ b/drivers/base/devcoredump.c | |||
@@ -0,0 +1,265 @@ | |||
1 | /* | ||
2 | * This file is provided under the GPLv2 license. | ||
3 | * | ||
4 | * GPL LICENSE SUMMARY | ||
5 | * | ||
6 | * Copyright(c) 2014 Intel Mobile Communications GmbH | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of version 2 of the GNU General Public License as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * The full GNU General Public License is included in this distribution | ||
18 | * in the file called COPYING. | ||
19 | * | ||
20 | * Contact Information: | ||
21 | * Intel Linux Wireless <ilw@linux.intel.com> | ||
22 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
23 | * | ||
24 | * Author: Johannes Berg <johannes@sipsolutions.net> | ||
25 | */ | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/devcoredump.h> | ||
29 | #include <linux/list.h> | ||
30 | #include <linux/slab.h> | ||
31 | #include <linux/fs.h> | ||
32 | #include <linux/workqueue.h> | ||
33 | |||
34 | /* if data isn't read by userspace after 5 minutes then delete it */ | ||
35 | #define DEVCD_TIMEOUT (HZ * 60 * 5) | ||
36 | |||
37 | struct devcd_entry { | ||
38 | struct device devcd_dev; | ||
39 | const void *data; | ||
40 | size_t datalen; | ||
41 | struct module *owner; | ||
42 | ssize_t (*read)(char *buffer, loff_t offset, size_t count, | ||
43 | const void *data, size_t datalen); | ||
44 | void (*free)(const void *data); | ||
45 | struct delayed_work del_wk; | ||
46 | struct device *failing_dev; | ||
47 | }; | ||
48 | |||
49 | static struct devcd_entry *dev_to_devcd(struct device *dev) | ||
50 | { | ||
51 | return container_of(dev, struct devcd_entry, devcd_dev); | ||
52 | } | ||
53 | |||
54 | static void devcd_dev_release(struct device *dev) | ||
55 | { | ||
56 | struct devcd_entry *devcd = dev_to_devcd(dev); | ||
57 | |||
58 | devcd->free(devcd->data); | ||
59 | module_put(devcd->owner); | ||
60 | |||
61 | /* | ||
62 | * this seems racy, but I don't see a notifier or such on | ||
63 | * a struct device to know when it goes away? | ||
64 | */ | ||
65 | if (devcd->failing_dev->kobj.sd) | ||
66 | sysfs_delete_link(&devcd->failing_dev->kobj, &dev->kobj, | ||
67 | "devcoredump"); | ||
68 | |||
69 | put_device(devcd->failing_dev); | ||
70 | kfree(devcd); | ||
71 | } | ||
72 | |||
73 | static void devcd_del(struct work_struct *wk) | ||
74 | { | ||
75 | struct devcd_entry *devcd; | ||
76 | |||
77 | devcd = container_of(wk, struct devcd_entry, del_wk.work); | ||
78 | |||
79 | device_del(&devcd->devcd_dev); | ||
80 | put_device(&devcd->devcd_dev); | ||
81 | } | ||
82 | |||
83 | static ssize_t devcd_data_read(struct file *filp, struct kobject *kobj, | ||
84 | struct bin_attribute *bin_attr, | ||
85 | char *buffer, loff_t offset, size_t count) | ||
86 | { | ||
87 | struct device *dev = kobj_to_dev(kobj); | ||
88 | struct devcd_entry *devcd = dev_to_devcd(dev); | ||
89 | |||
90 | return devcd->read(buffer, offset, count, devcd->data, devcd->datalen); | ||
91 | } | ||
92 | |||
93 | static ssize_t devcd_data_write(struct file *filp, struct kobject *kobj, | ||
94 | struct bin_attribute *bin_attr, | ||
95 | char *buffer, loff_t offset, size_t count) | ||
96 | { | ||
97 | struct device *dev = kobj_to_dev(kobj); | ||
98 | struct devcd_entry *devcd = dev_to_devcd(dev); | ||
99 | |||
100 | mod_delayed_work(system_wq, &devcd->del_wk, 0); | ||
101 | |||
102 | return count; | ||
103 | } | ||
104 | |||
105 | static struct bin_attribute devcd_attr_data = { | ||
106 | .attr = { .name = "data", .mode = S_IRUSR | S_IWUSR, }, | ||
107 | .size = 0, | ||
108 | .read = devcd_data_read, | ||
109 | .write = devcd_data_write, | ||
110 | }; | ||
111 | |||
112 | static struct bin_attribute *devcd_dev_bin_attrs[] = { | ||
113 | &devcd_attr_data, NULL, | ||
114 | }; | ||
115 | |||
116 | static const struct attribute_group devcd_dev_group = { | ||
117 | .bin_attrs = devcd_dev_bin_attrs, | ||
118 | }; | ||
119 | |||
120 | static const struct attribute_group *devcd_dev_groups[] = { | ||
121 | &devcd_dev_group, NULL, | ||
122 | }; | ||
123 | |||
124 | static struct class devcd_class = { | ||
125 | .name = "devcoredump", | ||
126 | .owner = THIS_MODULE, | ||
127 | .dev_release = devcd_dev_release, | ||
128 | .dev_groups = devcd_dev_groups, | ||
129 | }; | ||
130 | |||
131 | static ssize_t devcd_readv(char *buffer, loff_t offset, size_t count, | ||
132 | const void *data, size_t datalen) | ||
133 | { | ||
134 | if (offset > datalen) | ||
135 | return -EINVAL; | ||
136 | |||
137 | if (offset + count > datalen) | ||
138 | count = datalen - offset; | ||
139 | |||
140 | if (count) | ||
141 | memcpy(buffer, ((u8 *)data) + offset, count); | ||
142 | |||
143 | return count; | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * dev_coredumpv - create device coredump with vmalloc data | ||
148 | * @dev: the struct device for the crashed device | ||
149 | * @data: vmalloc data containing the device coredump | ||
150 | * @datalen: length of the data | ||
151 | * @gfp: allocation flags | ||
152 | * | ||
153 | * This function takes ownership of the vmalloc'ed data and will free | ||
154 | * it when it is no longer used. See dev_coredumpm() for more information. | ||
155 | */ | ||
156 | void dev_coredumpv(struct device *dev, const void *data, size_t datalen, | ||
157 | gfp_t gfp) | ||
158 | { | ||
159 | dev_coredumpm(dev, NULL, data, datalen, gfp, devcd_readv, vfree); | ||
160 | } | ||
161 | EXPORT_SYMBOL_GPL(dev_coredumpv); | ||
162 | |||
163 | static int devcd_match_failing(struct device *dev, const void *failing) | ||
164 | { | ||
165 | struct devcd_entry *devcd = dev_to_devcd(dev); | ||
166 | |||
167 | return devcd->failing_dev == failing; | ||
168 | } | ||
169 | |||
170 | /** | ||
171 | * dev_coredumpm - create device coredump with read/free methods | ||
172 | * @dev: the struct device for the crashed device | ||
173 | * @owner: the module that contains the read/free functions, use %THIS_MODULE | ||
174 | * @data: data cookie for the @read/@free functions | ||
175 | * @datalen: length of the data | ||
176 | * @gfp: allocation flags | ||
177 | * @read: function to read from the given buffer | ||
178 | * @free: function to free the given buffer | ||
179 | * | ||
180 | * Creates a new device coredump for the given device. If a previous one hasn't | ||
181 | * been read yet, the new coredump is discarded. The data lifetime is determined | ||
182 | * by the device coredump framework and when it is no longer needed the @free | ||
183 | * function will be called to free the data. | ||
184 | */ | ||
185 | void dev_coredumpm(struct device *dev, struct module *owner, | ||
186 | const void *data, size_t datalen, gfp_t gfp, | ||
187 | ssize_t (*read)(char *buffer, loff_t offset, size_t count, | ||
188 | const void *data, size_t datalen), | ||
189 | void (*free)(const void *data)) | ||
190 | { | ||
191 | static atomic_t devcd_count = ATOMIC_INIT(0); | ||
192 | struct devcd_entry *devcd; | ||
193 | struct device *existing; | ||
194 | |||
195 | existing = class_find_device(&devcd_class, NULL, dev, | ||
196 | devcd_match_failing); | ||
197 | if (existing) { | ||
198 | put_device(existing); | ||
199 | goto free; | ||
200 | } | ||
201 | |||
202 | if (!try_module_get(owner)) | ||
203 | goto free; | ||
204 | |||
205 | devcd = kzalloc(sizeof(*devcd), gfp); | ||
206 | if (!devcd) | ||
207 | goto put_module; | ||
208 | |||
209 | devcd->owner = owner; | ||
210 | devcd->data = data; | ||
211 | devcd->datalen = datalen; | ||
212 | devcd->read = read; | ||
213 | devcd->free = free; | ||
214 | devcd->failing_dev = get_device(dev); | ||
215 | |||
216 | device_initialize(&devcd->devcd_dev); | ||
217 | |||
218 | dev_set_name(&devcd->devcd_dev, "devcd%d", | ||
219 | atomic_inc_return(&devcd_count)); | ||
220 | devcd->devcd_dev.class = &devcd_class; | ||
221 | |||
222 | if (device_add(&devcd->devcd_dev)) | ||
223 | goto put_device; | ||
224 | |||
225 | if (sysfs_create_link(&devcd->devcd_dev.kobj, &dev->kobj, | ||
226 | "failing_device")) | ||
227 | /* nothing - symlink will be missing */; | ||
228 | |||
229 | if (sysfs_create_link(&dev->kobj, &devcd->devcd_dev.kobj, | ||
230 | "devcoredump")) | ||
231 | /* nothing - symlink will be missing */; | ||
232 | |||
233 | INIT_DELAYED_WORK(&devcd->del_wk, devcd_del); | ||
234 | schedule_delayed_work(&devcd->del_wk, DEVCD_TIMEOUT); | ||
235 | |||
236 | return; | ||
237 | put_device: | ||
238 | put_device(&devcd->devcd_dev); | ||
239 | put_module: | ||
240 | module_put(owner); | ||
241 | free: | ||
242 | free(data); | ||
243 | } | ||
244 | EXPORT_SYMBOL_GPL(dev_coredumpm); | ||
245 | |||
246 | static int __init devcoredump_init(void) | ||
247 | { | ||
248 | return class_register(&devcd_class); | ||
249 | } | ||
250 | __initcall(devcoredump_init); | ||
251 | |||
252 | static int devcd_free(struct device *dev, void *data) | ||
253 | { | ||
254 | struct devcd_entry *devcd = dev_to_devcd(dev); | ||
255 | |||
256 | flush_delayed_work(&devcd->del_wk); | ||
257 | return 0; | ||
258 | } | ||
259 | |||
260 | static void __exit devcoredump_exit(void) | ||
261 | { | ||
262 | class_for_each_device(&devcd_class, NULL, NULL, devcd_free); | ||
263 | class_unregister(&devcd_class); | ||
264 | } | ||
265 | __exitcall(devcoredump_exit); | ||
diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 69d9b0c89a01..c8a53d1e019f 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c | |||
@@ -817,13 +817,13 @@ char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) | |||
817 | EXPORT_SYMBOL_GPL(devm_kstrdup); | 817 | EXPORT_SYMBOL_GPL(devm_kstrdup); |
818 | 818 | ||
819 | /** | 819 | /** |
820 | * devm_kvasprintf - Allocate resource managed space | 820 | * devm_kvasprintf - Allocate resource managed space and format a string |
821 | * for the formatted string. | 821 | * into that. |
822 | * @dev: Device to allocate memory for | 822 | * @dev: Device to allocate memory for |
823 | * @gfp: the GFP mask used in the devm_kmalloc() call when | 823 | * @gfp: the GFP mask used in the devm_kmalloc() call when |
824 | * allocating memory | 824 | * allocating memory |
825 | * @fmt: the formatted string to duplicate | 825 | * @fmt: The printf()-style format string |
826 | * @ap: the list of tokens to be placed in the formatted string | 826 | * @ap: Arguments for the format string |
827 | * RETURNS: | 827 | * RETURNS: |
828 | * Pointer to allocated string on success, NULL on failure. | 828 | * Pointer to allocated string on success, NULL on failure. |
829 | */ | 829 | */ |
@@ -849,12 +849,13 @@ char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, | |||
849 | EXPORT_SYMBOL(devm_kvasprintf); | 849 | EXPORT_SYMBOL(devm_kvasprintf); |
850 | 850 | ||
851 | /** | 851 | /** |
852 | * devm_kasprintf - Allocate resource managed space | 852 | * devm_kasprintf - Allocate resource managed space and format a string |
853 | * and copy an existing formatted string into that | 853 | * into that. |
854 | * @dev: Device to allocate memory for | 854 | * @dev: Device to allocate memory for |
855 | * @gfp: the GFP mask used in the devm_kmalloc() call when | 855 | * @gfp: the GFP mask used in the devm_kmalloc() call when |
856 | * allocating memory | 856 | * allocating memory |
857 | * @fmt: the string to duplicate | 857 | * @fmt: The printf()-style format string |
858 | * @...: Arguments for the format string | ||
858 | * RETURNS: | 859 | * RETURNS: |
859 | * Pointer to allocated string on success, NULL on failure. | 860 | * Pointer to allocated string on success, NULL on failure. |
860 | */ | 861 | */ |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index bf424305f3dc..3d785ebb48d3 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -1105,6 +1105,9 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
1105 | if (!firmware_p) | 1105 | if (!firmware_p) |
1106 | return -EINVAL; | 1106 | return -EINVAL; |
1107 | 1107 | ||
1108 | if (!name || name[0] == '\0') | ||
1109 | return -EINVAL; | ||
1110 | |||
1108 | ret = _request_firmware_prepare(&fw, name, device); | 1111 | ret = _request_firmware_prepare(&fw, name, device); |
1109 | if (ret <= 0) /* error or already assigned */ | 1112 | if (ret <= 0) /* error or already assigned */ |
1110 | goto out; | 1113 | goto out; |
diff --git a/drivers/base/node.c b/drivers/base/node.c index c6d3ae05f1ca..d51c49c9bafa 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -603,7 +603,6 @@ void unregister_one_node(int nid) | |||
603 | return; | 603 | return; |
604 | 604 | ||
605 | unregister_node(node_devices[nid]); | 605 | unregister_node(node_devices[nid]); |
606 | kfree(node_devices[nid]); | ||
607 | node_devices[nid] = NULL; | 606 | node_devices[nid] = NULL; |
608 | } | 607 | } |
609 | 608 | ||
diff --git a/include/linux/devcoredump.h b/include/linux/devcoredump.h new file mode 100644 index 000000000000..c0a360e99f64 --- /dev/null +++ b/include/linux/devcoredump.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef __DEVCOREDUMP_H | ||
2 | #define __DEVCOREDUMP_H | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/module.h> | ||
6 | #include <linux/vmalloc.h> | ||
7 | |||
8 | #ifdef CONFIG_DEV_COREDUMP | ||
9 | void dev_coredumpv(struct device *dev, const void *data, size_t datalen, | ||
10 | gfp_t gfp); | ||
11 | |||
12 | void dev_coredumpm(struct device *dev, struct module *owner, | ||
13 | const void *data, size_t datalen, gfp_t gfp, | ||
14 | ssize_t (*read)(char *buffer, loff_t offset, size_t count, | ||
15 | const void *data, size_t datalen), | ||
16 | void (*free)(const void *data)); | ||
17 | #else | ||
18 | static inline void dev_coredumpv(struct device *dev, const void *data, | ||
19 | size_t datalen, gfp_t gfp) | ||
20 | { | ||
21 | vfree(data); | ||
22 | } | ||
23 | |||
24 | static inline void | ||
25 | dev_coredumpm(struct device *dev, struct module *owner, | ||
26 | const void *data, size_t datalen, gfp_t gfp, | ||
27 | ssize_t (*read)(char *buffer, loff_t offset, size_t count, | ||
28 | const void *data, size_t datalen), | ||
29 | void (*free)(const void *data)) | ||
30 | { | ||
31 | free(data); | ||
32 | } | ||
33 | #endif /* CONFIG_DEV_COREDUMP */ | ||
34 | |||
35 | #endif /* __DEVCOREDUMP_H */ | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 43d183aeb25b..a608e237f0a8 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -607,8 +607,8 @@ extern int devres_release_group(struct device *dev, void *id); | |||
607 | extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp); | 607 | extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp); |
608 | extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, | 608 | extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, |
609 | va_list ap); | 609 | va_list ap); |
610 | extern char *devm_kasprintf(struct device *dev, gfp_t gfp, | 610 | extern __printf(3, 4) |
611 | const char *fmt, ...); | 611 | char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...); |
612 | static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) | 612 | static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp) |
613 | { | 613 | { |
614 | return devm_kmalloc(dev, size, gfp | __GFP_ZERO); | 614 | return devm_kmalloc(dev, size, gfp | __GFP_ZERO); |
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2fe93b26b42f..4f1bbc68cd1b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h | |||
@@ -42,7 +42,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, | |||
42 | #if defined(CONFIG_DYNAMIC_DEBUG) | 42 | #if defined(CONFIG_DYNAMIC_DEBUG) |
43 | extern int ddebug_remove_module(const char *mod_name); | 43 | extern int ddebug_remove_module(const char *mod_name); |
44 | extern __printf(2, 3) | 44 | extern __printf(2, 3) |
45 | int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); | 45 | void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); |
46 | 46 | ||
47 | extern int ddebug_dyndbg_module_param_cb(char *param, char *val, | 47 | extern int ddebug_dyndbg_module_param_cb(char *param, char *val, |
48 | const char *modname); | 48 | const char *modname); |
@@ -50,15 +50,15 @@ extern int ddebug_dyndbg_module_param_cb(char *param, char *val, | |||
50 | struct device; | 50 | struct device; |
51 | 51 | ||
52 | extern __printf(3, 4) | 52 | extern __printf(3, 4) |
53 | int __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, | 53 | void __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, |
54 | const char *fmt, ...); | 54 | const char *fmt, ...); |
55 | 55 | ||
56 | struct net_device; | 56 | struct net_device; |
57 | 57 | ||
58 | extern __printf(3, 4) | 58 | extern __printf(3, 4) |
59 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | 59 | void __dynamic_netdev_dbg(struct _ddebug *descriptor, |
60 | const struct net_device *dev, | 60 | const struct net_device *dev, |
61 | const char *fmt, ...); | 61 | const char *fmt, ...); |
62 | 62 | ||
63 | #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ | 63 | #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ |
64 | static struct _ddebug __aligned(8) \ | 64 | static struct _ddebug __aligned(8) \ |
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c9afbe2c445a..31fe79e31ab8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c | |||
@@ -537,10 +537,9 @@ static char *dynamic_emit_prefix(const struct _ddebug *desc, char *buf) | |||
537 | return buf; | 537 | return buf; |
538 | } | 538 | } |
539 | 539 | ||
540 | int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) | 540 | void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) |
541 | { | 541 | { |
542 | va_list args; | 542 | va_list args; |
543 | int res; | ||
544 | struct va_format vaf; | 543 | struct va_format vaf; |
545 | char buf[PREFIX_SIZE]; | 544 | char buf[PREFIX_SIZE]; |
546 | 545 | ||
@@ -552,21 +551,17 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) | |||
552 | vaf.fmt = fmt; | 551 | vaf.fmt = fmt; |
553 | vaf.va = &args; | 552 | vaf.va = &args; |
554 | 553 | ||
555 | res = printk(KERN_DEBUG "%s%pV", | 554 | printk(KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); |
556 | dynamic_emit_prefix(descriptor, buf), &vaf); | ||
557 | 555 | ||
558 | va_end(args); | 556 | va_end(args); |
559 | |||
560 | return res; | ||
561 | } | 557 | } |
562 | EXPORT_SYMBOL(__dynamic_pr_debug); | 558 | EXPORT_SYMBOL(__dynamic_pr_debug); |
563 | 559 | ||
564 | int __dynamic_dev_dbg(struct _ddebug *descriptor, | 560 | void __dynamic_dev_dbg(struct _ddebug *descriptor, |
565 | const struct device *dev, const char *fmt, ...) | 561 | const struct device *dev, const char *fmt, ...) |
566 | { | 562 | { |
567 | struct va_format vaf; | 563 | struct va_format vaf; |
568 | va_list args; | 564 | va_list args; |
569 | int res; | ||
570 | 565 | ||
571 | BUG_ON(!descriptor); | 566 | BUG_ON(!descriptor); |
572 | BUG_ON(!fmt); | 567 | BUG_ON(!fmt); |
@@ -577,30 +572,27 @@ int __dynamic_dev_dbg(struct _ddebug *descriptor, | |||
577 | vaf.va = &args; | 572 | vaf.va = &args; |
578 | 573 | ||
579 | if (!dev) { | 574 | if (!dev) { |
580 | res = printk(KERN_DEBUG "(NULL device *): %pV", &vaf); | 575 | printk(KERN_DEBUG "(NULL device *): %pV", &vaf); |
581 | } else { | 576 | } else { |
582 | char buf[PREFIX_SIZE]; | 577 | char buf[PREFIX_SIZE]; |
583 | 578 | ||
584 | res = dev_printk_emit(7, dev, "%s%s %s: %pV", | 579 | dev_printk_emit(7, dev, "%s%s %s: %pV", |
585 | dynamic_emit_prefix(descriptor, buf), | 580 | dynamic_emit_prefix(descriptor, buf), |
586 | dev_driver_string(dev), dev_name(dev), | 581 | dev_driver_string(dev), dev_name(dev), |
587 | &vaf); | 582 | &vaf); |
588 | } | 583 | } |
589 | 584 | ||
590 | va_end(args); | 585 | va_end(args); |
591 | |||
592 | return res; | ||
593 | } | 586 | } |
594 | EXPORT_SYMBOL(__dynamic_dev_dbg); | 587 | EXPORT_SYMBOL(__dynamic_dev_dbg); |
595 | 588 | ||
596 | #ifdef CONFIG_NET | 589 | #ifdef CONFIG_NET |
597 | 590 | ||
598 | int __dynamic_netdev_dbg(struct _ddebug *descriptor, | 591 | void __dynamic_netdev_dbg(struct _ddebug *descriptor, |
599 | const struct net_device *dev, const char *fmt, ...) | 592 | const struct net_device *dev, const char *fmt, ...) |
600 | { | 593 | { |
601 | struct va_format vaf; | 594 | struct va_format vaf; |
602 | va_list args; | 595 | va_list args; |
603 | int res; | ||
604 | 596 | ||
605 | BUG_ON(!descriptor); | 597 | BUG_ON(!descriptor); |
606 | BUG_ON(!fmt); | 598 | BUG_ON(!fmt); |
@@ -613,23 +605,21 @@ int __dynamic_netdev_dbg(struct _ddebug *descriptor, | |||
613 | if (dev && dev->dev.parent) { | 605 | if (dev && dev->dev.parent) { |
614 | char buf[PREFIX_SIZE]; | 606 | char buf[PREFIX_SIZE]; |
615 | 607 | ||
616 | res = dev_printk_emit(7, dev->dev.parent, | 608 | dev_printk_emit(7, dev->dev.parent, |
617 | "%s%s %s %s%s: %pV", | 609 | "%s%s %s %s%s: %pV", |
618 | dynamic_emit_prefix(descriptor, buf), | 610 | dynamic_emit_prefix(descriptor, buf), |
619 | dev_driver_string(dev->dev.parent), | 611 | dev_driver_string(dev->dev.parent), |
620 | dev_name(dev->dev.parent), | 612 | dev_name(dev->dev.parent), |
621 | netdev_name(dev), netdev_reg_state(dev), | 613 | netdev_name(dev), netdev_reg_state(dev), |
622 | &vaf); | 614 | &vaf); |
623 | } else if (dev) { | 615 | } else if (dev) { |
624 | res = printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev), | 616 | printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev), |
625 | netdev_reg_state(dev), &vaf); | 617 | netdev_reg_state(dev), &vaf); |
626 | } else { | 618 | } else { |
627 | res = printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); | 619 | printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); |
628 | } | 620 | } |
629 | 621 | ||
630 | va_end(args); | 622 | va_end(args); |
631 | |||
632 | return res; | ||
633 | } | 623 | } |
634 | EXPORT_SYMBOL(__dynamic_netdev_dbg); | 624 | EXPORT_SYMBOL(__dynamic_netdev_dbg); |
635 | 625 | ||