Skip to content

Commit c4be50e

Browse files
committed
Merge tag 'driver-core-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH: "Here's the driver-core / kobject / lz4 tree update for 4.1-rc1. Everything here has been in linux-next for a while with no reported issues. It's mostly just coding style cleanups, with other minor changes in here as well, nothing big" * tag 'driver-core-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits) debugfs: allow bad parent pointers to be passed in stable_kernel_rules: Add clause about specification of kernel versions to patch. kobject: WARN as tip when call kobject_get() to a kobject not initialized lib/lz4: Pull out constant tables drivers: platform: parse IRQ flags from resources driver core: Make probe deferral more quiet drivers/core/of: Add symlink to device-tree from devices with an OF node device: Add dev_of_node() accessor drivers: base: fw: fix ret value when loading fw firmware: Avoid manual device_create_file() calls drivers/base: cacheinfo: validate device node for all the caches drivers/base: use tabs where possible in code indentation driver core: add missing blank line after declaration drivers: base: node: Delete space after pointer declaration drivers: base: memory: Use tabs instead of spaces firmware_class: Fix whitespace and indentation drivers: base: dma-mapping: Erase blank space after pointer drivers: base: class: Add a blank line after declarations attribute_container: fix missing blank lines after declarations drivers: base: memory: Fix switch indent ...
2 parents 42e3a58 + c9e15f2 commit c4be50e

File tree

25 files changed

+219
-112
lines changed

25 files changed

+219
-112
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Note: This documents additional properties of any device beyond what
2+
# is documented in Documentation/sysfs-rules.txt
3+
4+
What: /sys/devices/*/of_path
5+
Date: February 2015
6+
Contact: Device Tree mailing list <[email protected]>
7+
Description:
8+
Any device associated with a device-tree node will have
9+
an of_path symlink pointing to the corresponding device
10+
node in /sys/firmware/devicetree/

Documentation/stable_kernel_rules.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ format in the sign-off area:
8181
git cherry-pick fd21073
8282
git cherry-pick <this commit>
8383

84+
Also, some patches may have kernel version prerequisites. This can be
85+
specified in the following format in the sign-off area:
86+
87+
Cc: <[email protected]> # 3.3.x-
88+
89+
The tag has the meaning of:
90+
git cherry-pick <this commit>
91+
92+
For each "-stable" tree starting with the specified version.
93+
8494
Following the submission:
8595

8696
- The sender will receive an ACK when the patch has been accepted into the

drivers/base/attribute_container.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ int
9494
attribute_container_unregister(struct attribute_container *cont)
9595
{
9696
int retval = -EBUSY;
97+
9798
mutex_lock(&attribute_container_mutex);
9899
spin_lock(&cont->containers.k_lock);
99100
if (!list_empty(&cont->containers.k_list))
@@ -349,6 +350,7 @@ int
349350
attribute_container_add_class_device(struct device *classdev)
350351
{
351352
int error = device_add(classdev);
353+
352354
if (error)
353355
return error;
354356
return attribute_container_add_attrs(classdev);

drivers/base/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ int bus_add_device(struct device *dev)
515515
goto out_put;
516516
error = device_add_groups(dev, bus->dev_groups);
517517
if (error)
518-
goto out_groups;
518+
goto out_id;
519519
error = sysfs_create_link(&bus->p->devices_kset->kobj,
520520
&dev->kobj, dev_name(dev));
521521
if (error)
522-
goto out_id;
522+
goto out_groups;
523523
error = sysfs_create_link(&dev->kobj,
524524
&dev->bus->p->subsys.kobj, "subsystem");
525525
if (error)

drivers/base/cacheinfo.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,21 @@ static int cache_setup_of_node(unsigned int cpu)
6262
return -ENOENT;
6363
}
6464

65-
while (np && index < cache_leaves(cpu)) {
65+
while (index < cache_leaves(cpu)) {
6666
this_leaf = this_cpu_ci->info_list + index;
6767
if (this_leaf->level != 1)
6868
np = of_find_next_cache_node(np);
6969
else
7070
np = of_node_get(np);/* cpu node itself */
71+
if (!np)
72+
break;
7173
this_leaf->of_node = np;
7274
index++;
7375
}
76+
77+
if (index != cache_leaves(cpu)) /* not all OF nodes populated */
78+
return -ENOENT;
79+
7480
return 0;
7581
}
7682

@@ -189,8 +195,11 @@ static int detect_cache_attributes(unsigned int cpu)
189195
* will be set up here only if they are not populated already
190196
*/
191197
ret = cache_shared_cpu_map_setup(cpu);
192-
if (ret)
198+
if (ret) {
199+
pr_warn("Unable to detect cache hierarcy from DT for CPU %d\n",
200+
cpu);
193201
goto free_ci;
202+
}
194203
return 0;
195204

196205
free_ci:

drivers/base/class.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
9090
const void *ns)
9191
{
9292
int error;
93+
9394
if (cls)
9495
error = sysfs_create_file_ns(&cls->p->subsys.kobj,
9596
&attr->attr, ns);
@@ -488,6 +489,7 @@ ssize_t show_class_attr_string(struct class *class,
488489
struct class_attribute *attr, char *buf)
489490
{
490491
struct class_attribute_string *cs;
492+
491493
cs = container_of(attr, struct class_attribute_string, attr);
492494
return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
493495
}

drivers/base/core.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,16 +805,24 @@ static void cleanup_device_parent(struct device *dev)
805805

806806
static int device_add_class_symlinks(struct device *dev)
807807
{
808+
struct device_node *of_node = dev_of_node(dev);
808809
int error;
809810

811+
if (of_node) {
812+
error = sysfs_create_link(&dev->kobj, &of_node->kobj,"of_node");
813+
if (error)
814+
dev_warn(dev, "Error %d creating of_node link\n",error);
815+
/* An error here doesn't warrant bringing down the device */
816+
}
817+
810818
if (!dev->class)
811819
return 0;
812820

813821
error = sysfs_create_link(&dev->kobj,
814822
&dev->class->p->subsys.kobj,
815823
"subsystem");
816824
if (error)
817-
goto out;
825+
goto out_devnode;
818826

819827
if (dev->parent && device_is_not_partition(dev)) {
820828
error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
@@ -842,12 +850,16 @@ static int device_add_class_symlinks(struct device *dev)
842850

843851
out_subsys:
844852
sysfs_remove_link(&dev->kobj, "subsystem");
845-
out:
853+
out_devnode:
854+
sysfs_remove_link(&dev->kobj, "of_node");
846855
return error;
847856
}
848857

849858
static void device_remove_class_symlinks(struct device *dev)
850859
{
860+
if (dev_of_node(dev))
861+
sysfs_remove_link(&dev->kobj, "of_node");
862+
851863
if (!dev->class)
852864
return;
853865

@@ -1095,8 +1107,7 @@ int device_add(struct device *dev)
10951107
kobject_del(&dev->kobj);
10961108
Error:
10971109
cleanup_device_parent(dev);
1098-
if (parent)
1099-
put_device(parent);
1110+
put_device(parent);
11001111
name_error:
11011112
kfree(dev->p);
11021113
dev->p = NULL;

drivers/base/dd.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,21 +320,25 @@ static int really_probe(struct device *dev, struct device_driver *drv)
320320
dev->driver = NULL;
321321
dev_set_drvdata(dev, NULL);
322322

323-
if (ret == -EPROBE_DEFER) {
323+
switch (ret) {
324+
case -EPROBE_DEFER:
324325
/* Driver requested deferred probing */
325-
dev_info(dev, "Driver %s requests probe deferral\n", drv->name);
326+
dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
326327
driver_deferred_probe_add(dev);
327328
/* Did a trigger occur while probing? Need to re-trigger if yes */
328329
if (local_trigger_count != atomic_read(&deferred_trigger_count))
329330
driver_deferred_probe_trigger();
330-
} else if (ret != -ENODEV && ret != -ENXIO) {
331+
break;
332+
case -ENODEV:
333+
case -ENXIO:
334+
pr_debug("%s: probe of %s rejects match %d\n",
335+
drv->name, dev_name(dev), ret);
336+
break;
337+
default:
331338
/* driver matched but the probe failed */
332339
printk(KERN_WARNING
333340
"%s: probe of %s failed with error %d\n",
334341
drv->name, dev_name(dev), ret);
335-
} else {
336-
pr_debug("%s: probe of %s rejects match %d\n",
337-
drv->name, dev_name(dev), ret);
338342
}
339343
/*
340344
* Ignore errors returned by ->probe so that the next driver can try

drivers/base/dma-mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int dmam_match(struct device *dev, void *res, void *match_data)
6262
* RETURNS:
6363
* Pointer to allocated memory on success, NULL on failure.
6464
*/
65-
void * dmam_alloc_coherent(struct device *dev, size_t size,
65+
void *dmam_alloc_coherent(struct device *dev, size_t size,
6666
dma_addr_t *dma_handle, gfp_t gfp)
6767
{
6868
struct dma_devres *dr;

drivers/base/driver.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ int driver_create_file(struct device_driver *drv,
103103
const struct driver_attribute *attr)
104104
{
105105
int error;
106+
106107
if (drv)
107108
error = sysfs_create_file(&drv->p->kobj, &attr->attr);
108109
else

drivers/base/firmware_class.c

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
181181
{
182182
struct firmware_buf *buf;
183183

184-
buf = kzalloc(sizeof(*buf) + strlen(fw_name) + 1 , GFP_ATOMIC);
184+
buf = kzalloc(sizeof(*buf) + strlen(fw_name) + 1, GFP_ATOMIC);
185185

186186
if (!buf)
187187
return buf;
@@ -835,6 +835,26 @@ static struct bin_attribute firmware_attr_data = {
835835
.write = firmware_data_write,
836836
};
837837

838+
static struct attribute *fw_dev_attrs[] = {
839+
&dev_attr_loading.attr,
840+
NULL
841+
};
842+
843+
static struct bin_attribute *fw_dev_bin_attrs[] = {
844+
&firmware_attr_data,
845+
NULL
846+
};
847+
848+
static const struct attribute_group fw_dev_attr_group = {
849+
.attrs = fw_dev_attrs,
850+
.bin_attrs = fw_dev_bin_attrs,
851+
};
852+
853+
static const struct attribute_group *fw_dev_attr_groups[] = {
854+
&fw_dev_attr_group,
855+
NULL
856+
};
857+
838858
static struct firmware_priv *
839859
fw_create_instance(struct firmware *firmware, const char *fw_name,
840860
struct device *device, unsigned int opt_flags)
@@ -856,6 +876,7 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
856876
dev_set_name(f_dev, "%s", fw_name);
857877
f_dev->parent = device;
858878
f_dev->class = &firmware_class;
879+
f_dev->groups = fw_dev_attr_groups;
859880
exit:
860881
return fw_priv;
861882
}
@@ -879,25 +900,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
879900
goto err_put_dev;
880901
}
881902

882-
retval = device_create_bin_file(f_dev, &firmware_attr_data);
883-
if (retval) {
884-
dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__);
885-
goto err_del_dev;
886-
}
887-
888903
mutex_lock(&fw_lock);
889904
list_add(&buf->pending_list, &pending_fw_head);
890905
mutex_unlock(&fw_lock);
891906

892-
retval = device_create_file(f_dev, &dev_attr_loading);
893-
if (retval) {
894-
mutex_lock(&fw_lock);
895-
list_del_init(&buf->pending_list);
896-
mutex_unlock(&fw_lock);
897-
dev_err(f_dev, "%s: device_create_file failed\n", __func__);
898-
goto err_del_bin_attr;
899-
}
900-
901907
if (opt_flags & FW_OPT_UEVENT) {
902908
buf->need_uevent = true;
903909
dev_set_uevent_suppress(f_dev, false);
@@ -913,17 +919,15 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
913919
mutex_lock(&fw_lock);
914920
fw_load_abort(fw_priv);
915921
mutex_unlock(&fw_lock);
922+
} else if (retval > 0) {
923+
retval = 0;
916924
}
917925

918926
if (is_fw_load_aborted(buf))
919927
retval = -EAGAIN;
920928
else if (!buf->data)
921929
retval = -ENOMEM;
922930

923-
device_remove_file(f_dev, &dev_attr_loading);
924-
err_del_bin_attr:
925-
device_remove_bin_file(f_dev, &firmware_attr_data);
926-
err_del_dev:
927931
device_del(f_dev);
928932
err_put_dev:
929933
put_device(f_dev);
@@ -1168,7 +1172,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
11681172
**/
11691173
int
11701174
request_firmware(const struct firmware **firmware_p, const char *name,
1171-
struct device *device)
1175+
struct device *device)
11721176
{
11731177
int ret;
11741178

@@ -1196,6 +1200,7 @@ int request_firmware_direct(const struct firmware **firmware_p,
11961200
const char *name, struct device *device)
11971201
{
11981202
int ret;
1203+
11991204
__module_get(THIS_MODULE);
12001205
ret = _request_firmware(firmware_p, name, device,
12011206
FW_OPT_UEVENT | FW_OPT_NO_WARN);
@@ -1276,7 +1281,7 @@ request_firmware_nowait(
12761281
{
12771282
struct firmware_work *fw_work;
12781283

1279-
fw_work = kzalloc(sizeof (struct firmware_work), gfp);
1284+
fw_work = kzalloc(sizeof(struct firmware_work), gfp);
12801285
if (!fw_work)
12811286
return -ENOMEM;
12821287

drivers/base/map.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range,
4141
if (n > 255)
4242
n = 255;
4343

44-
p = kmalloc(sizeof(struct probe) * n, GFP_KERNEL);
45-
44+
p = kmalloc_array(n, sizeof(struct probe), GFP_KERNEL);
4645
if (p == NULL)
4746
return -ENOMEM;
4847

0 commit comments

Comments
 (0)