summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2018-07-17 10:19:11 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-07-23 06:44:52 -0400
commit977d5ad39f3ea12ac0bd51d75020cea5ecdca235 (patch)
tree6e61db209d8ff689916d8db83c9d2453a1eebb74
parentd72e90f33aa4709ebecc5005562f52335e106a60 (diff)
ACPI: Convert ACPI reference args to generic fwnode reference args
Convert all users of struct acpi_reference_args to more generic fwnode_reference_args. This will 1) avoid an ACPI specific references to device nodes with integer arguments as well as 2) allow making references to nodes other than device nodes in ACPI. As a by-product, convert the fwnode interger arguments to u64. The arguments were 64-bit integers on ACPI but the fwnode arguments were just 32-bit. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/property.c36
-rw-r--r--drivers/gpio/gpiolib-acpi.c11
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_hw_v1.c10
-rw-r--r--drivers/media/v4l2-core/v4l2-fwnode.c2
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c6
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c6
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_enet.c8
-rw-r--r--include/linux/acpi.h17
-rw-r--r--include/linux/fwnode.h2
9 files changed, 43 insertions, 55 deletions
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 5815356ea6ad..3fa40010fd67 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -579,7 +579,7 @@ static int acpi_data_get_property_array(const struct acpi_device_data *data,
579 */ 579 */
580int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 580int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
581 const char *propname, size_t index, size_t num_args, 581 const char *propname, size_t index, size_t num_args,
582 struct acpi_reference_args *args) 582 struct fwnode_reference_args *args)
583{ 583{
584 const union acpi_object *element, *end; 584 const union acpi_object *element, *end;
585 const union acpi_object *obj; 585 const union acpi_object *obj;
@@ -607,7 +607,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
607 if (ret) 607 if (ret)
608 return ret == -ENODEV ? -EINVAL : ret; 608 return ret == -ENODEV ? -EINVAL : ret;
609 609
610 args->adev = device; 610 args->fwnode = acpi_fwnode_handle(device);
611 args->nargs = 0; 611 args->nargs = 0;
612 return 0; 612 return 0;
613 } 613 }
@@ -653,11 +653,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
653 return -EINVAL; 653 return -EINVAL;
654 } 654 }
655 655
656 if (nargs > MAX_ACPI_REFERENCE_ARGS) 656 if (nargs > NR_FWNODE_REFERENCE_ARGS)
657 return -EINVAL; 657 return -EINVAL;
658 658
659 if (idx == index) { 659 if (idx == index) {
660 args->adev = device; 660 args->fwnode = acpi_fwnode_handle(device);
661 args->nargs = nargs; 661 args->nargs = nargs;
662 for (i = 0; i < nargs; i++) 662 for (i = 0; i < nargs; i++)
663 args->args[i] = element[i].integer.value; 663 args->args[i] = element[i].integer.value;
@@ -1089,7 +1089,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode,
1089{ 1089{
1090 struct fwnode_handle *fwnode; 1090 struct fwnode_handle *fwnode;
1091 unsigned int port_nr, endpoint_nr; 1091 unsigned int port_nr, endpoint_nr;
1092 struct acpi_reference_args args; 1092 struct fwnode_reference_args args;
1093 int ret; 1093 int ret;
1094 1094
1095 memset(&args, 0, sizeof(args)); 1095 memset(&args, 0, sizeof(args));
@@ -1098,6 +1098,10 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode,
1098 if (ret) 1098 if (ret)
1099 return ret; 1099 return ret;
1100 1100
1101 /* Ensure this is a device node. */
1102 if (!is_acpi_device_node(args.fwnode))
1103 return -ENODEV;
1104
1101 /* 1105 /*
1102 * Always require two arguments with the reference: port and 1106 * Always require two arguments with the reference: port and
1103 * endpoint indices. 1107 * endpoint indices.
@@ -1105,7 +1109,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode,
1105 if (args.nargs != 2) 1109 if (args.nargs != 2)
1106 return -EPROTO; 1110 return -EPROTO;
1107 1111
1108 fwnode = acpi_fwnode_handle(args.adev); 1112 fwnode = args.fwnode;
1109 port_nr = args.args[0]; 1113 port_nr = args.args[0];
1110 endpoint_nr = args.args[1]; 1114 endpoint_nr = args.args[1];
1111 1115
@@ -1209,24 +1213,8 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
1209 unsigned int args_count, unsigned int index, 1213 unsigned int args_count, unsigned int index,
1210 struct fwnode_reference_args *args) 1214 struct fwnode_reference_args *args)
1211{ 1215{
1212 struct acpi_reference_args acpi_args; 1216 return __acpi_node_get_property_reference(fwnode, prop, index,
1213 unsigned int i; 1217 args_count, args);
1214 int ret;
1215
1216 ret = __acpi_node_get_property_reference(fwnode, prop, index,
1217 args_count, &acpi_args);
1218 if (ret < 0)
1219 return ret;
1220 if (!args)
1221 return 0;
1222
1223 args->nargs = acpi_args.nargs;
1224 args->fwnode = acpi_fwnode_handle(acpi_args.adev);
1225
1226 for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++)
1227 args->args[i] = i < acpi_args.nargs ? acpi_args.args[i] : 0;
1228
1229 return 0;
1230} 1218}
1231 1219
1232static struct fwnode_handle * 1220static struct fwnode_handle *
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index e2232cbcec8b..4e8fdae1cde4 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -353,7 +353,7 @@ EXPORT_SYMBOL_GPL(devm_acpi_dev_remove_driver_gpios);
353 353
354static bool acpi_get_driver_gpio_data(struct acpi_device *adev, 354static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
355 const char *name, int index, 355 const char *name, int index,
356 struct acpi_reference_args *args, 356 struct fwnode_reference_args *args,
357 unsigned int *quirks) 357 unsigned int *quirks)
358{ 358{
359 const struct acpi_gpio_mapping *gm; 359 const struct acpi_gpio_mapping *gm;
@@ -365,7 +365,7 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev,
365 if (!strcmp(name, gm->name) && gm->data && index < gm->size) { 365 if (!strcmp(name, gm->name) && gm->data && index < gm->size) {
366 const struct acpi_gpio_params *par = gm->data + index; 366 const struct acpi_gpio_params *par = gm->data + index;
367 367
368 args->adev = adev; 368 args->fwnode = acpi_fwnode_handle(adev);
369 args->args[0] = par->crs_entry_index; 369 args->args[0] = par->crs_entry_index;
370 args->args[1] = par->line_index; 370 args->args[1] = par->line_index;
371 args->args[2] = par->active_low; 371 args->args[2] = par->active_low;
@@ -528,7 +528,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
528 const char *propname, int index, 528 const char *propname, int index,
529 struct acpi_gpio_lookup *lookup) 529 struct acpi_gpio_lookup *lookup)
530{ 530{
531 struct acpi_reference_args args; 531 struct fwnode_reference_args args;
532 unsigned int quirks = 0; 532 unsigned int quirks = 0;
533 int ret; 533 int ret;
534 534
@@ -549,6 +549,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
549 * The property was found and resolved, so need to lookup the GPIO based 549 * The property was found and resolved, so need to lookup the GPIO based
550 * on returned args. 550 * on returned args.
551 */ 551 */
552 if (!to_acpi_device_node(args.fwnode))
553 return -EINVAL;
552 if (args.nargs != 3) 554 if (args.nargs != 3)
553 return -EPROTO; 555 return -EPROTO;
554 556
@@ -556,8 +558,9 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode,
556 lookup->pin_index = args.args[1]; 558 lookup->pin_index = args.args[1];
557 lookup->active_low = !!args.args[2]; 559 lookup->active_low = !!args.args[2];
558 560
559 lookup->info.adev = args.adev; 561 lookup->info.adev = to_acpi_device_node(args.fwnode);
560 lookup->info.quirks = quirks; 562 lookup->info.quirks = quirks;
563
561 return 0; 564 return 0;
562} 565}
563 566
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 8013d69c5ac4..8444234ed092 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -1435,7 +1435,7 @@ static int hns_roce_v1_reset(struct hns_roce_dev *hr_dev, bool dereset)
1435 } 1435 }
1436 fwnode = &dsaf_node->fwnode; 1436 fwnode = &dsaf_node->fwnode;
1437 } else if (is_acpi_device_node(dev->fwnode)) { 1437 } else if (is_acpi_device_node(dev->fwnode)) {
1438 struct acpi_reference_args args; 1438 struct fwnode_reference_args args;
1439 1439
1440 ret = acpi_node_get_property_reference(dev->fwnode, 1440 ret = acpi_node_get_property_reference(dev->fwnode,
1441 "dsaf-handle", 0, &args); 1441 "dsaf-handle", 0, &args);
@@ -1443,7 +1443,7 @@ static int hns_roce_v1_reset(struct hns_roce_dev *hr_dev, bool dereset)
1443 dev_err(dev, "could not find dsaf-handle\n"); 1443 dev_err(dev, "could not find dsaf-handle\n");
1444 return ret; 1444 return ret;
1445 } 1445 }
1446 fwnode = acpi_fwnode_handle(args.adev); 1446 fwnode = args.fwnode;
1447 } else { 1447 } else {
1448 dev_err(dev, "cannot read data from DT or ACPI\n"); 1448 dev_err(dev, "cannot read data from DT or ACPI\n");
1449 return -ENXIO; 1449 return -ENXIO;
@@ -4835,16 +4835,14 @@ static int hns_roce_get_cfg(struct hns_roce_dev *hr_dev)
4835 continue; 4835 continue;
4836 pdev = of_find_device_by_node(net_node); 4836 pdev = of_find_device_by_node(net_node);
4837 } else if (is_acpi_device_node(dev->fwnode)) { 4837 } else if (is_acpi_device_node(dev->fwnode)) {
4838 struct acpi_reference_args args; 4838 struct fwnode_reference_args args;
4839 struct fwnode_handle *fwnode;
4840 4839
4841 ret = acpi_node_get_property_reference(dev->fwnode, 4840 ret = acpi_node_get_property_reference(dev->fwnode,
4842 "eth-handle", 4841 "eth-handle",
4843 i, &args); 4842 i, &args);
4844 if (ret) 4843 if (ret)
4845 continue; 4844 continue;
4846 fwnode = acpi_fwnode_handle(args.adev); 4845 pdev = hns_roce_find_pdev(args.fwnode);
4847 pdev = hns_roce_find_pdev(fwnode);
4848 } else { 4846 } else {
4849 dev_err(dev, "cannot read data from DT or ACPI\n"); 4847 dev_err(dev, "cannot read data from DT or ACPI\n");
4850 return -ENXIO; 4848 return -ENXIO;
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
index 3f77aa318035..82595cebc0b8 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -739,7 +739,7 @@ static struct fwnode_handle *v4l2_fwnode_reference_get_int_prop(
739 const char * const *props, unsigned int nprops) 739 const char * const *props, unsigned int nprops)
740{ 740{
741 struct fwnode_reference_args fwnode_args; 741 struct fwnode_reference_args fwnode_args;
742 unsigned int *args = fwnode_args.args; 742 u64 *args = fwnode_args.args;
743 struct fwnode_handle *child; 743 struct fwnode_handle *child;
744 int ret; 744 int ret;
745 745
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 3188f553da35..078a04dc1182 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -836,19 +836,19 @@ static void xgene_enet_adjust_link(struct net_device *ndev)
836#ifdef CONFIG_ACPI 836#ifdef CONFIG_ACPI
837static struct acpi_device *acpi_phy_find_device(struct device *dev) 837static struct acpi_device *acpi_phy_find_device(struct device *dev)
838{ 838{
839 struct acpi_reference_args args; 839 struct fwnode_reference_args args;
840 struct fwnode_handle *fw_node; 840 struct fwnode_handle *fw_node;
841 int status; 841 int status;
842 842
843 fw_node = acpi_fwnode_handle(ACPI_COMPANION(dev)); 843 fw_node = acpi_fwnode_handle(ACPI_COMPANION(dev));
844 status = acpi_node_get_property_reference(fw_node, "phy-handle", 0, 844 status = acpi_node_get_property_reference(fw_node, "phy-handle", 0,
845 &args); 845 &args);
846 if (ACPI_FAILURE(status)) { 846 if (ACPI_FAILURE(status) || !is_acpi_device_node(args.fwnode)) {
847 dev_dbg(dev, "No matching phy in ACPI table\n"); 847 dev_dbg(dev, "No matching phy in ACPI table\n");
848 return NULL; 848 return NULL;
849 } 849 }
850 850
851 return args.adev; 851 return to_acpi_device_node(args.fwnode);
852} 852}
853#endif 853#endif
854 854
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 9dcc5765f11f..794516718d9d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -708,7 +708,7 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
708 708
709static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) 709static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
710{ 710{
711 struct acpi_reference_args args; 711 struct fwnode_reference_args args;
712 struct platform_device *pdev; 712 struct platform_device *pdev;
713 struct mii_bus *mii_bus; 713 struct mii_bus *mii_bus;
714 int rc; 714 int rc;
@@ -722,13 +722,15 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb)
722 mac_cb->fw_port, "mdio-node", 0, &args); 722 mac_cb->fw_port, "mdio-node", 0, &args);
723 if (rc) 723 if (rc)
724 return rc; 724 return rc;
725 if (!is_acpi_device_node(args.fwnode))
726 return -EINVAL;
725 727
726 addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port); 728 addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
727 if (addr < 0) 729 if (addr < 0)
728 return addr; 730 return addr;
729 731
730 /* dev address in adev */ 732 /* dev address in adev */
731 pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev)); 733 pdev = hns_dsaf_find_platform_device(args.fwnode);
732 if (!pdev) { 734 if (!pdev) {
733 dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n", 735 dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n",
734 mac_cb->mac_id); 736 mac_cb->mac_id);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index ef9ef703d13a..5608f807d7ba 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -2377,7 +2377,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
2377 } 2377 }
2378 priv->fwnode = &ae_node->fwnode; 2378 priv->fwnode = &ae_node->fwnode;
2379 } else if (is_acpi_node(dev->fwnode)) { 2379 } else if (is_acpi_node(dev->fwnode)) {
2380 struct acpi_reference_args args; 2380 struct fwnode_reference_args args;
2381 2381
2382 if (acpi_dev_found(hns_enet_acpi_match[0].id)) 2382 if (acpi_dev_found(hns_enet_acpi_match[0].id))
2383 priv->enet_ver = AE_VERSION_1; 2383 priv->enet_ver = AE_VERSION_1;
@@ -2393,7 +2393,11 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
2393 dev_err(dev, "not find ae-handle\n"); 2393 dev_err(dev, "not find ae-handle\n");
2394 goto out_read_prop_fail; 2394 goto out_read_prop_fail;
2395 } 2395 }
2396 priv->fwnode = acpi_fwnode_handle(args.adev); 2396 if (!is_acpi_device_node(args.fwnode)) {
2397 ret = -EINVAL;
2398 goto out_read_prop_fail;
2399 }
2400 priv->fwnode = args.fwnode;
2397 } else { 2401 } else {
2398 dev_err(dev, "cannot read cfg data from OF or acpi\n"); 2402 dev_err(dev, "cannot read cfg data from OF or acpi\n");
2399 return -ENXIO; 2403 return -ENXIO;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index e54f40974eb0..11cf39719fd8 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1058,27 +1058,20 @@ static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
1058 1058
1059/* Device properties */ 1059/* Device properties */
1060 1060
1061#define MAX_ACPI_REFERENCE_ARGS 8
1062struct acpi_reference_args {
1063 struct acpi_device *adev;
1064 size_t nargs;
1065 u64 args[MAX_ACPI_REFERENCE_ARGS];
1066};
1067
1068#ifdef CONFIG_ACPI 1061#ifdef CONFIG_ACPI
1069int acpi_dev_get_property(const struct acpi_device *adev, const char *name, 1062int acpi_dev_get_property(const struct acpi_device *adev, const char *name,
1070 acpi_object_type type, const union acpi_object **obj); 1063 acpi_object_type type, const union acpi_object **obj);
1071int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1064int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1072 const char *name, size_t index, size_t num_args, 1065 const char *name, size_t index, size_t num_args,
1073 struct acpi_reference_args *args); 1066 struct fwnode_reference_args *args);
1074 1067
1075static inline int acpi_node_get_property_reference( 1068static inline int acpi_node_get_property_reference(
1076 const struct fwnode_handle *fwnode, 1069 const struct fwnode_handle *fwnode,
1077 const char *name, size_t index, 1070 const char *name, size_t index,
1078 struct acpi_reference_args *args) 1071 struct fwnode_reference_args *args)
1079{ 1072{
1080 return __acpi_node_get_property_reference(fwnode, name, index, 1073 return __acpi_node_get_property_reference(fwnode, name, index,
1081 MAX_ACPI_REFERENCE_ARGS, args); 1074 NR_FWNODE_REFERENCE_ARGS, args);
1082} 1075}
1083 1076
1084int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname, 1077int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
@@ -1169,7 +1162,7 @@ static inline int acpi_dev_get_property(struct acpi_device *adev,
1169static inline int 1162static inline int
1170__acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1163__acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1171 const char *name, size_t index, size_t num_args, 1164 const char *name, size_t index, size_t num_args,
1172 struct acpi_reference_args *args) 1165 struct fwnode_reference_args *args)
1173{ 1166{
1174 return -ENXIO; 1167 return -ENXIO;
1175} 1168}
@@ -1177,7 +1170,7 @@ __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1177static inline int 1170static inline int
1178acpi_node_get_property_reference(const struct fwnode_handle *fwnode, 1171acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
1179 const char *name, size_t index, 1172 const char *name, size_t index,
1180 struct acpi_reference_args *args) 1173 struct fwnode_reference_args *args)
1181{ 1174{
1182 return -ENXIO; 1175 return -ENXIO;
1183} 1176}
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 4fe8f289b3f6..faebf0ca0686 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -45,7 +45,7 @@ struct fwnode_endpoint {
45struct fwnode_reference_args { 45struct fwnode_reference_args {
46 struct fwnode_handle *fwnode; 46 struct fwnode_handle *fwnode;
47 unsigned int nargs; 47 unsigned int nargs;
48 unsigned int args[NR_FWNODE_REFERENCE_ARGS]; 48 u64 args[NR_FWNODE_REFERENCE_ARGS];
49}; 49};
50 50
51/** 51/**