Skip to content

Commit e7d0c41

Browse files
committed
Merge tag 'devprop-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework updates from Rafael Wysocki: "These introduce fwnode operations for all of the separate types of 'firmware nodes' that can be handled by the device properties framework, make the framework use const fwnode arguments all over, add a helper for the consolidated handling of node references and switch over the framework to the new UUID API. Specifics: - Introduce fwnode operations for all of the separate types of 'firmware nodes' that can be handled by the device properties framework and drop the type field from struct fwnode_handle (Sakari Ailus, Arnd Bergmann). - Make the device properties framework use const fwnode arguments where possible (Sakari Ailus). - Add a helper for the consolidated handling of node references to the device properties framework (Sakari Ailus). - Switch over the ACPI part of the device properties framework to the new UUID API (Andy Shevchenko)" * tag 'devprop-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI: device property: Switch to use new generic UUID API device property: export irqchip_fwnode_ops device property: Introduce fwnode_property_get_reference_args device property: Constify fwnode property API device property: Constify argument to pset fwnode backend ACPI: Constify internal fwnode arguments ACPI: Constify acpi_bus helper functions, switch to macros ACPI: Prepare for constifying acpi_get_next_subnode() fwnode argument device property: Get rid of struct fwnode_handle type field ACPI: Use IS_ERR_OR_NULL() instead of non-NULL check in is_acpi_data_node()
2 parents 53ac64a + 3689d3d commit e7d0c41

File tree

11 files changed

+428
-264
lines changed

11 files changed

+428
-264
lines changed

drivers/acpi/property.c

Lines changed: 141 additions & 90 deletions
Large diffs are not rendered by default.

drivers/acpi/scan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,8 +1549,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
15491549
device->device_type = type;
15501550
device->handle = handle;
15511551
device->parent = acpi_bus_get_parent(handle);
1552-
device->fwnode.type = FWNODE_ACPI;
1553-
device->fwnode.ops = &acpi_fwnode_ops;
1552+
device->fwnode.ops = &acpi_device_fwnode_ops;
15541553
acpi_set_device_status(device, sta);
15551554
acpi_device_get_busid(device);
15561555
acpi_set_pnp_ids(handle, &device->pnp, type);

drivers/base/property.c

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,25 @@ struct property_set {
2525
const struct property_entry *properties;
2626
};
2727

28-
static inline bool is_pset_node(struct fwnode_handle *fwnode)
29-
{
30-
return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_PDATA;
31-
}
28+
static const struct fwnode_operations pset_fwnode_ops;
3229

33-
static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode)
30+
static inline bool is_pset_node(const struct fwnode_handle *fwnode)
3431
{
35-
return is_pset_node(fwnode) ?
36-
container_of(fwnode, struct property_set, fwnode) : NULL;
32+
return !IS_ERR_OR_NULL(fwnode) && fwnode->ops == &pset_fwnode_ops;
3733
}
3834

39-
static const struct property_entry *pset_prop_get(struct property_set *pset,
40-
const char *name)
35+
#define to_pset_node(__fwnode) \
36+
({ \
37+
typeof(__fwnode) __to_pset_node_fwnode = __fwnode; \
38+
\
39+
is_pset_node(__to_pset_node_fwnode) ? \
40+
container_of(__to_pset_node_fwnode, \
41+
struct property_set, fwnode) : \
42+
NULL; \
43+
})
44+
45+
static const struct property_entry *
46+
pset_prop_get(const struct property_set *pset, const char *name)
4147
{
4248
const struct property_entry *prop;
4349

@@ -51,7 +57,7 @@ static const struct property_entry *pset_prop_get(struct property_set *pset,
5157
return NULL;
5258
}
5359

54-
static const void *pset_prop_find(struct property_set *pset,
60+
static const void *pset_prop_find(const struct property_set *pset,
5561
const char *propname, size_t length)
5662
{
5763
const struct property_entry *prop;
@@ -71,7 +77,7 @@ static const void *pset_prop_find(struct property_set *pset,
7177
return pointer;
7278
}
7379

74-
static int pset_prop_read_u8_array(struct property_set *pset,
80+
static int pset_prop_read_u8_array(const struct property_set *pset,
7581
const char *propname,
7682
u8 *values, size_t nval)
7783
{
@@ -86,7 +92,7 @@ static int pset_prop_read_u8_array(struct property_set *pset,
8692
return 0;
8793
}
8894

89-
static int pset_prop_read_u16_array(struct property_set *pset,
95+
static int pset_prop_read_u16_array(const struct property_set *pset,
9096
const char *propname,
9197
u16 *values, size_t nval)
9298
{
@@ -101,7 +107,7 @@ static int pset_prop_read_u16_array(struct property_set *pset,
101107
return 0;
102108
}
103109

104-
static int pset_prop_read_u32_array(struct property_set *pset,
110+
static int pset_prop_read_u32_array(const struct property_set *pset,
105111
const char *propname,
106112
u32 *values, size_t nval)
107113
{
@@ -116,7 +122,7 @@ static int pset_prop_read_u32_array(struct property_set *pset,
116122
return 0;
117123
}
118124

119-
static int pset_prop_read_u64_array(struct property_set *pset,
125+
static int pset_prop_read_u64_array(const struct property_set *pset,
120126
const char *propname,
121127
u64 *values, size_t nval)
122128
{
@@ -131,7 +137,7 @@ static int pset_prop_read_u64_array(struct property_set *pset,
131137
return 0;
132138
}
133139

134-
static int pset_prop_count_elems_of_size(struct property_set *pset,
140+
static int pset_prop_count_elems_of_size(const struct property_set *pset,
135141
const char *propname, size_t length)
136142
{
137143
const struct property_entry *prop;
@@ -143,7 +149,7 @@ static int pset_prop_count_elems_of_size(struct property_set *pset,
143149
return prop->length / length;
144150
}
145151

146-
static int pset_prop_read_string_array(struct property_set *pset,
152+
static int pset_prop_read_string_array(const struct property_set *pset,
147153
const char *propname,
148154
const char **strings, size_t nval)
149155
{
@@ -187,18 +193,18 @@ struct fwnode_handle *dev_fwnode(struct device *dev)
187193
}
188194
EXPORT_SYMBOL_GPL(dev_fwnode);
189195

190-
static bool pset_fwnode_property_present(struct fwnode_handle *fwnode,
196+
static bool pset_fwnode_property_present(const struct fwnode_handle *fwnode,
191197
const char *propname)
192198
{
193199
return !!pset_prop_get(to_pset_node(fwnode), propname);
194200
}
195201

196-
static int pset_fwnode_read_int_array(struct fwnode_handle *fwnode,
202+
static int pset_fwnode_read_int_array(const struct fwnode_handle *fwnode,
197203
const char *propname,
198204
unsigned int elem_size, void *val,
199205
size_t nval)
200206
{
201-
struct property_set *node = to_pset_node(fwnode);
207+
const struct property_set *node = to_pset_node(fwnode);
202208

203209
if (!val)
204210
return pset_prop_count_elems_of_size(node, propname, elem_size);
@@ -217,9 +223,10 @@ static int pset_fwnode_read_int_array(struct fwnode_handle *fwnode,
217223
return -ENXIO;
218224
}
219225

220-
static int pset_fwnode_property_read_string_array(struct fwnode_handle *fwnode,
221-
const char *propname,
222-
const char **val, size_t nval)
226+
static int
227+
pset_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
228+
const char *propname,
229+
const char **val, size_t nval)
223230
{
224231
return pset_prop_read_string_array(to_pset_node(fwnode), propname,
225232
val, nval);
@@ -249,7 +256,8 @@ EXPORT_SYMBOL_GPL(device_property_present);
249256
* @fwnode: Firmware node whose property to check
250257
* @propname: Name of the property
251258
*/
252-
bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
259+
bool fwnode_property_present(const struct fwnode_handle *fwnode,
260+
const char *propname)
253261
{
254262
bool ret;
255263

@@ -431,7 +439,7 @@ int device_property_match_string(struct device *dev, const char *propname,
431439
}
432440
EXPORT_SYMBOL_GPL(device_property_match_string);
433441

434-
static int fwnode_property_read_int_array(struct fwnode_handle *fwnode,
442+
static int fwnode_property_read_int_array(const struct fwnode_handle *fwnode,
435443
const char *propname,
436444
unsigned int elem_size, void *val,
437445
size_t nval)
@@ -467,7 +475,7 @@ static int fwnode_property_read_int_array(struct fwnode_handle *fwnode,
467475
* %-EOVERFLOW if the size of the property is not as expected,
468476
* %-ENXIO if no suitable firmware interface is present.
469477
*/
470-
int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
478+
int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
471479
const char *propname, u8 *val, size_t nval)
472480
{
473481
return fwnode_property_read_int_array(fwnode, propname, sizeof(u8),
@@ -493,7 +501,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
493501
* %-EOVERFLOW if the size of the property is not as expected,
494502
* %-ENXIO if no suitable firmware interface is present.
495503
*/
496-
int fwnode_property_read_u16_array(struct fwnode_handle *fwnode,
504+
int fwnode_property_read_u16_array(const struct fwnode_handle *fwnode,
497505
const char *propname, u16 *val, size_t nval)
498506
{
499507
return fwnode_property_read_int_array(fwnode, propname, sizeof(u16),
@@ -519,7 +527,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
519527
* %-EOVERFLOW if the size of the property is not as expected,
520528
* %-ENXIO if no suitable firmware interface is present.
521529
*/
522-
int fwnode_property_read_u32_array(struct fwnode_handle *fwnode,
530+
int fwnode_property_read_u32_array(const struct fwnode_handle *fwnode,
523531
const char *propname, u32 *val, size_t nval)
524532
{
525533
return fwnode_property_read_int_array(fwnode, propname, sizeof(u32),
@@ -545,7 +553,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
545553
* %-EOVERFLOW if the size of the property is not as expected,
546554
* %-ENXIO if no suitable firmware interface is present.
547555
*/
548-
int fwnode_property_read_u64_array(struct fwnode_handle *fwnode,
556+
int fwnode_property_read_u64_array(const struct fwnode_handle *fwnode,
549557
const char *propname, u64 *val, size_t nval)
550558
{
551559
return fwnode_property_read_int_array(fwnode, propname, sizeof(u64),
@@ -571,7 +579,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
571579
* %-EOVERFLOW if the size of the property is not as expected,
572580
* %-ENXIO if no suitable firmware interface is present.
573581
*/
574-
int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
582+
int fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
575583
const char *propname, const char **val,
576584
size_t nval)
577585
{
@@ -603,7 +611,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
603611
* %-EPROTO or %-EILSEQ if the property is not a string,
604612
* %-ENXIO if no suitable firmware interface is present.
605613
*/
606-
int fwnode_property_read_string(struct fwnode_handle *fwnode,
614+
int fwnode_property_read_string(const struct fwnode_handle *fwnode,
607615
const char *propname, const char **val)
608616
{
609617
int ret = fwnode_property_read_string_array(fwnode, propname, val, 1);
@@ -627,7 +635,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string);
627635
* %-EPROTO if the property is not an array of strings,
628636
* %-ENXIO if no suitable firmware interface is present.
629637
*/
630-
int fwnode_property_match_string(struct fwnode_handle *fwnode,
638+
int fwnode_property_match_string(const struct fwnode_handle *fwnode,
631639
const char *propname, const char *string)
632640
{
633641
const char **values;
@@ -657,6 +665,34 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
657665
}
658666
EXPORT_SYMBOL_GPL(fwnode_property_match_string);
659667

668+
/**
669+
* fwnode_property_get_reference_args() - Find a reference with arguments
670+
* @fwnode: Firmware node where to look for the reference
671+
* @prop: The name of the property
672+
* @nargs_prop: The name of the property telling the number of
673+
* arguments in the referred node. NULL if @nargs is known,
674+
* otherwise @nargs is ignored. Only relevant on OF.
675+
* @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
676+
* @index: Index of the reference, from zero onwards.
677+
* @args: Result structure with reference and integer arguments.
678+
*
679+
* Obtain a reference based on a named property in an fwnode, with
680+
* integer arguments.
681+
*
682+
* Caller is responsible to call fwnode_handle_put() on the returned
683+
* args->fwnode pointer.
684+
*
685+
*/
686+
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
687+
const char *prop, const char *nargs_prop,
688+
unsigned int nargs, unsigned int index,
689+
struct fwnode_reference_args *args)
690+
{
691+
return fwnode_call_int_op(fwnode, get_reference_args, prop, nargs_prop,
692+
nargs, index, args);
693+
}
694+
EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
695+
660696
static int property_copy_string_array(struct property_entry *dst,
661697
const struct property_entry *src)
662698
{
@@ -900,7 +936,6 @@ int device_add_properties(struct device *dev,
900936
if (IS_ERR(p))
901937
return PTR_ERR(p);
902938

903-
p->fwnode.type = FWNODE_PDATA;
904939
p->fwnode.ops = &pset_fwnode_ops;
905940
set_secondary_fwnode(dev, &p->fwnode);
906941
return 0;
@@ -935,7 +970,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
935970
* Return parent firmware node of the given node if possible or %NULL if no
936971
* parent was available.
937972
*/
938-
struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode)
973+
struct fwnode_handle *fwnode_get_parent(const struct fwnode_handle *fwnode)
939974
{
940975
return fwnode_call_ptr_op(fwnode, get_parent);
941976
}
@@ -946,8 +981,9 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);
946981
* @fwnode: Firmware node to find the next child node for.
947982
* @child: Handle to one of the node's child nodes or a %NULL handle.
948983
*/
949-
struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
950-
struct fwnode_handle *child)
984+
struct fwnode_handle *
985+
fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
986+
struct fwnode_handle *child)
951987
{
952988
return fwnode_call_ptr_op(fwnode, get_next_child_node, child);
953989
}
@@ -978,8 +1014,9 @@ EXPORT_SYMBOL_GPL(device_get_next_child_node);
9781014
* @fwnode: Firmware node to find the named child node for.
9791015
* @childname: String to match child node name against.
9801016
*/
981-
struct fwnode_handle *fwnode_get_named_child_node(struct fwnode_handle *fwnode,
982-
const char *childname)
1017+
struct fwnode_handle *
1018+
fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
1019+
const char *childname)
9831020
{
9841021
return fwnode_call_ptr_op(fwnode, get_named_child_node, childname);
9851022
}
@@ -1025,7 +1062,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
10251062
* fwnode_device_is_available - check if a device is available for use
10261063
* @fwnode: Pointer to the fwnode of the device.
10271064
*/
1028-
bool fwnode_device_is_available(struct fwnode_handle *fwnode)
1065+
bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
10291066
{
10301067
return fwnode_call_bool_op(fwnode, device_is_available);
10311068
}
@@ -1163,7 +1200,7 @@ EXPORT_SYMBOL(device_get_mac_address);
11631200
* are available.
11641201
*/
11651202
struct fwnode_handle *
1166-
fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
1203+
fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
11671204
struct fwnode_handle *prev)
11681205
{
11691206
return fwnode_call_ptr_op(fwnode, graph_get_next_endpoint, prev);
@@ -1177,7 +1214,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
11771214
* Return: the firmware node of the device the @endpoint belongs to.
11781215
*/
11791216
struct fwnode_handle *
1180-
fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
1217+
fwnode_graph_get_port_parent(const struct fwnode_handle *endpoint)
11811218
{
11821219
struct fwnode_handle *port, *parent;
11831220

@@ -1197,7 +1234,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
11971234
* Extracts firmware node of a remote device the @fwnode points to.
11981235
*/
11991236
struct fwnode_handle *
1200-
fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
1237+
fwnode_graph_get_remote_port_parent(const struct fwnode_handle *fwnode)
12011238
{
12021239
struct fwnode_handle *endpoint, *parent;
12031240

@@ -1216,7 +1253,8 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);
12161253
*
12171254
* Extracts firmware node of a remote port the @fwnode points to.
12181255
*/
1219-
struct fwnode_handle *fwnode_graph_get_remote_port(struct fwnode_handle *fwnode)
1256+
struct fwnode_handle *
1257+
fwnode_graph_get_remote_port(const struct fwnode_handle *fwnode)
12201258
{
12211259
return fwnode_get_next_parent(fwnode_graph_get_remote_endpoint(fwnode));
12221260
}
@@ -1229,7 +1267,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);
12291267
* Extracts firmware node of a remote endpoint the @fwnode points to.
12301268
*/
12311269
struct fwnode_handle *
1232-
fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
1270+
fwnode_graph_get_remote_endpoint(const struct fwnode_handle *fwnode)
12331271
{
12341272
return fwnode_call_ptr_op(fwnode, graph_get_remote_endpoint);
12351273
}
@@ -1244,8 +1282,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
12441282
* Return: Remote fwnode handle associated with remote endpoint node linked
12451283
* to @node. Use fwnode_node_put() on it when done.
12461284
*/
1247-
struct fwnode_handle *fwnode_graph_get_remote_node(struct fwnode_handle *fwnode,
1248-
u32 port_id, u32 endpoint_id)
1285+
struct fwnode_handle *
1286+
fwnode_graph_get_remote_node(const struct fwnode_handle *fwnode, u32 port_id,
1287+
u32 endpoint_id)
12491288
{
12501289
struct fwnode_handle *endpoint = NULL;
12511290

@@ -1281,7 +1320,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
12811320
* information in @endpoint. The caller must hold a reference to
12821321
* @fwnode.
12831322
*/
1284-
int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
1323+
int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
12851324
struct fwnode_endpoint *endpoint)
12861325
{
12871326
memset(endpoint, 0, sizeof(*endpoint));

0 commit comments

Comments
 (0)