Skip to content

Commit

Permalink
Merge tag 'driver-core-4.1-rc1' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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
  ...
  • Loading branch information
Linus Torvalds committed Apr 14, 2015
2 parents 42e3a58 + c9e15f2 commit c4be50e
Show file tree
Hide file tree
Showing 25 changed files with 219 additions and 112 deletions.
10 changes: 10 additions & 0 deletions Documentation/ABI/stable/sysfs-devices
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Note: This documents additional properties of any device beyond what
# is documented in Documentation/sysfs-rules.txt

What: /sys/devices/*/of_path
Date: February 2015
Contact: Device Tree mailing list <devicetree@vger.kernel.org>
Description:
Any device associated with a device-tree node will have
an of_path symlink pointing to the corresponding device
node in /sys/firmware/devicetree/
10 changes: 10 additions & 0 deletions Documentation/stable_kernel_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ format in the sign-off area:
git cherry-pick fd21073
git cherry-pick <this commit>

Also, some patches may have kernel version prerequisites. This can be
specified in the following format in the sign-off area:

Cc: <stable@vger.kernel.org> # 3.3.x-

The tag has the meaning of:
git cherry-pick <this commit>

For each "-stable" tree starting with the specified version.

Following the submission:

- The sender will receive an ACK when the patch has been accepted into the
Expand Down
2 changes: 2 additions & 0 deletions drivers/base/attribute_container.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ int
attribute_container_unregister(struct attribute_container *cont)
{
int retval = -EBUSY;

mutex_lock(&attribute_container_mutex);
spin_lock(&cont->containers.k_lock);
if (!list_empty(&cont->containers.k_list))
Expand Down Expand Up @@ -349,6 +350,7 @@ int
attribute_container_add_class_device(struct device *classdev)
{
int error = device_add(classdev);

if (error)
return error;
return attribute_container_add_attrs(classdev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ int bus_add_device(struct device *dev)
goto out_put;
error = device_add_groups(dev, bus->dev_groups);
if (error)
goto out_groups;
goto out_id;
error = sysfs_create_link(&bus->p->devices_kset->kobj,
&dev->kobj, dev_name(dev));
if (error)
goto out_id;
goto out_groups;
error = sysfs_create_link(&dev->kobj,
&dev->bus->p->subsys.kobj, "subsystem");
if (error)
Expand Down
13 changes: 11 additions & 2 deletions drivers/base/cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ static int cache_setup_of_node(unsigned int cpu)
return -ENOENT;
}

while (np && index < cache_leaves(cpu)) {
while (index < cache_leaves(cpu)) {
this_leaf = this_cpu_ci->info_list + index;
if (this_leaf->level != 1)
np = of_find_next_cache_node(np);
else
np = of_node_get(np);/* cpu node itself */
if (!np)
break;
this_leaf->of_node = np;
index++;
}

if (index != cache_leaves(cpu)) /* not all OF nodes populated */
return -ENOENT;

return 0;
}

Expand Down Expand Up @@ -189,8 +195,11 @@ static int detect_cache_attributes(unsigned int cpu)
* will be set up here only if they are not populated already
*/
ret = cache_shared_cpu_map_setup(cpu);
if (ret)
if (ret) {
pr_warn("Unable to detect cache hierarcy from DT for CPU %d\n",
cpu);
goto free_ci;
}
return 0;

free_ci:
Expand Down
2 changes: 2 additions & 0 deletions drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
const void *ns)
{
int error;

if (cls)
error = sysfs_create_file_ns(&cls->p->subsys.kobj,
&attr->attr, ns);
Expand Down Expand Up @@ -488,6 +489,7 @@ ssize_t show_class_attr_string(struct class *class,
struct class_attribute *attr, char *buf)
{
struct class_attribute_string *cs;

cs = container_of(attr, struct class_attribute_string, attr);
return snprintf(buf, PAGE_SIZE, "%s\n", cs->str);
}
Expand Down
19 changes: 15 additions & 4 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,16 +805,24 @@ static void cleanup_device_parent(struct device *dev)

static int device_add_class_symlinks(struct device *dev)
{
struct device_node *of_node = dev_of_node(dev);
int error;

if (of_node) {
error = sysfs_create_link(&dev->kobj, &of_node->kobj,"of_node");
if (error)
dev_warn(dev, "Error %d creating of_node link\n",error);
/* An error here doesn't warrant bringing down the device */
}

if (!dev->class)
return 0;

error = sysfs_create_link(&dev->kobj,
&dev->class->p->subsys.kobj,
"subsystem");
if (error)
goto out;
goto out_devnode;

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

out_subsys:
sysfs_remove_link(&dev->kobj, "subsystem");
out:
out_devnode:
sysfs_remove_link(&dev->kobj, "of_node");
return error;
}

static void device_remove_class_symlinks(struct device *dev)
{
if (dev_of_node(dev))
sysfs_remove_link(&dev->kobj, "of_node");

if (!dev->class)
return;

Expand Down Expand Up @@ -1095,8 +1107,7 @@ int device_add(struct device *dev)
kobject_del(&dev->kobj);
Error:
cleanup_device_parent(dev);
if (parent)
put_device(parent);
put_device(parent);
name_error:
kfree(dev->p);
dev->p = NULL;
Expand Down
16 changes: 10 additions & 6 deletions drivers/base/dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,21 +320,25 @@ static int really_probe(struct device *dev, struct device_driver *drv)
dev->driver = NULL;
dev_set_drvdata(dev, NULL);

if (ret == -EPROBE_DEFER) {
switch (ret) {
case -EPROBE_DEFER:
/* Driver requested deferred probing */
dev_info(dev, "Driver %s requests probe deferral\n", drv->name);
dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
driver_deferred_probe_add(dev);
/* Did a trigger occur while probing? Need to re-trigger if yes */
if (local_trigger_count != atomic_read(&deferred_trigger_count))
driver_deferred_probe_trigger();
} else if (ret != -ENODEV && ret != -ENXIO) {
break;
case -ENODEV:
case -ENXIO:
pr_debug("%s: probe of %s rejects match %d\n",
drv->name, dev_name(dev), ret);
break;
default:
/* driver matched but the probe failed */
printk(KERN_WARNING
"%s: probe of %s failed with error %d\n",
drv->name, dev_name(dev), ret);
} else {
pr_debug("%s: probe of %s rejects match %d\n",
drv->name, dev_name(dev), ret);
}
/*
* Ignore errors returned by ->probe so that the next driver can try
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static int dmam_match(struct device *dev, void *res, void *match_data)
* RETURNS:
* Pointer to allocated memory on success, NULL on failure.
*/
void * dmam_alloc_coherent(struct device *dev, size_t size,
void *dmam_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp)
{
struct dma_devres *dr;
Expand Down
1 change: 1 addition & 0 deletions drivers/base/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ int driver_create_file(struct device_driver *drv,
const struct driver_attribute *attr)
{
int error;

if (drv)
error = sysfs_create_file(&drv->p->kobj, &attr->attr);
else
Expand Down
49 changes: 27 additions & 22 deletions drivers/base/firmware_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
{
struct firmware_buf *buf;

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

if (!buf)
return buf;
Expand Down Expand Up @@ -835,6 +835,26 @@ static struct bin_attribute firmware_attr_data = {
.write = firmware_data_write,
};

static struct attribute *fw_dev_attrs[] = {
&dev_attr_loading.attr,
NULL
};

static struct bin_attribute *fw_dev_bin_attrs[] = {
&firmware_attr_data,
NULL
};

static const struct attribute_group fw_dev_attr_group = {
.attrs = fw_dev_attrs,
.bin_attrs = fw_dev_bin_attrs,
};

static const struct attribute_group *fw_dev_attr_groups[] = {
&fw_dev_attr_group,
NULL
};

static struct firmware_priv *
fw_create_instance(struct firmware *firmware, const char *fw_name,
struct device *device, unsigned int opt_flags)
Expand All @@ -856,6 +876,7 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
dev_set_name(f_dev, "%s", fw_name);
f_dev->parent = device;
f_dev->class = &firmware_class;
f_dev->groups = fw_dev_attr_groups;
exit:
return fw_priv;
}
Expand All @@ -879,25 +900,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
goto err_put_dev;
}

retval = device_create_bin_file(f_dev, &firmware_attr_data);
if (retval) {
dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__);
goto err_del_dev;
}

mutex_lock(&fw_lock);
list_add(&buf->pending_list, &pending_fw_head);
mutex_unlock(&fw_lock);

retval = device_create_file(f_dev, &dev_attr_loading);
if (retval) {
mutex_lock(&fw_lock);
list_del_init(&buf->pending_list);
mutex_unlock(&fw_lock);
dev_err(f_dev, "%s: device_create_file failed\n", __func__);
goto err_del_bin_attr;
}

if (opt_flags & FW_OPT_UEVENT) {
buf->need_uevent = true;
dev_set_uevent_suppress(f_dev, false);
Expand All @@ -913,17 +919,15 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
mutex_lock(&fw_lock);
fw_load_abort(fw_priv);
mutex_unlock(&fw_lock);
} else if (retval > 0) {
retval = 0;
}

if (is_fw_load_aborted(buf))
retval = -EAGAIN;
else if (!buf->data)
retval = -ENOMEM;

device_remove_file(f_dev, &dev_attr_loading);
err_del_bin_attr:
device_remove_bin_file(f_dev, &firmware_attr_data);
err_del_dev:
device_del(f_dev);
err_put_dev:
put_device(f_dev);
Expand Down Expand Up @@ -1168,7 +1172,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
**/
int
request_firmware(const struct firmware **firmware_p, const char *name,
struct device *device)
struct device *device)
{
int ret;

Expand Down Expand Up @@ -1196,6 +1200,7 @@ int request_firmware_direct(const struct firmware **firmware_p,
const char *name, struct device *device)
{
int ret;

__module_get(THIS_MODULE);
ret = _request_firmware(firmware_p, name, device,
FW_OPT_UEVENT | FW_OPT_NO_WARN);
Expand Down Expand Up @@ -1276,7 +1281,7 @@ request_firmware_nowait(
{
struct firmware_work *fw_work;

fw_work = kzalloc(sizeof (struct firmware_work), gfp);
fw_work = kzalloc(sizeof(struct firmware_work), gfp);
if (!fw_work)
return -ENOMEM;

Expand Down
3 changes: 1 addition & 2 deletions drivers/base/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range,
if (n > 255)
n = 255;

p = kmalloc(sizeof(struct probe) * n, GFP_KERNEL);

p = kmalloc_array(n, sizeof(struct probe), GFP_KERNEL);
if (p == NULL)
return -ENOMEM;

Expand Down
Loading

0 comments on commit c4be50e

Please sign in to comment.