Skip to content

Commit

Permalink
Merge tag 'driver-core-5.14-rc1' of git://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/gregkh/driver-core

Pull driver core changes from Greg KH:
 "Here is the small set of driver core and debugfs updates for 5.14-rc1.

  Included in here are:

   - debugfs api cleanups (touched some drivers)

   - devres updates

   - tiny driver core updates and tweaks

  Nothing major in here at all, and all have been in linux-next for a
  while with no reported issues"

* tag 'driver-core-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (27 commits)
  docs: ABI: testing: sysfs-firmware-memmap: add some memmap types.
  devres: Enable trace events
  devres: No need to call remove_nodes() when there none present
  devres: Use list_for_each_safe_from() in remove_nodes()
  devres: Make locking straight forward in release_nodes()
  kernfs: move revalidate to be near lookup
  drivers/base: Constify static attribute_group structs
  firmware_loader: remove unneeded 'comma' macro
  devcoredump: remove contact information
  driver core: Drop helper devm_platform_ioremap_resource_wc()
  component: Rename 'dev' to 'parent'
  component: Drop 'dev' argument to component_match_realloc()
  device property: Don't check for NULL twice in the loops
  driver core: auxiliary bus: Fix typo in the docs
  drivers/base/node.c: make CACHE_ATTR define static DEVICE_ATTR_RO
  debugfs: remove return value of debugfs_create_ulong()
  debugfs: remove return value of debugfs_create_bool()
  scsi: snic: debugfs: remove local storage of debugfs files
  b43: don't save dentries for debugfs
  b43legacy: don't save dentries for debugfs
  ...
  • Loading branch information
torvalds committed Jul 5, 2021
2 parents eed0218 + 3b1f941 commit f5c13f1
Show file tree
Hide file tree
Showing 45 changed files with 304 additions and 361 deletions.
4 changes: 4 additions & 0 deletions Documentation/ABI/testing/sysfs-firmware-memmap
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Description:
- System RAM
- ACPI Tables
- ACPI Non-volatile Storage
- Unusable memory
- Persistent Memory (legacy)
- Persistent Memory
- Soft Reserved
- reserved

Following shell snippet can be used to display that memory
Expand Down
2 changes: 1 addition & 1 deletion Documentation/driver-api/auxiliary_bus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ too complex for a single device to be managed by a monolithic driver
(e.g. Sound Open Firmware), multiple devices might implement a common
intersection of functionality (e.g. NICs + RDMA), or a driver may want to
export an interface for another subsystem to drive (e.g. SIOV Physical Function
export Virtual Function management). A split of the functinoality into child-
export Virtual Function management). A split of the functionality into child-
devices representing sub-domains of functionality makes it possible to
compartmentalize, layer, and distribute domain-specific concerns via a Linux
device-driver model.
Expand Down
1 change: 0 additions & 1 deletion Documentation/driver-api/driver-model/devres.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ IOMAP
devm_ioremap_resource() : checks resource, requests memory region, ioremaps
devm_ioremap_resource_wc()
devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
devm_platform_ioremap_resource_wc()
devm_platform_ioremap_resource_byname()
devm_platform_get_and_ioremap_resource()
devm_iounmap()
Expand Down
4 changes: 2 additions & 2 deletions Documentation/filesystems/debugfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ and hexadecimal::

Boolean values can be placed in debugfs with::

struct dentry *debugfs_create_bool(const char *name, umode_t mode,
struct dentry *parent, bool *value);
void debugfs_create_bool(const char *name, umode_t mode,
struct dentry *parent, bool *value);

A read on the resulting file will yield either Y (for non-zero values) or
N, followed by a newline. If written to, it will accept either upper- or
Expand Down
3 changes: 3 additions & 0 deletions drivers/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ obj-y += test/

ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG

# define_trace.h needs to know how to find our header
CFLAGS_trace.o := -I$(src)
obj-$(CONFIG_TRACING) += trace.o
6 changes: 3 additions & 3 deletions drivers/base/attribute_container.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ do_attribute_container_device_trigger_safe(struct device *dev,
* matching classdev or fail all of them.
*
* @dev: The generic device to run the trigger for
* @fn the function to execute for each classdev.
* @undo A function to undo the work previously done in case of error
* @fn: the function to execute for each classdev.
* @undo: A function to undo the work previously done in case of error
*
* This function is a safe version of
* attribute_container_device_trigger. It stops on the first error and
Expand Down Expand Up @@ -343,7 +343,7 @@ attribute_container_device_trigger_safe(struct device *dev,
* attribute_container_device_trigger - execute a trigger for each matching classdev
*
* @dev: The generic device to run the trigger for
* @fn the function to execute for each classdev.
* @fn: the function to execute for each classdev.
*
* This function is for executing a trigger when you need to know both
* the container and the classdev. If you only care about the
Expand Down
96 changes: 45 additions & 51 deletions drivers/base/component.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct master {
bool bound;

const struct component_master_ops *ops;
struct device *dev;
struct device *parent;
struct component_match *match;
};

Expand Down Expand Up @@ -95,7 +95,7 @@ static int component_devices_show(struct seq_file *s, void *data)
seq_printf(s, "%-40s %20s\n", "master name", "status");
seq_puts(s, "-------------------------------------------------------------\n");
seq_printf(s, "%-40s %20s\n\n",
dev_name(m->dev), m->bound ? "bound" : "not bound");
dev_name(m->parent), m->bound ? "bound" : "not bound");

seq_printf(s, "%-40s %20s\n", "device name", "status");
seq_puts(s, "-------------------------------------------------------------\n");
Expand Down Expand Up @@ -124,13 +124,13 @@ core_initcall(component_debug_init);

static void component_master_debugfs_add(struct master *m)
{
debugfs_create_file(dev_name(m->dev), 0444, component_debugfs_dir, m,
debugfs_create_file(dev_name(m->parent), 0444, component_debugfs_dir, m,
&component_devices_fops);
}

static void component_master_debugfs_del(struct master *m)
{
debugfs_remove(debugfs_lookup(dev_name(m->dev), component_debugfs_dir));
debugfs_remove(debugfs_lookup(dev_name(m->parent), component_debugfs_dir));
}

#else
Expand All @@ -143,13 +143,13 @@ static void component_master_debugfs_del(struct master *m)

#endif

static struct master *__master_find(struct device *dev,
static struct master *__master_find(struct device *parent,
const struct component_master_ops *ops)
{
struct master *m;

list_for_each_entry(m, &masters, node)
if (m->dev == dev && (!ops || m->ops == ops))
if (m->parent == parent && (!ops || m->ops == ops))
return m;

return NULL;
Expand Down Expand Up @@ -189,7 +189,7 @@ static int find_components(struct master *master)
struct component_match_array *mc = &match->compare[i];
struct component *c;

dev_dbg(master->dev, "Looking for component %zu\n", i);
dev_dbg(master->parent, "Looking for component %zu\n", i);

if (match->compare[i].component)
continue;
Expand All @@ -200,7 +200,7 @@ static int find_components(struct master *master)
break;
}

dev_dbg(master->dev, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master);
dev_dbg(master->parent, "found component %s, duplicate %u\n", dev_name(c->dev), !!c->master);

/* Attach this component to the master */
match->compare[i].duplicate = !!c->master;
Expand Down Expand Up @@ -233,28 +233,28 @@ static int try_to_bring_up_master(struct master *master,
{
int ret;

dev_dbg(master->dev, "trying to bring up master\n");
dev_dbg(master->parent, "trying to bring up master\n");

if (find_components(master)) {
dev_dbg(master->dev, "master has incomplete components\n");
dev_dbg(master->parent, "master has incomplete components\n");
return 0;
}

if (component && component->master != master) {
dev_dbg(master->dev, "master is not for this component (%s)\n",
dev_dbg(master->parent, "master is not for this component (%s)\n",
dev_name(component->dev));
return 0;
}

if (!devres_open_group(master->dev, NULL, GFP_KERNEL))
if (!devres_open_group(master->parent, NULL, GFP_KERNEL))
return -ENOMEM;

/* Found all components */
ret = master->ops->bind(master->dev);
ret = master->ops->bind(master->parent);
if (ret < 0) {
devres_release_group(master->dev, NULL);
devres_release_group(master->parent, NULL);
if (ret != -EPROBE_DEFER)
dev_info(master->dev, "master bind failed: %d\n", ret);
dev_info(master->parent, "master bind failed: %d\n", ret);
return ret;
}

Expand All @@ -281,34 +281,28 @@ static int try_to_bring_up_masters(struct component *component)
static void take_down_master(struct master *master)
{
if (master->bound) {
master->ops->unbind(master->dev);
devres_release_group(master->dev, NULL);
master->ops->unbind(master->parent);
devres_release_group(master->parent, NULL);
master->bound = false;
}
}

static void component_match_release(struct device *master,
struct component_match *match)
static void devm_component_match_release(struct device *parent, void *res)
{
struct component_match *match = res;
unsigned int i;

for (i = 0; i < match->num; i++) {
struct component_match_array *mc = &match->compare[i];

if (mc->release)
mc->release(master, mc->data);
mc->release(parent, mc->data);
}

kfree(match->compare);
}

static void devm_component_match_release(struct device *dev, void *res)
{
component_match_release(dev, res);
}

static int component_match_realloc(struct device *dev,
struct component_match *match, size_t num)
static int component_match_realloc(struct component_match *match, size_t num)
{
struct component_match_array *new;

Expand Down Expand Up @@ -359,7 +353,7 @@ static void __component_match_add(struct device *master,
size_t new_size = match->alloc + 16;
int ret;

ret = component_match_realloc(master, match, new_size);
ret = component_match_realloc(match, new_size);
if (ret) {
*matchptr = ERR_PTR(ret);
return;
Expand Down Expand Up @@ -451,7 +445,7 @@ static void free_master(struct master *master)

/**
* component_master_add_with_match - register an aggregate driver
* @dev: device with the aggregate driver
* @parent: parent device of the aggregate driver
* @ops: callbacks for the aggregate driver
* @match: component match list for the aggregate driver
*
Expand All @@ -461,23 +455,23 @@ static void free_master(struct master *master)
* &component_master_ops.bind from @ops. Must be unregistered by calling
* component_master_del().
*/
int component_master_add_with_match(struct device *dev,
int component_master_add_with_match(struct device *parent,
const struct component_master_ops *ops,
struct component_match *match)
{
struct master *master;
int ret;

/* Reallocate the match array for its true size */
ret = component_match_realloc(dev, match, match->num);
ret = component_match_realloc(match, match->num);
if (ret)
return ret;

master = kzalloc(sizeof(*master), GFP_KERNEL);
if (!master)
return -ENOMEM;

master->dev = dev;
master->parent = parent;
master->ops = ops;
master->match = match;

Expand All @@ -499,20 +493,20 @@ EXPORT_SYMBOL_GPL(component_master_add_with_match);

/**
* component_master_del - unregister an aggregate driver
* @dev: device with the aggregate driver
* @parent: parent device of the aggregate driver
* @ops: callbacks for the aggregate driver
*
* Unregisters an aggregate driver registered with
* component_master_add_with_match(). If necessary the aggregate driver is first
* disassembled by calling &component_master_ops.unbind from @ops.
*/
void component_master_del(struct device *dev,
void component_master_del(struct device *parent,
const struct component_master_ops *ops)
{
struct master *master;

mutex_lock(&component_mutex);
master = __master_find(dev, ops);
master = __master_find(parent, ops);
if (master) {
take_down_master(master);
free_master(master);
Expand All @@ -527,7 +521,7 @@ static void component_unbind(struct component *component,
WARN_ON(!component->bound);

if (component->ops && component->ops->unbind)
component->ops->unbind(component->dev, master->dev, data);
component->ops->unbind(component->dev, master->parent, data);
component->bound = false;

/* Release all resources claimed in the binding of this component */
Expand All @@ -536,22 +530,22 @@ static void component_unbind(struct component *component,

/**
* component_unbind_all - unbind all components of an aggregate driver
* @master_dev: device with the aggregate driver
* @parent: parent device of the aggregate driver
* @data: opaque pointer, passed to all components
*
* Unbinds all components of the aggregate @dev by passing @data to their
* Unbinds all components of the aggregate device by passing @data to their
* &component_ops.unbind functions. Should be called from
* &component_master_ops.unbind.
*/
void component_unbind_all(struct device *master_dev, void *data)
void component_unbind_all(struct device *parent, void *data)
{
struct master *master;
struct component *c;
size_t i;

WARN_ON(!mutex_is_locked(&component_mutex));

master = __master_find(master_dev, NULL);
master = __master_find(parent, NULL);
if (!master)
return;

Expand All @@ -574,7 +568,7 @@ static int component_bind(struct component *component, struct master *master,
* This allows us to roll-back a failed component without
* affecting anything else.
*/
if (!devres_open_group(master->dev, NULL, GFP_KERNEL))
if (!devres_open_group(master->parent, NULL, GFP_KERNEL))
return -ENOMEM;

/*
Expand All @@ -583,14 +577,14 @@ static int component_bind(struct component *component, struct master *master,
* at the appropriate moment.
*/
if (!devres_open_group(component->dev, component, GFP_KERNEL)) {
devres_release_group(master->dev, NULL);
devres_release_group(master->parent, NULL);
return -ENOMEM;
}

dev_dbg(master->dev, "binding %s (ops %ps)\n",
dev_dbg(master->parent, "binding %s (ops %ps)\n",
dev_name(component->dev), component->ops);

ret = component->ops->bind(component->dev, master->dev, data);
ret = component->ops->bind(component->dev, master->parent, data);
if (!ret) {
component->bound = true;

Expand All @@ -601,16 +595,16 @@ static int component_bind(struct component *component, struct master *master,
* can clean those resources up independently.
*/
devres_close_group(component->dev, NULL);
devres_remove_group(master->dev, NULL);
devres_remove_group(master->parent, NULL);

dev_info(master->dev, "bound %s (ops %ps)\n",
dev_info(master->parent, "bound %s (ops %ps)\n",
dev_name(component->dev), component->ops);
} else {
devres_release_group(component->dev, NULL);
devres_release_group(master->dev, NULL);
devres_release_group(master->parent, NULL);

if (ret != -EPROBE_DEFER)
dev_err(master->dev, "failed to bind %s (ops %ps): %d\n",
dev_err(master->parent, "failed to bind %s (ops %ps): %d\n",
dev_name(component->dev), component->ops, ret);
}

Expand All @@ -619,14 +613,14 @@ static int component_bind(struct component *component, struct master *master,

/**
* component_bind_all - bind all components of an aggregate driver
* @master_dev: device with the aggregate driver
* @parent: parent device of the aggregate driver
* @data: opaque pointer, passed to all components
*
* Binds all components of the aggregate @dev by passing @data to their
* &component_ops.bind functions. Should be called from
* &component_master_ops.bind.
*/
int component_bind_all(struct device *master_dev, void *data)
int component_bind_all(struct device *parent, void *data)
{
struct master *master;
struct component *c;
Expand All @@ -635,7 +629,7 @@ int component_bind_all(struct device *master_dev, void *data)

WARN_ON(!mutex_is_locked(&component_mutex));

master = __master_find(master_dev, NULL);
master = __master_find(parent, NULL);
if (!master)
return -EINVAL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3442,7 +3442,7 @@ bool kill_device(struct device *dev)
* to run while we are tearing out the bus/class/sysfs from
* underneath the device.
*/
lockdep_assert_held(&dev->mutex);
device_lock_assert(dev);

if (dev->p->dead)
return false;
Expand Down
Loading

0 comments on commit f5c13f1

Please sign in to comment.