diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2018-07-17 17:19:11 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-07-23 12:44:52 +0200 |
commit | 977d5ad39f3ea12ac0bd51d75020cea5ecdca235 (patch) | |
tree | 6e61db209d8ff689916d8db83c9d2453a1eebb74 | |
parent | d72e90f33aa4709ebecc5005562f52335e106a60 (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.c | 36 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 11 | ||||
-rw-r--r-- | drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 10 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-fwnode.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns/hns_enet.c | 8 | ||||
-rw-r--r-- | include/linux/acpi.h | 17 | ||||
-rw-r--r-- | include/linux/fwnode.h | 2 |
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, */ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, const char *propname, size_t index, size_t num_args, - struct acpi_reference_args *args) + struct fwnode_reference_args *args) { const union acpi_object *element, *end; const union acpi_object *obj; @@ -607,7 +607,7 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, if (ret) return ret == -ENODEV ? -EINVAL : ret; - args->adev = device; + args->fwnode = acpi_fwnode_handle(device); args->nargs = 0; return 0; } @@ -653,11 +653,11 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, return -EINVAL; } - if (nargs > MAX_ACPI_REFERENCE_ARGS) + if (nargs > NR_FWNODE_REFERENCE_ARGS) return -EINVAL; if (idx == index) { - args->adev = device; + args->fwnode = acpi_fwnode_handle(device); args->nargs = nargs; for (i = 0; i < nargs; i++) args->args[i] = element[i].integer.value; @@ -1089,7 +1089,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, { struct fwnode_handle *fwnode; unsigned int port_nr, endpoint_nr; - struct acpi_reference_args args; + struct fwnode_reference_args args; int ret; memset(&args, 0, sizeof(args)); @@ -1098,6 +1098,10 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, if (ret) return ret; + /* Ensure this is a device node. */ + if (!is_acpi_device_node(args.fwnode)) + return -ENODEV; + /* * Always require two arguments with the reference: port and * endpoint indices. @@ -1105,7 +1109,7 @@ int acpi_graph_get_remote_endpoint(const struct fwnode_handle *__fwnode, if (args.nargs != 2) return -EPROTO; - fwnode = acpi_fwnode_handle(args.adev); + fwnode = args.fwnode; port_nr = args.args[0]; endpoint_nr = args.args[1]; @@ -1209,24 +1213,8 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode, unsigned int args_count, unsigned int index, struct fwnode_reference_args *args) { - struct acpi_reference_args acpi_args; - unsigned int i; - int ret; - - ret = __acpi_node_get_property_reference(fwnode, prop, index, - args_count, &acpi_args); - if (ret < 0) - return ret; - if (!args) - return 0; - - args->nargs = acpi_args.nargs; - args->fwnode = acpi_fwnode_handle(acpi_args.adev); - - for (i = 0; i < NR_FWNODE_REFERENCE_ARGS; i++) - args->args[i] = i < acpi_args.nargs ? acpi_args.args[i] : 0; - - return 0; + return __acpi_node_get_property_reference(fwnode, prop, index, + args_count, args); } static 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); static bool acpi_get_driver_gpio_data(struct acpi_device *adev, const char *name, int index, - struct acpi_reference_args *args, + struct fwnode_reference_args *args, unsigned int *quirks) { const struct acpi_gpio_mapping *gm; @@ -365,7 +365,7 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev, if (!strcmp(name, gm->name) && gm->data && index < gm->size) { const struct acpi_gpio_params *par = gm->data + index; - args->adev = adev; + args->fwnode = acpi_fwnode_handle(adev); args->args[0] = par->crs_entry_index; args->args[1] = par->line_index; args->args[2] = par->active_low; @@ -528,7 +528,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, const char *propname, int index, struct acpi_gpio_lookup *lookup) { - struct acpi_reference_args args; + struct fwnode_reference_args args; unsigned int quirks = 0; int ret; @@ -549,6 +549,8 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, * The property was found and resolved, so need to lookup the GPIO based * on returned args. */ + if (!to_acpi_device_node(args.fwnode)) + return -EINVAL; if (args.nargs != 3) return -EPROTO; @@ -556,8 +558,9 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, lookup->pin_index = args.args[1]; lookup->active_low = !!args.args[2]; - lookup->info.adev = args.adev; + lookup->info.adev = to_acpi_device_node(args.fwnode); lookup->info.quirks = quirks; + return 0; } 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) } fwnode = &dsaf_node->fwnode; } else if (is_acpi_device_node(dev->fwnode)) { - struct acpi_reference_args args; + struct fwnode_reference_args args; ret = acpi_node_get_property_reference(dev->fwnode, "dsaf-handle", 0, &args); @@ -1443,7 +1443,7 @@ static int hns_roce_v1_reset(struct hns_roce_dev *hr_dev, bool dereset) dev_err(dev, "could not find dsaf-handle\n"); return ret; } - fwnode = acpi_fwnode_handle(args.adev); + fwnode = args.fwnode; } else { dev_err(dev, "cannot read data from DT or ACPI\n"); return -ENXIO; @@ -4835,16 +4835,14 @@ static int hns_roce_get_cfg(struct hns_roce_dev *hr_dev) continue; pdev = of_find_device_by_node(net_node); } else if (is_acpi_device_node(dev->fwnode)) { - struct acpi_reference_args args; - struct fwnode_handle *fwnode; + struct fwnode_reference_args args; ret = acpi_node_get_property_reference(dev->fwnode, "eth-handle", i, &args); if (ret) continue; - fwnode = acpi_fwnode_handle(args.adev); - pdev = hns_roce_find_pdev(fwnode); + pdev = hns_roce_find_pdev(args.fwnode); } else { dev_err(dev, "cannot read data from DT or ACPI\n"); 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( const char * const *props, unsigned int nprops) { struct fwnode_reference_args fwnode_args; - unsigned int *args = fwnode_args.args; + u64 *args = fwnode_args.args; struct fwnode_handle *child; int ret; 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) #ifdef CONFIG_ACPI static struct acpi_device *acpi_phy_find_device(struct device *dev) { - struct acpi_reference_args args; + struct fwnode_reference_args args; struct fwnode_handle *fw_node; int status; fw_node = acpi_fwnode_handle(ACPI_COMPANION(dev)); status = acpi_node_get_property_reference(fw_node, "phy-handle", 0, &args); - if (ACPI_FAILURE(status)) { + if (ACPI_FAILURE(status) || !is_acpi_device_node(args.fwnode)) { dev_dbg(dev, "No matching phy in ACPI table\n"); return NULL; } - return args.adev; + return to_acpi_device_node(args.fwnode); } #endif 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, static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) { - struct acpi_reference_args args; + struct fwnode_reference_args args; struct platform_device *pdev; struct mii_bus *mii_bus; int rc; @@ -722,13 +722,15 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) mac_cb->fw_port, "mdio-node", 0, &args); if (rc) return rc; + if (!is_acpi_device_node(args.fwnode)) + return -EINVAL; addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port); if (addr < 0) return addr; /* dev address in adev */ - pdev = hns_dsaf_find_platform_device(acpi_fwnode_handle(args.adev)); + pdev = hns_dsaf_find_platform_device(args.fwnode); if (!pdev) { dev_err(mac_cb->dev, "mac%d mdio pdev is NULL\n", 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) } priv->fwnode = &ae_node->fwnode; } else if (is_acpi_node(dev->fwnode)) { - struct acpi_reference_args args; + struct fwnode_reference_args args; if (acpi_dev_found(hns_enet_acpi_match[0].id)) priv->enet_ver = AE_VERSION_1; @@ -2393,7 +2393,11 @@ static int hns_nic_dev_probe(struct platform_device *pdev) dev_err(dev, "not find ae-handle\n"); goto out_read_prop_fail; } - priv->fwnode = acpi_fwnode_handle(args.adev); + if (!is_acpi_device_node(args.fwnode)) { + ret = -EINVAL; + goto out_read_prop_fail; + } + priv->fwnode = args.fwnode; } else { dev_err(dev, "cannot read cfg data from OF or acpi\n"); 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) /* Device properties */ -#define MAX_ACPI_REFERENCE_ARGS 8 -struct acpi_reference_args { - struct acpi_device *adev; - size_t nargs; - u64 args[MAX_ACPI_REFERENCE_ARGS]; -}; - #ifdef CONFIG_ACPI int acpi_dev_get_property(const struct acpi_device *adev, const char *name, acpi_object_type type, const union acpi_object **obj); int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, const char *name, size_t index, size_t num_args, - struct acpi_reference_args *args); + struct fwnode_reference_args *args); static inline int acpi_node_get_property_reference( const struct fwnode_handle *fwnode, const char *name, size_t index, - struct acpi_reference_args *args) + struct fwnode_reference_args *args) { return __acpi_node_get_property_reference(fwnode, name, index, - MAX_ACPI_REFERENCE_ARGS, args); + NR_FWNODE_REFERENCE_ARGS, args); } int 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, static inline int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, const char *name, size_t index, size_t num_args, - struct acpi_reference_args *args) + struct fwnode_reference_args *args) { return -ENXIO; } @@ -1177,7 +1170,7 @@ __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, static inline int acpi_node_get_property_reference(const struct fwnode_handle *fwnode, const char *name, size_t index, - struct acpi_reference_args *args) + struct fwnode_reference_args *args) { return -ENXIO; } 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 { struct fwnode_reference_args { struct fwnode_handle *fwnode; unsigned int nargs; - unsigned int args[NR_FWNODE_REFERENCE_ARGS]; + u64 args[NR_FWNODE_REFERENCE_ARGS]; }; /** |