Skip to content

Commit 3708184

Browse files
Sakari Ailusrafaeljw
authored andcommitted
device property: Move FW type specific functionality to FW specific files
The device and fwnode property API supports Devicetree, ACPI and pset properties. The implementation of this functionality for each firmware type was embedded in the fwnode property core. Move it out to firmware type specific locations, making it easier to maintain. Depends-on: ("of: Move OF property and graph API from base.c to property.c") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent cde1f95 commit 3708184

File tree

7 files changed

+302
-125
lines changed

7 files changed

+302
-125
lines changed

drivers/acpi/property.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static bool acpi_nondev_subnode_extract(const union acpi_object *desc,
5757

5858
dn->name = link->package.elements[0].string.pointer;
5959
dn->fwnode.type = FWNODE_ACPI_DATA;
60+
dn->fwnode.ops = &acpi_fwnode_ops;
6061
dn->parent = parent;
6162
INIT_LIST_HEAD(&dn->data.subnodes);
6263

@@ -1119,3 +1120,70 @@ int acpi_graph_get_remote_endpoint(struct fwnode_handle *fwnode,
11191120

11201121
return 0;
11211122
}
1123+
1124+
static bool acpi_fwnode_property_present(struct fwnode_handle *fwnode,
1125+
const char *propname)
1126+
{
1127+
return !acpi_node_prop_get(fwnode, propname, NULL);
1128+
}
1129+
1130+
static int acpi_fwnode_property_read_int_array(struct fwnode_handle *fwnode,
1131+
const char *propname,
1132+
unsigned int elem_size,
1133+
void *val, size_t nval)
1134+
{
1135+
enum dev_prop_type type;
1136+
1137+
switch (elem_size) {
1138+
case sizeof(u8):
1139+
type = DEV_PROP_U8;
1140+
break;
1141+
case sizeof(u16):
1142+
type = DEV_PROP_U16;
1143+
break;
1144+
case sizeof(u32):
1145+
type = DEV_PROP_U32;
1146+
break;
1147+
case sizeof(u64):
1148+
type = DEV_PROP_U64;
1149+
break;
1150+
default:
1151+
return -ENXIO;
1152+
}
1153+
1154+
return acpi_node_prop_read(fwnode, propname, type, val, nval);
1155+
}
1156+
1157+
static int acpi_fwnode_property_read_string_array(struct fwnode_handle *fwnode,
1158+
const char *propname,
1159+
const char **val, size_t nval)
1160+
{
1161+
return acpi_node_prop_read(fwnode, propname, DEV_PROP_STRING,
1162+
val, nval);
1163+
}
1164+
1165+
static struct fwnode_handle *
1166+
acpi_fwnode_get_named_child_node(struct fwnode_handle *fwnode,
1167+
const char *childname)
1168+
{
1169+
struct fwnode_handle *child;
1170+
1171+
/*
1172+
* Find first matching named child node of this fwnode.
1173+
* For ACPI this will be a data only sub-node.
1174+
*/
1175+
fwnode_for_each_child_node(fwnode, child)
1176+
if (acpi_data_node_match(child, childname))
1177+
return child;
1178+
1179+
return NULL;
1180+
}
1181+
1182+
const struct fwnode_operations acpi_fwnode_ops = {
1183+
.property_present = acpi_fwnode_property_present,
1184+
.property_read_int_array = acpi_fwnode_property_read_int_array,
1185+
.property_read_string_array = acpi_fwnode_property_read_string_array,
1186+
.get_parent = acpi_node_get_parent,
1187+
.get_next_child_node = acpi_get_next_subnode,
1188+
.get_named_child_node = acpi_fwnode_get_named_child_node,
1189+
};

drivers/acpi/scan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
14361436
device->handle = handle;
14371437
device->parent = acpi_bus_get_parent(handle);
14381438
device->fwnode.type = FWNODE_ACPI;
1439+
device->fwnode.ops = &acpi_fwnode_ops;
14391440
acpi_set_device_status(device, sta);
14401441
acpi_device_get_busid(device);
14411442
acpi_set_pnp_ids(handle, &device->pnp, type);

0 commit comments

Comments
 (0)