mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
7ac1161c27
Here is the "big" driver core and debugfs update for 5.12-rc1 This set of driver core patches caused a bunch of problems in linux-next for the past few weeks, when Saravana tried to set fw_devlink=on as the default functionality. This caused a number of systems to stop booting, and lots of bugs were fixed in this area for almost all of the reported systems, but this option is not ready to be turned on just yet for the default operation based on this testing, so I've reverted that change at the very end so we don't have to worry about regressions in 5.12. We will try to turn this on for 5.13 if testing goes better over the next few months. Other than the fixes caused by the fw_devlink testing in here, there's not much more: - debugfs fixes for invalid input into debugfs_lookup() - kerneldoc cleanups - warn message if platform drivers return an error on their remove callback (a futile effort, but good to catch). All of these have been in linux-next for a while now, and the regressions have gone away with the revert of the fw_devlink change. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYDZhzA8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+ylS2wCfU28FxDWNwcWhPFVfRT8Mb3OxZ50An1sR4lNR t5Ie4aztMUjVJhI9bq6g =3NSB -----END PGP SIGNATURE----- Merge tag 'driver-core-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core Pull driver core / debugfs update from Greg KH: "Here is the "big" driver core and debugfs update for 5.12-rc1 This set of driver core patches caused a bunch of problems in linux-next for the past few weeks, when Saravana tried to set fw_devlink=on as the default functionality. This caused a number of systems to stop booting, and lots of bugs were fixed in this area for almost all of the reported systems, but this option is not ready to be turned on just yet for the default operation based on this testing, so I've reverted that change at the very end so we don't have to worry about regressions in 5.12 We will try to turn this on for 5.13 if testing goes better over the next few months. Other than the fixes caused by the fw_devlink testing in here, there's not much more: - debugfs fixes for invalid input into debugfs_lookup() - kerneldoc cleanups - warn message if platform drivers return an error on their remove callback (a futile effort, but good to catch). All of these have been in linux-next for a while now, and the regressions have gone away with the revert of the fw_devlink change" * tag 'driver-core-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (35 commits) Revert "driver core: Set fw_devlink=on by default" of: property: fw_devlink: Ignore interrupts property for some configs debugfs: do not attempt to create a new file before the filesystem is initalized debugfs: be more robust at handling improper input in debugfs_lookup() driver core: auxiliary bus: Fix calling stage for auxiliary bus init of: irq: Fix the return value for of_irq_parse_one() stub of: irq: make a stub for of_irq_parse_one() clk: Mark fwnodes when their clock provider is added/removed PM: domains: Mark fwnodes when their powerdomain is added/removed irqdomain: Mark fwnodes when their irqdomain is added/removed driver core: fw_devlink: Handle suppliers that don't use driver core of: property: Add fw_devlink support for optional properties driver core: Add fw_devlink.strict kernel param of: property: Don't add links to absent suppliers driver core: fw_devlink: Detect supplier devices that will never be added driver core: platform: Emit a warning if a remove callback returned non-zero of: property: Fix fw_devlink handling of interrupts/interrupts-extended gpiolib: Don't probe gpio_device if it's not the primary device device.h: Remove bogus "the" in kerneldoc gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default ...
191 lines
6.5 KiB
C
191 lines
6.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* fwnode.h - Firmware device node object handle type definition.
|
|
*
|
|
* Copyright (C) 2015, Intel Corporation
|
|
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
|
*/
|
|
|
|
#ifndef _LINUX_FWNODE_H_
|
|
#define _LINUX_FWNODE_H_
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/list.h>
|
|
#include <linux/err.h>
|
|
|
|
struct fwnode_operations;
|
|
struct device;
|
|
|
|
/*
|
|
* fwnode link flags
|
|
*
|
|
* LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
|
|
* NOT_DEVICE: The fwnode will never be populated as a struct device.
|
|
* INITIALIZED: The hardware corresponding to fwnode has been initialized.
|
|
*/
|
|
#define FWNODE_FLAG_LINKS_ADDED BIT(0)
|
|
#define FWNODE_FLAG_NOT_DEVICE BIT(1)
|
|
#define FWNODE_FLAG_INITIALIZED BIT(2)
|
|
|
|
struct fwnode_handle {
|
|
struct fwnode_handle *secondary;
|
|
const struct fwnode_operations *ops;
|
|
struct device *dev;
|
|
struct list_head suppliers;
|
|
struct list_head consumers;
|
|
u8 flags;
|
|
};
|
|
|
|
struct fwnode_link {
|
|
struct fwnode_handle *supplier;
|
|
struct list_head s_hook;
|
|
struct fwnode_handle *consumer;
|
|
struct list_head c_hook;
|
|
};
|
|
|
|
/**
|
|
* struct fwnode_endpoint - Fwnode graph endpoint
|
|
* @port: Port number
|
|
* @id: Endpoint id
|
|
* @local_fwnode: reference to the related fwnode
|
|
*/
|
|
struct fwnode_endpoint {
|
|
unsigned int port;
|
|
unsigned int id;
|
|
const struct fwnode_handle *local_fwnode;
|
|
};
|
|
|
|
/*
|
|
* ports and endpoints defined as software_nodes should all follow a common
|
|
* naming scheme; use these macros to ensure commonality.
|
|
*/
|
|
#define SWNODE_GRAPH_PORT_NAME_FMT "port@%u"
|
|
#define SWNODE_GRAPH_ENDPOINT_NAME_FMT "endpoint@%u"
|
|
|
|
#define NR_FWNODE_REFERENCE_ARGS 8
|
|
|
|
/**
|
|
* struct fwnode_reference_args - Fwnode reference with additional arguments
|
|
* @fwnode:- A reference to the base fwnode
|
|
* @nargs: Number of elements in @args array
|
|
* @args: Integer arguments on the fwnode
|
|
*/
|
|
struct fwnode_reference_args {
|
|
struct fwnode_handle *fwnode;
|
|
unsigned int nargs;
|
|
u64 args[NR_FWNODE_REFERENCE_ARGS];
|
|
};
|
|
|
|
/**
|
|
* struct fwnode_operations - Operations for fwnode interface
|
|
* @get: Get a reference to an fwnode.
|
|
* @put: Put a reference to an fwnode.
|
|
* @device_is_available: Return true if the device is available.
|
|
* @device_get_match_data: Return the device driver match data.
|
|
* @property_present: Return true if a property is present.
|
|
* @property_read_int_array: Read an array of integer properties. Return zero on
|
|
* success, a negative error code otherwise.
|
|
* @property_read_string_array: Read an array of string properties. Return zero
|
|
* on success, a negative error code otherwise.
|
|
* @get_name: Return the name of an fwnode.
|
|
* @get_name_prefix: Get a prefix for a node (for printing purposes).
|
|
* @get_parent: Return the parent of an fwnode.
|
|
* @get_next_child_node: Return the next child node in an iteration.
|
|
* @get_named_child_node: Return a child node with a given name.
|
|
* @get_reference_args: Return a reference pointed to by a property, with args
|
|
* @graph_get_next_endpoint: Return an endpoint node in an iteration.
|
|
* @graph_get_remote_endpoint: Return the remote endpoint node of a local
|
|
* endpoint node.
|
|
* @graph_get_port_parent: Return the parent node of a port node.
|
|
* @graph_parse_endpoint: Parse endpoint for port and endpoint id.
|
|
* @add_links: Create fwnode links to all the suppliers of the fwnode. Return
|
|
* zero on success, a negative error code otherwise.
|
|
*/
|
|
struct fwnode_operations {
|
|
struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);
|
|
void (*put)(struct fwnode_handle *fwnode);
|
|
bool (*device_is_available)(const struct fwnode_handle *fwnode);
|
|
const void *(*device_get_match_data)(const struct fwnode_handle *fwnode,
|
|
const struct device *dev);
|
|
bool (*property_present)(const struct fwnode_handle *fwnode,
|
|
const char *propname);
|
|
int (*property_read_int_array)(const struct fwnode_handle *fwnode,
|
|
const char *propname,
|
|
unsigned int elem_size, void *val,
|
|
size_t nval);
|
|
int
|
|
(*property_read_string_array)(const struct fwnode_handle *fwnode_handle,
|
|
const char *propname, const char **val,
|
|
size_t nval);
|
|
const char *(*get_name)(const struct fwnode_handle *fwnode);
|
|
const char *(*get_name_prefix)(const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *(*get_parent)(const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *
|
|
(*get_next_child_node)(const struct fwnode_handle *fwnode,
|
|
struct fwnode_handle *child);
|
|
struct fwnode_handle *
|
|
(*get_named_child_node)(const struct fwnode_handle *fwnode,
|
|
const char *name);
|
|
int (*get_reference_args)(const struct fwnode_handle *fwnode,
|
|
const char *prop, const char *nargs_prop,
|
|
unsigned int nargs, unsigned int index,
|
|
struct fwnode_reference_args *args);
|
|
struct fwnode_handle *
|
|
(*graph_get_next_endpoint)(const struct fwnode_handle *fwnode,
|
|
struct fwnode_handle *prev);
|
|
struct fwnode_handle *
|
|
(*graph_get_remote_endpoint)(const struct fwnode_handle *fwnode);
|
|
struct fwnode_handle *
|
|
(*graph_get_port_parent)(struct fwnode_handle *fwnode);
|
|
int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
|
|
struct fwnode_endpoint *endpoint);
|
|
int (*add_links)(struct fwnode_handle *fwnode);
|
|
};
|
|
|
|
#define fwnode_has_op(fwnode, op) \
|
|
((fwnode) && (fwnode)->ops && (fwnode)->ops->op)
|
|
#define fwnode_call_int_op(fwnode, op, ...) \
|
|
(fwnode ? (fwnode_has_op(fwnode, op) ? \
|
|
(fwnode)->ops->op(fwnode, ## __VA_ARGS__) : -ENXIO) : \
|
|
-EINVAL)
|
|
|
|
#define fwnode_call_bool_op(fwnode, op, ...) \
|
|
(fwnode_has_op(fwnode, op) ? \
|
|
(fwnode)->ops->op(fwnode, ## __VA_ARGS__) : false)
|
|
|
|
#define fwnode_call_ptr_op(fwnode, op, ...) \
|
|
(fwnode_has_op(fwnode, op) ? \
|
|
(fwnode)->ops->op(fwnode, ## __VA_ARGS__) : NULL)
|
|
#define fwnode_call_void_op(fwnode, op, ...) \
|
|
do { \
|
|
if (fwnode_has_op(fwnode, op)) \
|
|
(fwnode)->ops->op(fwnode, ## __VA_ARGS__); \
|
|
} while (false)
|
|
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
|
|
|
|
static inline void fwnode_init(struct fwnode_handle *fwnode,
|
|
const struct fwnode_operations *ops)
|
|
{
|
|
fwnode->ops = ops;
|
|
INIT_LIST_HEAD(&fwnode->consumers);
|
|
INIT_LIST_HEAD(&fwnode->suppliers);
|
|
}
|
|
|
|
static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode,
|
|
bool initialized)
|
|
{
|
|
if (IS_ERR_OR_NULL(fwnode))
|
|
return;
|
|
|
|
if (initialized)
|
|
fwnode->flags |= FWNODE_FLAG_INITIALIZED;
|
|
else
|
|
fwnode->flags &= ~FWNODE_FLAG_INITIALIZED;
|
|
}
|
|
|
|
extern u32 fw_devlink_get_flags(void);
|
|
extern bool fw_devlink_is_strict(void);
|
|
int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup);
|
|
void fwnode_links_purge(struct fwnode_handle *fwnode);
|
|
|
|
#endif
|