mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
of: make kobject and bin_attribute support configurable
Having device_nodes be kobjects is only needed if sysfs or OF_DYNAMIC is enabled. Otherwise, having a kobject in struct device_node is unnecessary bloat in minimal kernel configurations. Likewise, bin_attribute is only needed in struct property when sysfs is enabled, so we can make it configurable too. Tested-by: Nicolas Pitre <nico@linaro.org> Reviewed-by: Frank Rowand <frowand.list@gmail.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:
parent
0c3c234b95
commit
b56b5528f5
7 changed files with 202 additions and 164 deletions
|
@ -43,7 +43,9 @@ struct property {
|
|||
#if defined(CONFIG_OF_PROMTREE)
|
||||
unsigned int unique_id;
|
||||
#endif
|
||||
#if defined(CONFIG_OF_KOBJ)
|
||||
struct bin_attribute attr;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(CONFIG_SPARC)
|
||||
|
@ -62,7 +64,9 @@ struct device_node {
|
|||
struct device_node *parent;
|
||||
struct device_node *child;
|
||||
struct device_node *sibling;
|
||||
#if defined(CONFIG_OF_KOBJ)
|
||||
struct kobject kobj;
|
||||
#endif
|
||||
unsigned long _flags;
|
||||
void *data;
|
||||
#if defined(CONFIG_SPARC)
|
||||
|
@ -107,23 +111,17 @@ extern struct kobj_type of_node_ktype;
|
|||
extern const struct fwnode_operations of_fwnode_ops;
|
||||
static inline void of_node_init(struct device_node *node)
|
||||
{
|
||||
#if defined(CONFIG_OF_KOBJ)
|
||||
kobject_init(&node->kobj, &of_node_ktype);
|
||||
#endif
|
||||
node->fwnode.ops = &of_fwnode_ops;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OF_KOBJ)
|
||||
#define of_node_kobj(n) (&(n)->kobj)
|
||||
|
||||
/* true when node is initialized */
|
||||
static inline int of_node_is_initialized(struct device_node *node)
|
||||
{
|
||||
return node && node->kobj.state_initialized;
|
||||
}
|
||||
|
||||
/* true when node is attached (i.e. present on sysfs) */
|
||||
static inline int of_node_is_attached(struct device_node *node)
|
||||
{
|
||||
return node && node->kobj.state_in_sysfs;
|
||||
}
|
||||
#else
|
||||
#define of_node_kobj(n) NULL
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_OF_DYNAMIC
|
||||
extern struct device_node *of_node_get(struct device_node *node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue