aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/Kconfig19
-rw-r--r--drivers/base/Makefile1
-rw-r--r--drivers/base/component.c192
-rw-r--r--drivers/base/dma-buf.c743
-rw-r--r--drivers/base/firmware_class.c47
-rw-r--r--drivers/base/platform.c51
-rw-r--r--drivers/base/reservation.c39
7 files changed, 245 insertions, 847 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 23b8726962af..88500fed3c7a 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -149,15 +149,21 @@ config EXTRA_FIRMWARE_DIR
149 some other directory containing the firmware files. 149 some other directory containing the firmware files.
150 150
151config FW_LOADER_USER_HELPER 151config FW_LOADER_USER_HELPER
152 bool
153
154config FW_LOADER_USER_HELPER_FALLBACK
152 bool "Fallback user-helper invocation for firmware loading" 155 bool "Fallback user-helper invocation for firmware loading"
153 depends on FW_LOADER 156 depends on FW_LOADER
154 default y 157 select FW_LOADER_USER_HELPER
155 help 158 help
156 This option enables / disables the invocation of user-helper 159 This option enables / disables the invocation of user-helper
157 (e.g. udev) for loading firmware files as a fallback after the 160 (e.g. udev) for loading firmware files as a fallback after the
158 direct file loading in kernel fails. The user-mode helper is 161 direct file loading in kernel fails. The user-mode helper is
159 no longer required unless you have a special firmware file that 162 no longer required unless you have a special firmware file that
160 resides in a non-standard path. 163 resides in a non-standard path. Moreover, the udev support has
164 been deprecated upstream.
165
166 If you are unsure about this, say N here.
161 167
162config DEBUG_DRIVER 168config DEBUG_DRIVER
163 bool "Driver Core verbose debug messages" 169 bool "Driver Core verbose debug messages"
@@ -208,6 +214,15 @@ config DMA_SHARED_BUFFER
208 APIs extension; the file's descriptor can then be passed on to other 214 APIs extension; the file's descriptor can then be passed on to other
209 driver. 215 driver.
210 216
217config FENCE_TRACE
218 bool "Enable verbose FENCE_TRACE messages"
219 depends on DMA_SHARED_BUFFER
220 help
221 Enable the FENCE_TRACE printks. This will add extra
222 spam to the console log, but will make it easier to diagnose
223 lockup related problems for dma-buffers shared across multiple
224 devices.
225
211config DMA_CMA 226config DMA_CMA
212 bool "DMA Contiguous Memory Allocator" 227 bool "DMA Contiguous Memory Allocator"
213 depends on HAVE_DMA_CONTIGUOUS && CMA 228 depends on HAVE_DMA_CONTIGUOUS && CMA
diff --git a/drivers/base/Makefile b/drivers/base/Makefile
index 04b314e0fa51..4aab26ec0292 100644
--- a/drivers/base/Makefile
+++ b/drivers/base/Makefile
@@ -10,7 +10,6 @@ obj-$(CONFIG_DMA_CMA) += dma-contiguous.o
10obj-y += power/ 10obj-y += power/
11obj-$(CONFIG_HAS_DMA) += dma-mapping.o 11obj-$(CONFIG_HAS_DMA) += dma-mapping.o
12obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o 12obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o
13obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf.o reservation.o
14obj-$(CONFIG_ISA) += isa.o 13obj-$(CONFIG_ISA) += isa.o
15obj-$(CONFIG_FW_LOADER) += firmware_class.o 14obj-$(CONFIG_FW_LOADER) += firmware_class.o
16obj-$(CONFIG_NUMA) += node.o 15obj-$(CONFIG_NUMA) += node.o
diff --git a/drivers/base/component.c b/drivers/base/component.c
index c4778995cd72..f748430bb654 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -18,6 +18,15 @@
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20 20
21struct component_match {
22 size_t alloc;
23 size_t num;
24 struct {
25 void *data;
26 int (*fn)(struct device *, void *);
27 } compare[0];
28};
29
21struct master { 30struct master {
22 struct list_head node; 31 struct list_head node;
23 struct list_head components; 32 struct list_head components;
@@ -25,6 +34,7 @@ struct master {
25 34
26 const struct component_master_ops *ops; 35 const struct component_master_ops *ops;
27 struct device *dev; 36 struct device *dev;
37 struct component_match *match;
28}; 38};
29 39
30struct component { 40struct component {
@@ -69,6 +79,11 @@ static void component_detach_master(struct master *master, struct component *c)
69 c->master = NULL; 79 c->master = NULL;
70} 80}
71 81
82/*
83 * Add a component to a master, finding the component via the compare
84 * function and compare data. This is safe to call for duplicate matches
85 * and will not result in the same component being added multiple times.
86 */
72int component_master_add_child(struct master *master, 87int component_master_add_child(struct master *master,
73 int (*compare)(struct device *, void *), void *compare_data) 88 int (*compare)(struct device *, void *), void *compare_data)
74{ 89{
@@ -76,11 +91,12 @@ int component_master_add_child(struct master *master,
76 int ret = -ENXIO; 91 int ret = -ENXIO;
77 92
78 list_for_each_entry(c, &component_list, node) { 93 list_for_each_entry(c, &component_list, node) {
79 if (c->master) 94 if (c->master && c->master != master)
80 continue; 95 continue;
81 96
82 if (compare(c->dev, compare_data)) { 97 if (compare(c->dev, compare_data)) {
83 component_attach_master(master, c); 98 if (!c->master)
99 component_attach_master(master, c);
84 ret = 0; 100 ret = 0;
85 break; 101 break;
86 } 102 }
@@ -90,6 +106,34 @@ int component_master_add_child(struct master *master,
90} 106}
91EXPORT_SYMBOL_GPL(component_master_add_child); 107EXPORT_SYMBOL_GPL(component_master_add_child);
92 108
109static int find_components(struct master *master)
110{
111 struct component_match *match = master->match;
112 size_t i;
113 int ret = 0;
114
115 if (!match) {
116 /*
117 * Search the list of components, looking for components that
118 * belong to this master, and attach them to the master.
119 */
120 return master->ops->add_components(master->dev, master);
121 }
122
123 /*
124 * Scan the array of match functions and attach
125 * any components which are found to this master.
126 */
127 for (i = 0; i < match->num; i++) {
128 ret = component_master_add_child(master,
129 match->compare[i].fn,
130 match->compare[i].data);
131 if (ret)
132 break;
133 }
134 return ret;
135}
136
93/* Detach all attached components from this master */ 137/* Detach all attached components from this master */
94static void master_remove_components(struct master *master) 138static void master_remove_components(struct master *master)
95{ 139{
@@ -113,44 +157,44 @@ static void master_remove_components(struct master *master)
113static int try_to_bring_up_master(struct master *master, 157static int try_to_bring_up_master(struct master *master,
114 struct component *component) 158 struct component *component)
115{ 159{
116 int ret = 0; 160 int ret;
117 161
118 if (!master->bound) { 162 if (master->bound)
119 /* 163 return 0;
120 * Search the list of components, looking for components that
121 * belong to this master, and attach them to the master.
122 */
123 if (master->ops->add_components(master->dev, master)) {
124 /* Failed to find all components */
125 master_remove_components(master);
126 ret = 0;
127 goto out;
128 }
129 164
130 if (component && component->master != master) { 165 /*
131 master_remove_components(master); 166 * Search the list of components, looking for components that
132 ret = 0; 167 * belong to this master, and attach them to the master.
133 goto out; 168 */
134 } 169 if (find_components(master)) {
170 /* Failed to find all components */
171 ret = 0;
172 goto out;
173 }
135 174
136 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) { 175 if (component && component->master != master) {
137 ret = -ENOMEM; 176 ret = 0;
138 goto out; 177 goto out;
139 } 178 }
140 179
141 /* Found all components */ 180 if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) {
142 ret = master->ops->bind(master->dev); 181 ret = -ENOMEM;
143 if (ret < 0) { 182 goto out;
144 devres_release_group(master->dev, NULL); 183 }
145 dev_info(master->dev, "master bind failed: %d\n", ret);
146 master_remove_components(master);
147 goto out;
148 }
149 184
150 master->bound = true; 185 /* Found all components */
151 ret = 1; 186 ret = master->ops->bind(master->dev);
187 if (ret < 0) {
188 devres_release_group(master->dev, NULL);
189 dev_info(master->dev, "master bind failed: %d\n", ret);
190 goto out;
152 } 191 }
192
193 master->bound = true;
194 return 1;
195
153out: 196out:
197 master_remove_components(master);
154 198
155 return ret; 199 return ret;
156} 200}
@@ -180,18 +224,89 @@ static void take_down_master(struct master *master)
180 master_remove_components(master); 224 master_remove_components(master);
181} 225}
182 226
183int component_master_add(struct device *dev, 227static size_t component_match_size(size_t num)
184 const struct component_master_ops *ops) 228{
229 return offsetof(struct component_match, compare[num]);
230}
231
232static struct component_match *component_match_realloc(struct device *dev,
233 struct component_match *match, size_t num)
234{
235 struct component_match *new;
236
237 if (match && match->alloc == num)
238 return match;
239
240 new = devm_kmalloc(dev, component_match_size(num), GFP_KERNEL);
241 if (!new)
242 return ERR_PTR(-ENOMEM);
243
244 if (match) {
245 memcpy(new, match, component_match_size(min(match->num, num)));
246 devm_kfree(dev, match);
247 } else {
248 new->num = 0;
249 }
250
251 new->alloc = num;
252
253 return new;
254}
255
256/*
257 * Add a component to be matched.
258 *
259 * The match array is first created or extended if necessary.
260 */
261void component_match_add(struct device *dev, struct component_match **matchptr,
262 int (*compare)(struct device *, void *), void *compare_data)
263{
264 struct component_match *match = *matchptr;
265
266 if (IS_ERR(match))
267 return;
268
269 if (!match || match->num == match->alloc) {
270 size_t new_size = match ? match->alloc + 16 : 15;
271
272 match = component_match_realloc(dev, match, new_size);
273
274 *matchptr = match;
275
276 if (IS_ERR(match))
277 return;
278 }
279
280 match->compare[match->num].fn = compare;
281 match->compare[match->num].data = compare_data;
282 match->num++;
283}
284EXPORT_SYMBOL(component_match_add);
285
286int component_master_add_with_match(struct device *dev,
287 const struct component_master_ops *ops,
288 struct component_match *match)
185{ 289{
186 struct master *master; 290 struct master *master;
187 int ret; 291 int ret;
188 292
293 if (ops->add_components && match)
294 return -EINVAL;
295
296 if (match) {
297 /* Reallocate the match array for its true size */
298 match = component_match_realloc(dev, match, match->num);
299 if (IS_ERR(match))
300 return PTR_ERR(match);
301 }
302
189 master = kzalloc(sizeof(*master), GFP_KERNEL); 303 master = kzalloc(sizeof(*master), GFP_KERNEL);
190 if (!master) 304 if (!master)
191 return -ENOMEM; 305 return -ENOMEM;
192 306
193 master->dev = dev; 307 master->dev = dev;
194 master->ops = ops; 308 master->ops = ops;
309 master->match = match;
195 INIT_LIST_HEAD(&master->components); 310 INIT_LIST_HEAD(&master->components);
196 311
197 /* Add to the list of available masters. */ 312 /* Add to the list of available masters. */
@@ -209,6 +324,13 @@ int component_master_add(struct device *dev,
209 324
210 return ret < 0 ? ret : 0; 325 return ret < 0 ? ret : 0;
211} 326}
327EXPORT_SYMBOL_GPL(component_master_add_with_match);
328
329int component_master_add(struct device *dev,
330 const struct component_master_ops *ops)
331{
332 return component_master_add_with_match(dev, ops, NULL);
333}
212EXPORT_SYMBOL_GPL(component_master_add); 334EXPORT_SYMBOL_GPL(component_master_add);
213 335
214void component_master_del(struct device *dev, 336void component_master_del(struct device *dev,
diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
deleted file mode 100644
index 840c7fa80983..000000000000
--- a/drivers/base/dma-buf.c
+++ /dev/null
@@ -1,743 +0,0 @@
1/*
2 * Framework for buffer objects that can be shared across devices/subsystems.
3 *
4 * Copyright(C) 2011 Linaro Limited. All rights reserved.
5 * Author: Sumit Semwal <sumit.semwal@ti.com>
6 *
7 * Many thanks to linaro-mm-sig list, and specially
8 * Arnd Bergmann <arnd@arndb.de>, Rob Clark <rob@ti.com> and
9 * Daniel Vetter <daniel@ffwll.ch> for their support in creation and
10 * refining of this idea.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published by
14 * the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25#include <linux/fs.h>
26#include <linux/slab.h>
27#include <linux/dma-buf.h>
28#include <linux/anon_inodes.h>
29#include <linux/export.h>
30#include <linux/debugfs.h>
31#include <linux/seq_file.h>
32
33static inline int is_dma_buf_file(struct file *);
34
35struct dma_buf_list {
36 struct list_head head;
37 struct mutex lock;
38};
39
40static struct dma_buf_list db_list;
41
42static int dma_buf_release(struct inode *inode, struct file *file)
43{
44 struct dma_buf *dmabuf;
45
46 if (!is_dma_buf_file(file))
47 return -EINVAL;
48
49 dmabuf = file->private_data;
50
51 BUG_ON(dmabuf->vmapping_counter);
52
53 dmabuf->ops->release(dmabuf);
54
55 mutex_lock(&db_list.lock);
56 list_del(&dmabuf->list_node);
57 mutex_unlock(&db_list.lock);
58
59 kfree(dmabuf);
60 return 0;
61}
62
63static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
64{
65 struct dma_buf *dmabuf;
66
67 if (!is_dma_buf_file(file))
68 return -EINVAL;
69
70 dmabuf = file->private_data;
71
72 /* check for overflowing the buffer's size */
73 if (vma->vm_pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
74 dmabuf->size >> PAGE_SHIFT)
75 return -EINVAL;
76
77 return dmabuf->ops->mmap(dmabuf, vma);
78}
79
80static loff_t dma_buf_llseek(struct file *file, loff_t offset, int whence)
81{
82 struct dma_buf *dmabuf;
83 loff_t base;
84
85 if (!is_dma_buf_file(file))
86 return -EBADF;
87
88 dmabuf = file->private_data;
89
90 /* only support discovering the end of the buffer,
91 but also allow SEEK_SET to maintain the idiomatic
92 SEEK_END(0), SEEK_CUR(0) pattern */
93 if (whence == SEEK_END)
94 base = dmabuf->size;
95 else if (whence == SEEK_SET)
96 base = 0;
97 else
98 return -EINVAL;
99
100 if (offset != 0)
101 return -EINVAL;
102
103 return base + offset;
104}
105
106static const struct file_operations dma_buf_fops = {
107 .release = dma_buf_release,
108 .mmap = dma_buf_mmap_internal,
109 .llseek = dma_buf_llseek,
110};
111
112/*
113 * is_dma_buf_file - Check if struct file* is associated with dma_buf
114 */
115static inline int is_dma_buf_file(struct file *file)
116{
117 return file->f_op == &dma_buf_fops;
118}
119
120/**
121 * dma_buf_export_named - Creates a new dma_buf, and associates an anon file
122 * with this buffer, so it can be exported.
123 * Also connect the allocator specific data and ops to the buffer.
124 * Additionally, provide a name string for exporter; useful in debugging.
125 *
126 * @priv: [in] Attach private data of allocator to this buffer
127 * @ops: [in] Attach allocator-defined dma buf ops to the new buffer.
128 * @size: [in] Size of the buffer
129 * @flags: [in] mode flags for the file.
130 * @exp_name: [in] name of the exporting module - useful for debugging.
131 *
132 * Returns, on success, a newly created dma_buf object, which wraps the
133 * supplied private data and operations for dma_buf_ops. On either missing
134 * ops, or error in allocating struct dma_buf, will return negative error.
135 *
136 */
137struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops,
138 size_t size, int flags, const char *exp_name)
139{
140 struct dma_buf *dmabuf;
141 struct file *file;
142
143 if (WARN_ON(!priv || !ops
144 || !ops->map_dma_buf
145 || !ops->unmap_dma_buf
146 || !ops->release
147 || !ops->kmap_atomic
148 || !ops->kmap
149 || !ops->mmap)) {
150 return ERR_PTR(-EINVAL);
151 }
152
153 dmabuf = kzalloc(sizeof(struct dma_buf), GFP_KERNEL);
154 if (dmabuf == NULL)
155 return ERR_PTR(-ENOMEM);
156
157 dmabuf->priv = priv;
158 dmabuf->ops = ops;
159 dmabuf->size = size;
160 dmabuf->exp_name = exp_name;
161
162 file = anon_inode_getfile("dmabuf", &dma_buf_fops, dmabuf, flags);
163 if (IS_ERR(file)) {
164 kfree(dmabuf);
165 return ERR_CAST(file);
166 }
167
168 file->f_mode |= FMODE_LSEEK;
169 dmabuf->file = file;
170
171 mutex_init(&dmabuf->lock);
172 INIT_LIST_HEAD(&dmabuf->attachments);
173
174 mutex_lock(&db_list.lock);
175 list_add(&dmabuf->list_node, &db_list.head);
176 mutex_unlock(&db_list.lock);
177
178 return dmabuf;
179}
180EXPORT_SYMBOL_GPL(dma_buf_export_named);
181
182
183/**
184 * dma_buf_fd - returns a file descriptor for the given dma_buf
185 * @dmabuf: [in] pointer to dma_buf for which fd is required.
186 * @flags: [in] flags to give to fd
187 *
188 * On success, returns an associated 'fd'. Else, returns error.
189 */
190int dma_buf_fd(struct dma_buf *dmabuf, int flags)
191{
192 int fd;
193
194 if (!dmabuf || !dmabuf->file)
195 return -EINVAL;
196
197 fd = get_unused_fd_flags(flags);
198 if (fd < 0)
199 return fd;
200
201 fd_install(fd, dmabuf->file);
202
203 return fd;
204}
205EXPORT_SYMBOL_GPL(dma_buf_fd);
206
207/**
208 * dma_buf_get - returns the dma_buf structure related to an fd
209 * @fd: [in] fd associated with the dma_buf to be returned
210 *
211 * On success, returns the dma_buf structure associated with an fd; uses
212 * file's refcounting done by fget to increase refcount. returns ERR_PTR
213 * otherwise.
214 */
215struct dma_buf *dma_buf_get(int fd)
216{
217 struct file *file;
218
219 file = fget(fd);
220
221 if (!file)
222 return ERR_PTR(-EBADF);
223
224 if (!is_dma_buf_file(file)) {
225 fput(file);
226 return ERR_PTR(-EINVAL);
227 }
228
229 return file->private_data;
230}
231EXPORT_SYMBOL_GPL(dma_buf_get);
232
233/**
234 * dma_buf_put - decreases refcount of the buffer
235 * @dmabuf: [in] buffer to reduce refcount of
236 *
237 * Uses file's refcounting done implicitly by fput()
238 */
239void dma_buf_put(struct dma_buf *dmabuf)
240{
241 if (WARN_ON(!dmabuf || !dmabuf->file))
242 return;
243
244 fput(dmabuf->file);
245}
246EXPORT_SYMBOL_GPL(dma_buf_put);
247
248/**
249 * dma_buf_attach - Add the device to dma_buf's attachments list; optionally,
250 * calls attach() of dma_buf_ops to allow device-specific attach functionality
251 * @dmabuf: [in] buffer to attach device to.
252 * @dev: [in] device to be attached.
253 *
254 * Returns struct dma_buf_attachment * for this attachment; returns ERR_PTR on
255 * error.
256 */
257struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
258 struct device *dev)
259{
260 struct dma_buf_attachment *attach;
261 int ret;
262
263 if (WARN_ON(!dmabuf || !dev))
264 return ERR_PTR(-EINVAL);
265
266 attach = kzalloc(sizeof(struct dma_buf_attachment), GFP_KERNEL);
267 if (attach == NULL)
268 return ERR_PTR(-ENOMEM);
269
270 attach->dev = dev;
271 attach->dmabuf = dmabuf;
272
273 mutex_lock(&dmabuf->lock);
274
275 if (dmabuf->ops->attach) {
276 ret = dmabuf->ops->attach(dmabuf, dev, attach);
277 if (ret)
278 goto err_attach;
279 }
280 list_add(&attach->node, &dmabuf->attachments);
281
282 mutex_unlock(&dmabuf->lock);
283 return attach;
284
285err_attach:
286 kfree(attach);
287 mutex_unlock(&dmabuf->lock);
288 return ERR_PTR(ret);
289}
290EXPORT_SYMBOL_GPL(dma_buf_attach);
291
292/**
293 * dma_buf_detach - Remove the given attachment from dmabuf's attachments list;
294 * optionally calls detach() of dma_buf_ops for device-specific detach
295 * @dmabuf: [in] buffer to detach from.
296 * @attach: [in] attachment to be detached; is free'd after this call.
297 *
298 */
299void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
300{
301 if (WARN_ON(!dmabuf || !attach))
302 return;
303
304 mutex_lock(&dmabuf->lock);
305 list_del(&attach->node);
306 if (dmabuf->ops->detach)
307 dmabuf->ops->detach(dmabuf, attach);
308
309 mutex_unlock(&dmabuf->lock);
310 kfree(attach);
311}
312EXPORT_SYMBOL_GPL(dma_buf_detach);
313
314/**
315 * dma_buf_map_attachment - Returns the scatterlist table of the attachment;
316 * mapped into _device_ address space. Is a wrapper for map_dma_buf() of the
317 * dma_buf_ops.
318 * @attach: [in] attachment whose scatterlist is to be returned
319 * @direction: [in] direction of DMA transfer
320 *
321 * Returns sg_table containing the scatterlist to be returned; returns ERR_PTR
322 * on error.
323 */
324struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
325 enum dma_data_direction direction)
326{
327 struct sg_table *sg_table = ERR_PTR(-EINVAL);
328
329 might_sleep();
330
331 if (WARN_ON(!attach || !attach->dmabuf))
332 return ERR_PTR(-EINVAL);
333
334 sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
335 if (!sg_table)
336 sg_table = ERR_PTR(-ENOMEM);
337
338 return sg_table;
339}
340EXPORT_SYMBOL_GPL(dma_buf_map_attachment);
341
342/**
343 * dma_buf_unmap_attachment - unmaps and decreases usecount of the buffer;might
344 * deallocate the scatterlist associated. Is a wrapper for unmap_dma_buf() of
345 * dma_buf_ops.
346 * @attach: [in] attachment to unmap buffer from
347 * @sg_table: [in] scatterlist info of the buffer to unmap
348 * @direction: [in] direction of DMA transfer
349 *
350 */
351void dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
352 struct sg_table *sg_table,
353 enum dma_data_direction direction)
354{
355 might_sleep();
356
357 if (WARN_ON(!attach || !attach->dmabuf || !sg_table))
358 return;
359
360 attach->dmabuf->ops->unmap_dma_buf(attach, sg_table,
361 direction);
362}
363EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
364
365
366/**
367 * dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the
368 * cpu in the kernel context. Calls begin_cpu_access to allow exporter-specific
369 * preparations. Coherency is only guaranteed in the specified range for the
370 * specified access direction.
371 * @dmabuf: [in] buffer to prepare cpu access for.
372 * @start: [in] start of range for cpu access.
373 * @len: [in] length of range for cpu access.
374 * @direction: [in] length of range for cpu access.
375 *
376 * Can return negative error values, returns 0 on success.
377 */
378int dma_buf_begin_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len,
379 enum dma_data_direction direction)
380{
381 int ret = 0;
382
383 if (WARN_ON(!dmabuf))
384 return -EINVAL;
385
386 if (dmabuf->ops->begin_cpu_access)
387 ret = dmabuf->ops->begin_cpu_access(dmabuf, start, len, direction);
388
389 return ret;
390}
391EXPORT_SYMBOL_GPL(dma_buf_begin_cpu_access);
392
393/**
394 * dma_buf_end_cpu_access - Must be called after accessing a dma_buf from the
395 * cpu in the kernel context. Calls end_cpu_access to allow exporter-specific
396 * actions. Coherency is only guaranteed in the specified range for the
397 * specified access direction.
398 * @dmabuf: [in] buffer to complete cpu access for.
399 * @start: [in] start of range for cpu access.
400 * @len: [in] length of range for cpu access.
401 * @direction: [in] length of range for cpu access.
402 *
403 * This call must always succeed.
404 */
405void dma_buf_end_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len,
406 enum dma_data_direction direction)
407{
408 WARN_ON(!dmabuf);
409
410 if (dmabuf->ops->end_cpu_access)
411 dmabuf->ops->end_cpu_access(dmabuf, start, len, direction);
412}
413EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access);
414
415/**
416 * dma_buf_kmap_atomic - Map a page of the buffer object into kernel address
417 * space. The same restrictions as for kmap_atomic and friends apply.
418 * @dmabuf: [in] buffer to map page from.
419 * @page_num: [in] page in PAGE_SIZE units to map.
420 *
421 * This call must always succeed, any necessary preparations that might fail
422 * need to be done in begin_cpu_access.
423 */
424void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, unsigned long page_num)
425{
426 WARN_ON(!dmabuf);
427
428 return dmabuf->ops->kmap_atomic(dmabuf, page_num);
429}
430EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
431
432/**
433 * dma_buf_kunmap_atomic - Unmap a page obtained by dma_buf_kmap_atomic.
434 * @dmabuf: [in] buffer to unmap page from.
435 * @page_num: [in] page in PAGE_SIZE units to unmap.
436 * @vaddr: [in] kernel space pointer obtained from dma_buf_kmap_atomic.
437 *
438 * This call must always succeed.
439 */
440void dma_buf_kunmap_atomic(struct dma_buf *dmabuf, unsigned long page_num,
441 void *vaddr)
442{
443 WARN_ON(!dmabuf);
444
445 if (dmabuf->ops->kunmap_atomic)
446 dmabuf->ops->kunmap_atomic(dmabuf, page_num, vaddr);
447}
448EXPORT_SYMBOL_GPL(dma_buf_kunmap_atomic);
449
450/**
451 * dma_buf_kmap - Map a page of the buffer object into kernel address space. The
452 * same restrictions as for kmap and friends apply.
453 * @dmabuf: [in] buffer to map page from.
454 * @page_num: [in] page in PAGE_SIZE units to map.
455 *
456 * This call must always succeed, any necessary preparations that might fail
457 * need to be done in begin_cpu_access.
458 */
459void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long page_num)
460{
461 WARN_ON(!dmabuf);
462
463 return dmabuf->ops->kmap(dmabuf, page_num);
464}
465EXPORT_SYMBOL_GPL(dma_buf_kmap);
466
467/**
468 * dma_buf_kunmap - Unmap a page obtained by dma_buf_kmap.
469 * @dmabuf: [in] buffer to unmap page from.
470 * @page_num: [in] page in PAGE_SIZE units to unmap.
471 * @vaddr: [in] kernel space pointer obtained from dma_buf_kmap.
472 *
473 * This call must always succeed.
474 */
475void dma_buf_kunmap(struct dma_buf *dmabuf, unsigned long page_num,
476 void *vaddr)
477{
478 WARN_ON(!dmabuf);
479
480 if (dmabuf->ops->kunmap)
481 dmabuf->ops->kunmap(dmabuf, page_num, vaddr);
482}
483EXPORT_SYMBOL_GPL(dma_buf_kunmap);
484
485
486/**
487 * dma_buf_mmap - Setup up a userspace mmap with the given vma
488 * @dmabuf: [in] buffer that should back the vma
489 * @vma: [in] vma for the mmap
490 * @pgoff: [in] offset in pages where this mmap should start within the
491 * dma-buf buffer.
492 *
493 * This function adjusts the passed in vma so that it points at the file of the
494 * dma_buf operation. It also adjusts the starting pgoff and does bounds
495 * checking on the size of the vma. Then it calls the exporters mmap function to
496 * set up the mapping.
497 *
498 * Can return negative error values, returns 0 on success.
499 */
500int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
501 unsigned long pgoff)
502{
503 struct file *oldfile;
504 int ret;
505
506 if (WARN_ON(!dmabuf || !vma))
507 return -EINVAL;
508
509 /* check for offset overflow */
510 if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) < pgoff)
511 return -EOVERFLOW;
512
513 /* check for overflowing the buffer's size */
514 if (pgoff + ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT) >
515 dmabuf->size >> PAGE_SHIFT)
516 return -EINVAL;
517
518 /* readjust the vma */
519 get_file(dmabuf->file);
520 oldfile = vma->vm_file;
521 vma->vm_file = dmabuf->file;
522 vma->vm_pgoff = pgoff;
523
524 ret = dmabuf->ops->mmap(dmabuf, vma);
525 if (ret) {
526 /* restore old parameters on failure */
527 vma->vm_file = oldfile;
528 fput(dmabuf->file);
529 } else {
530 if (oldfile)
531 fput(oldfile);
532 }
533 return ret;
534
535}
536EXPORT_SYMBOL_GPL(dma_buf_mmap);
537
538/**
539 * dma_buf_vmap - Create virtual mapping for the buffer object into kernel
540 * address space. Same restrictions as for vmap and friends apply.
541 * @dmabuf: [in] buffer to vmap
542 *
543 * This call may fail due to lack of virtual mapping address space.
544 * These calls are optional in drivers. The intended use for them
545 * is for mapping objects linear in kernel space for high use objects.
546 * Please attempt to use kmap/kunmap before thinking about these interfaces.
547 *
548 * Returns NULL on error.
549 */
550void *dma_buf_vmap(struct dma_buf *dmabuf)
551{
552 void *ptr;
553
554 if (WARN_ON(!dmabuf))
555 return NULL;
556
557 if (!dmabuf->ops->vmap)
558 return NULL;
559
560 mutex_lock(&dmabuf->lock);
561 if (dmabuf->vmapping_counter) {
562 dmabuf->vmapping_counter++;
563 BUG_ON(!dmabuf->vmap_ptr);
564 ptr = dmabuf->vmap_ptr;
565 goto out_unlock;
566 }
567
568 BUG_ON(dmabuf->vmap_ptr);
569
570 ptr = dmabuf->ops->vmap(dmabuf);
571 if (WARN_ON_ONCE(IS_ERR(ptr)))
572 ptr = NULL;
573 if (!ptr)
574 goto out_unlock;
575
576 dmabuf->vmap_ptr = ptr;
577 dmabuf->vmapping_counter = 1;
578
579out_unlock:
580 mutex_unlock(&dmabuf->lock);
581 return ptr;
582}
583EXPORT_SYMBOL_GPL(dma_buf_vmap);
584
585/**
586 * dma_buf_vunmap - Unmap a vmap obtained by dma_buf_vmap.
587 * @dmabuf: [in] buffer to vunmap
588 * @vaddr: [in] vmap to vunmap
589 */
590void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
591{
592 if (WARN_ON(!dmabuf))
593 return;
594
595 BUG_ON(!dmabuf->vmap_ptr);
596 BUG_ON(dmabuf->vmapping_counter == 0);
597 BUG_ON(dmabuf->vmap_ptr != vaddr);
598
599 mutex_lock(&dmabuf->lock);
600 if (--dmabuf->vmapping_counter == 0) {
601 if (dmabuf->ops->vunmap)
602 dmabuf->ops->vunmap(dmabuf, vaddr);
603 dmabuf->vmap_ptr = NULL;
604 }
605 mutex_unlock(&dmabuf->lock);
606}
607EXPORT_SYMBOL_GPL(dma_buf_vunmap);
608
609#ifdef CONFIG_DEBUG_FS
610static int dma_buf_describe(struct seq_file *s)
611{
612 int ret;
613 struct dma_buf *buf_obj;
614 struct dma_buf_attachment *attach_obj;
615 int count = 0, attach_count;
616 size_t size = 0;
617
618 ret = mutex_lock_interruptible(&db_list.lock);
619
620 if (ret)
621 return ret;
622
623 seq_puts(s, "\nDma-buf Objects:\n");
624 seq_puts(s, "size\tflags\tmode\tcount\texp_name\n");
625
626 list_for_each_entry(buf_obj, &db_list.head, list_node) {
627 ret = mutex_lock_interruptible(&buf_obj->lock);
628
629 if (ret) {
630 seq_puts(s,
631 "\tERROR locking buffer object: skipping\n");
632 continue;
633 }
634
635 seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\n",
636 buf_obj->size,
637 buf_obj->file->f_flags, buf_obj->file->f_mode,
638 (long)(buf_obj->file->f_count.counter),
639 buf_obj->exp_name);
640
641 seq_puts(s, "\tAttached Devices:\n");
642 attach_count = 0;
643
644 list_for_each_entry(attach_obj, &buf_obj->attachments, node) {
645 seq_puts(s, "\t");
646
647 seq_printf(s, "%s\n", dev_name(attach_obj->dev));
648 attach_count++;
649 }
650
651 seq_printf(s, "Total %d devices attached\n\n",
652 attach_count);
653
654 count++;
655 size += buf_obj->size;
656 mutex_unlock(&buf_obj->lock);
657 }
658
659 seq_printf(s, "\nTotal %d objects, %zu bytes\n", count, size);
660
661 mutex_unlock(&db_list.lock);
662 return 0;
663}
664
665static int dma_buf_show(struct seq_file *s, void *unused)
666{
667 void (*func)(struct seq_file *) = s->private;
668 func(s);
669 return 0;
670}
671
672static int dma_buf_debug_open(struct inode *inode, struct file *file)
673{
674 return single_open(file, dma_buf_show, inode->i_private);
675}
676
677static const struct file_operations dma_buf_debug_fops = {
678 .open = dma_buf_debug_open,
679 .read = seq_read,
680 .llseek = seq_lseek,
681 .release = single_release,
682};
683
684static struct dentry *dma_buf_debugfs_dir;
685
686static int dma_buf_init_debugfs(void)
687{
688 int err = 0;
689 dma_buf_debugfs_dir = debugfs_create_dir("dma_buf", NULL);
690 if (IS_ERR(dma_buf_debugfs_dir)) {
691 err = PTR_ERR(dma_buf_debugfs_dir);
692 dma_buf_debugfs_dir = NULL;
693 return err;
694 }
695
696 err = dma_buf_debugfs_create_file("bufinfo", dma_buf_describe);
697
698 if (err)
699 pr_debug("dma_buf: debugfs: failed to create node bufinfo\n");
700
701 return err;
702}
703
704static void dma_buf_uninit_debugfs(void)
705{
706 if (dma_buf_debugfs_dir)
707 debugfs_remove_recursive(dma_buf_debugfs_dir);
708}
709
710int dma_buf_debugfs_create_file(const char *name,
711 int (*write)(struct seq_file *))
712{
713 struct dentry *d;
714
715 d = debugfs_create_file(name, S_IRUGO, dma_buf_debugfs_dir,
716 write, &dma_buf_debug_fops);
717
718 return PTR_ERR_OR_ZERO(d);
719}
720#else
721static inline int dma_buf_init_debugfs(void)
722{
723 return 0;
724}
725static inline void dma_buf_uninit_debugfs(void)
726{
727}
728#endif
729
730static int __init dma_buf_init(void)
731{
732 mutex_init(&db_list.lock);
733 INIT_LIST_HEAD(&db_list.head);
734 dma_buf_init_debugfs();
735 return 0;
736}
737subsys_initcall(dma_buf_init);
738
739static void __exit dma_buf_deinit(void)
740{
741 dma_buf_uninit_debugfs();
742}
743__exitcall(dma_buf_deinit);
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d276e33880be..da77791793f1 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -100,10 +100,16 @@ static inline long firmware_loading_timeout(void)
100#define FW_OPT_UEVENT (1U << 0) 100#define FW_OPT_UEVENT (1U << 0)
101#define FW_OPT_NOWAIT (1U << 1) 101#define FW_OPT_NOWAIT (1U << 1)
102#ifdef CONFIG_FW_LOADER_USER_HELPER 102#ifdef CONFIG_FW_LOADER_USER_HELPER
103#define FW_OPT_FALLBACK (1U << 2) 103#define FW_OPT_USERHELPER (1U << 2)
104#else 104#else
105#define FW_OPT_FALLBACK 0 105#define FW_OPT_USERHELPER 0
106#endif 106#endif
107#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
108#define FW_OPT_FALLBACK FW_OPT_USERHELPER
109#else
110#define FW_OPT_FALLBACK 0
111#endif
112#define FW_OPT_NO_WARN (1U << 3)
107 113
108struct firmware_cache { 114struct firmware_cache {
109 /* firmware_buf instance will be added into the below list */ 115 /* firmware_buf instance will be added into the below list */
@@ -279,26 +285,15 @@ static const char * const fw_path[] = {
279module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); 285module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
280MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); 286MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
281 287
282/* Don't inline this: 'struct kstat' is biggish */
283static noinline_for_stack int fw_file_size(struct file *file)
284{
285 struct kstat st;
286 if (vfs_getattr(&file->f_path, &st))
287 return -1;
288 if (!S_ISREG(st.mode))
289 return -1;
290 if (st.size != (int)st.size)
291 return -1;
292 return st.size;
293}
294
295static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) 288static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
296{ 289{
297 int size; 290 int size;
298 char *buf; 291 char *buf;
299 int rc; 292 int rc;
300 293
301 size = fw_file_size(file); 294 if (!S_ISREG(file_inode(file)->i_mode))
295 return -EINVAL;
296 size = i_size_read(file_inode(file));
302 if (size <= 0) 297 if (size <= 0)
303 return -EINVAL; 298 return -EINVAL;
304 buf = vmalloc(size); 299 buf = vmalloc(size);
@@ -718,7 +713,7 @@ out:
718static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) 713static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
719{ 714{
720 struct firmware_buf *buf = fw_priv->buf; 715 struct firmware_buf *buf = fw_priv->buf;
721 int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; 716 int pages_needed = PAGE_ALIGN(min_size) >> PAGE_SHIFT;
722 717
723 /* If the array of pages is too small, grow it... */ 718 /* If the array of pages is too small, grow it... */
724 if (buf->page_array_size < pages_needed) { 719 if (buf->page_array_size < pages_needed) {
@@ -911,7 +906,9 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
911 wait_for_completion(&buf->completion); 906 wait_for_completion(&buf->completion);
912 907
913 cancel_delayed_work_sync(&fw_priv->timeout_work); 908 cancel_delayed_work_sync(&fw_priv->timeout_work);
914 if (!buf->data) 909 if (is_fw_load_aborted(buf))
910 retval = -EAGAIN;
911 else if (!buf->data)
915 retval = -ENOMEM; 912 retval = -ENOMEM;
916 913
917 device_remove_file(f_dev, &dev_attr_loading); 914 device_remove_file(f_dev, &dev_attr_loading);
@@ -1111,10 +1108,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
1111 1108
1112 ret = fw_get_filesystem_firmware(device, fw->priv); 1109 ret = fw_get_filesystem_firmware(device, fw->priv);
1113 if (ret) { 1110 if (ret) {
1114 if (opt_flags & FW_OPT_FALLBACK) { 1111 if (!(opt_flags & FW_OPT_NO_WARN))
1115 dev_warn(device, 1112 dev_warn(device,
1116 "Direct firmware load failed with error %d\n", 1113 "Direct firmware load for %s failed with error %d\n",
1117 ret); 1114 name, ret);
1115 if (opt_flags & FW_OPT_USERHELPER) {
1118 dev_warn(device, "Falling back to user helper\n"); 1116 dev_warn(device, "Falling back to user helper\n");
1119 ret = fw_load_from_user_helper(fw, name, device, 1117 ret = fw_load_from_user_helper(fw, name, device,
1120 opt_flags, timeout); 1118 opt_flags, timeout);
@@ -1171,7 +1169,6 @@ request_firmware(const struct firmware **firmware_p, const char *name,
1171} 1169}
1172EXPORT_SYMBOL(request_firmware); 1170EXPORT_SYMBOL(request_firmware);
1173 1171
1174#ifdef CONFIG_FW_LOADER_USER_HELPER
1175/** 1172/**
1176 * request_firmware: - load firmware directly without usermode helper 1173 * request_firmware: - load firmware directly without usermode helper
1177 * @firmware_p: pointer to firmware image 1174 * @firmware_p: pointer to firmware image
@@ -1188,12 +1185,12 @@ int request_firmware_direct(const struct firmware **firmware_p,
1188{ 1185{
1189 int ret; 1186 int ret;
1190 __module_get(THIS_MODULE); 1187 __module_get(THIS_MODULE);
1191 ret = _request_firmware(firmware_p, name, device, FW_OPT_UEVENT); 1188 ret = _request_firmware(firmware_p, name, device,
1189 FW_OPT_UEVENT | FW_OPT_NO_WARN);
1192 module_put(THIS_MODULE); 1190 module_put(THIS_MODULE);
1193 return ret; 1191 return ret;
1194} 1192}
1195EXPORT_SYMBOL_GPL(request_firmware_direct); 1193EXPORT_SYMBOL_GPL(request_firmware_direct);
1196#endif
1197 1194
1198/** 1195/**
1199 * release_firmware: - release the resource associated with a firmware image 1196 * release_firmware: - release the resource associated with a firmware image
@@ -1277,7 +1274,7 @@ request_firmware_nowait(
1277 fw_work->context = context; 1274 fw_work->context = context;
1278 fw_work->cont = cont; 1275 fw_work->cont = cont;
1279 fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK | 1276 fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK |
1280 (uevent ? FW_OPT_UEVENT : 0); 1277 (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
1281 1278
1282 if (!try_module_get(module)) { 1279 if (!try_module_get(module)) {
1283 kfree(fw_work); 1280 kfree(fw_work);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 00f2208949d1..ab4f4ce02722 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -24,6 +24,7 @@
24#include <linux/idr.h> 24#include <linux/idr.h>
25#include <linux/acpi.h> 25#include <linux/acpi.h>
26#include <linux/clk/clk-conf.h> 26#include <linux/clk/clk-conf.h>
27#include <linux/limits.h>
27 28
28#include "base.h" 29#include "base.h"
29#include "power/power.h" 30#include "power/power.h"
@@ -176,7 +177,7 @@ EXPORT_SYMBOL_GPL(platform_add_devices);
176 177
177struct platform_object { 178struct platform_object {
178 struct platform_device pdev; 179 struct platform_device pdev;
179 char name[1]; 180 char name[];
180}; 181};
181 182
182/** 183/**
@@ -202,6 +203,7 @@ static void platform_device_release(struct device *dev)
202 kfree(pa->pdev.dev.platform_data); 203 kfree(pa->pdev.dev.platform_data);
203 kfree(pa->pdev.mfd_cell); 204 kfree(pa->pdev.mfd_cell);
204 kfree(pa->pdev.resource); 205 kfree(pa->pdev.resource);
206 kfree(pa->pdev.driver_override);
205 kfree(pa); 207 kfree(pa);
206} 208}
207 209
@@ -217,7 +219,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
217{ 219{
218 struct platform_object *pa; 220 struct platform_object *pa;
219 221
220 pa = kzalloc(sizeof(struct platform_object) + strlen(name), GFP_KERNEL); 222 pa = kzalloc(sizeof(*pa) + strlen(name) + 1, GFP_KERNEL);
221 if (pa) { 223 if (pa) {
222 strcpy(pa->name, name); 224 strcpy(pa->name, name);
223 pa->pdev.name = pa->name; 225 pa->pdev.name = pa->name;
@@ -713,8 +715,49 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
713} 715}
714static DEVICE_ATTR_RO(modalias); 716static DEVICE_ATTR_RO(modalias);
715 717
718static ssize_t driver_override_store(struct device *dev,
719 struct device_attribute *attr,
720 const char *buf, size_t count)
721{
722 struct platform_device *pdev = to_platform_device(dev);
723 char *driver_override, *old = pdev->driver_override, *cp;
724
725 if (count > PATH_MAX)
726 return -EINVAL;
727
728 driver_override = kstrndup(buf, count, GFP_KERNEL);
729 if (!driver_override)
730 return -ENOMEM;
731
732 cp = strchr(driver_override, '\n');
733 if (cp)
734 *cp = '\0';
735
736 if (strlen(driver_override)) {
737 pdev->driver_override = driver_override;
738 } else {
739 kfree(driver_override);
740 pdev->driver_override = NULL;
741 }
742
743 kfree(old);
744
745 return count;
746}
747
748static ssize_t driver_override_show(struct device *dev,
749 struct device_attribute *attr, char *buf)
750{
751 struct platform_device *pdev = to_platform_device(dev);
752
753 return sprintf(buf, "%s\n", pdev->driver_override);
754}
755static DEVICE_ATTR_RW(driver_override);
756
757
716static struct attribute *platform_dev_attrs[] = { 758static struct attribute *platform_dev_attrs[] = {
717 &dev_attr_modalias.attr, 759 &dev_attr_modalias.attr,
760 &dev_attr_driver_override.attr,
718 NULL, 761 NULL,
719}; 762};
720ATTRIBUTE_GROUPS(platform_dev); 763ATTRIBUTE_GROUPS(platform_dev);
@@ -770,6 +813,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
770 struct platform_device *pdev = to_platform_device(dev); 813 struct platform_device *pdev = to_platform_device(dev);
771 struct platform_driver *pdrv = to_platform_driver(drv); 814 struct platform_driver *pdrv = to_platform_driver(drv);
772 815
816 /* When driver_override is set, only bind to the matching driver */
817 if (pdev->driver_override)
818 return !strcmp(pdev->driver_override, drv->name);
819
773 /* Attempt an OF style match first */ 820 /* Attempt an OF style match first */
774 if (of_driver_match_device(dev, drv)) 821 if (of_driver_match_device(dev, drv))
775 return 1; 822 return 1;
diff --git a/drivers/base/reservation.c b/drivers/base/reservation.c
deleted file mode 100644
index a73fbf3b8e56..000000000000
--- a/drivers/base/reservation.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2012-2013 Canonical Ltd
3 *
4 * Based on bo.c which bears the following copyright notice,
5 * but is dual licensed:
6 *
7 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
8 * All Rights Reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sub license, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice (including the
19 * next paragraph) shall be included in all copies or substantial portions
20 * of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
25 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
26 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
28 * USE OR OTHER DEALINGS IN THE SOFTWARE.
29 *
30 **************************************************************************/
31/*
32 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
33 */
34
35#include <linux/reservation.h>
36#include <linux/export.h>
37
38DEFINE_WW_CLASS(reservation_ww_class);
39EXPORT_SYMBOL(reservation_ww_class);