From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
coresight@lists.linaro.org, mike.leach@linaro.org,
robert.walker@arm.com
Subject: Re: [PATCH 18/25] coresight: Introduce generic platform data helper
Date: Wed, 27 Mar 2019 16:57:21 -0600 [thread overview]
Message-ID: <20190327225721.GC778@xps15> (raw)
In-Reply-To: <1553107783-3340-19-git-send-email-suzuki.poulose@arm.com>
On Wed, Mar 20, 2019 at 06:49:35PM +0000, Suzuki K Poulose wrote:
> So far we have hard coded the DT platform parsing code in
> every driver. Introduce generic helper to parse the information
> provided by the firmware in a platform agnostic manner, in preparation
> for the ACPI support.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-catu.c | 13 ++---
> drivers/hwtracing/coresight/coresight-etb10.c | 11 ++--
> drivers/hwtracing/coresight/coresight-etm3x.c | 12 ++--
> drivers/hwtracing/coresight/coresight-etm4x.c | 11 ++--
> drivers/hwtracing/coresight/coresight-funnel.c | 11 ++--
> drivers/hwtracing/coresight/coresight-platform.c | 65 +++++++++++++---------
> drivers/hwtracing/coresight/coresight-replicator.c | 12 ++--
> drivers/hwtracing/coresight/coresight-stm.c | 11 ++--
> drivers/hwtracing/coresight/coresight-tmc.c | 13 ++---
> drivers/hwtracing/coresight/coresight-tpiu.c | 11 ++--
> include/linux/coresight.h | 7 +--
> 11 files changed, 80 insertions(+), 97 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 671a05a..4595c67 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -503,17 +503,14 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
> struct coresight_desc catu_desc;
> struct coresight_platform_data *pdata = NULL;
> struct device *dev = &adev->dev;
> - struct device_node *np = dev->of_node;
> void __iomem *base;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata)) {
> - ret = PTR_ERR(pdata);
> - goto out;
> - }
> - dev->platform_data = pdata;
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata)) {
> + ret = PTR_ERR(pdata);
> + goto out;
> }
> + dev->platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata) {
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index a471cbd..e4175849 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -688,14 +688,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
> struct etb_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
> index 7137f06..b101464 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x.c
> @@ -788,20 +788,16 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
> struct etm_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> -
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
>
> + adev->dev.platform_data = pdata;
> drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
> dev_set_drvdata(dev, drvdata);
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
> index 8d5ee3b..bfc23ab 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c
> @@ -974,18 +974,15 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
> struct etmv4_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> dev_set_drvdata(dev, drvdata);
>
> diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
> index 1085f31..2590744 100644
> --- a/drivers/hwtracing/coresight/coresight-funnel.c
> +++ b/drivers/hwtracing/coresight/coresight-funnel.c
> @@ -185,14 +185,11 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id)
> struct funnel_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index 514cc2b..693e3f5 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -17,6 +17,20 @@
> #include <linux/cpumask.h>
> #include <asm/smp_plat.h>
>
> +static int coresight_alloc_conns(struct device *dev,
> + struct coresight_platform_data *pdata)
> +{
> + if (pdata->nr_outport) {
> + pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
> + sizeof(*pdata->conns),
> + GFP_KERNEL);
> + if (!pdata->conns)
> + return -ENOMEM;
> + }
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_OF
> static int of_dev_node_match(struct device *dev, void *data)
> {
> @@ -133,20 +147,6 @@ static void of_coresight_get_ports(const struct device_node *node,
> }
> }
>
> -static int of_coresight_alloc_memory(struct device *dev,
> - struct coresight_platform_data *pdata)
> -{
> - if (pdata->nr_outport) {
> - pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
> - sizeof(*pdata->conns),
> - GFP_KERNEL);
> - if (!pdata->conns)
> - return -ENOMEM;
> - }
> -
> - return 0;
> -}
> -
> int of_coresight_get_cpu(const struct device_node *node)
> {
> int cpu;
> @@ -226,23 +226,17 @@ static int of_coresight_parse_endpoint(struct device *dev,
> return ret;
> }
>
> -struct coresight_platform_data *
> +static struct coresight_platform_data *
> of_get_coresight_platform_data(struct device *dev,
> - const struct device_node *node)
> + struct coresight_platform_data *pdata)
> {
> int ret = 0;
> - struct coresight_platform_data *pdata;
> struct coresight_connection *conn;
> struct device_node *ep = NULL;
> const struct device_node *parent = NULL;
> bool legacy_binding = false;
> + struct device_node *node = dev->of_node;
>
> - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> - if (!pdata)
> - return ERR_PTR(-ENOMEM);
> -
> - /* Use device name as sysfs handle */
> - pdata->name = dev_name(dev);
> pdata->cpu = of_coresight_get_cpu(node);
>
> /* Get the number of input and output port for this component */
> @@ -252,7 +246,7 @@ of_get_coresight_platform_data(struct device *dev,
> if (!pdata->nr_outport)
> return pdata;
>
> - ret = of_coresight_alloc_memory(dev, pdata);
> + ret = coresight_alloc_conns(dev, pdata);
I'm pretty sure you're doing this because you want to use
coresight_alloc_conns() for ACPI as well, and I'm fine with that. But it is
quite orthogonal to the rest of the work done in this patch and as such I think
it needs a patch of its own.
> if (ret)
> return ERR_PTR(ret);
>
> @@ -294,5 +288,26 @@ of_get_coresight_platform_data(struct device *dev,
>
> return pdata;
> }
> -EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
> #endif
> +
> +struct coresight_platform_data *
> +coresight_get_platform_data(struct device *dev)
> +{
> + struct coresight_platform_data *pdata;
> +
> + if (IS_ERR_OR_NULL(dev->fwnode))
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + /* Use device name as sysfs handle */
> + pdata->name = dev_name(dev);
> +
> + if (is_of_node(dev->fwnode))
> + return of_get_coresight_platform_data(dev, pdata);
> +
> + return ERR_PTR(-ENOENT);
> +}
> +EXPORT_SYMBOL_GPL(coresight_get_platform_data);
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index 8bbb008..7eb3bf7 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -177,15 +177,12 @@ static int replicator_probe(struct device *dev, struct resource *res)
> struct coresight_platform_data *pdata = NULL;
> struct replicator_drvdata *drvdata;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = dev->of_node;
> void __iomem *base;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - dev->platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + dev->platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> @@ -213,7 +210,6 @@ static int replicator_probe(struct device *dev, struct resource *res)
> }
>
> dev_set_drvdata(dev, drvdata);
> -
> desc.type = CORESIGHT_DEV_TYPE_LINK;
> desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
> desc.ops = &replicator_cs_ops;
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index eb96bba..6514586 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -809,14 +809,11 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
> size_t bitmap_size;
> struct coresight_desc desc = { 0 };
> struct coresight_device *csdev;
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
> diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
> index 7ce3427..147ab17 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc.c
> @@ -394,16 +394,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
> struct tmc_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata)) {
> - ret = PTR_ERR(pdata);
> - goto out;
> - }
> - adev->dev.platform_data = pdata;
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata)) {
> + ret = PTR_ERR(pdata);
> + goto out;
> }
> + adev->dev.platform_data = pdata;
>
> ret = -ENOMEM;
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
> index 9763721..18a749a 100644
> --- a/drivers/hwtracing/coresight/coresight-tpiu.c
> +++ b/drivers/hwtracing/coresight/coresight-tpiu.c
> @@ -120,14 +120,11 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> struct coresight_device *csdev;
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index 7b87965..5b29255 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -293,14 +293,11 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
>
> #ifdef CONFIG_OF
> extern int of_coresight_get_cpu(const struct device_node *node);
> -extern struct coresight_platform_data *
> -of_get_coresight_platform_data(struct device *dev,
> - const struct device_node *node);
> #else
> static inline int of_coresight_get_cpu(const struct device_node *node)
> { return 0; }
> -static inline struct coresight_platform_data *of_get_coresight_platform_data(
> - struct device *dev, const struct device_node *node) { return NULL; }
> #endif
>
> +struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
> +
> #endif
> --
> 2.7.4
>
WARNING: multiple messages have this Message-ID (diff)
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org,
linux-acpi@vger.kernel.org, robert.walker@arm.com,
linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org
Subject: Re: [PATCH 18/25] coresight: Introduce generic platform data helper
Date: Wed, 27 Mar 2019 16:57:21 -0600 [thread overview]
Message-ID: <20190327225721.GC778@xps15> (raw)
In-Reply-To: <1553107783-3340-19-git-send-email-suzuki.poulose@arm.com>
On Wed, Mar 20, 2019 at 06:49:35PM +0000, Suzuki K Poulose wrote:
> So far we have hard coded the DT platform parsing code in
> every driver. Introduce generic helper to parse the information
> provided by the firmware in a platform agnostic manner, in preparation
> for the ACPI support.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> drivers/hwtracing/coresight/coresight-catu.c | 13 ++---
> drivers/hwtracing/coresight/coresight-etb10.c | 11 ++--
> drivers/hwtracing/coresight/coresight-etm3x.c | 12 ++--
> drivers/hwtracing/coresight/coresight-etm4x.c | 11 ++--
> drivers/hwtracing/coresight/coresight-funnel.c | 11 ++--
> drivers/hwtracing/coresight/coresight-platform.c | 65 +++++++++++++---------
> drivers/hwtracing/coresight/coresight-replicator.c | 12 ++--
> drivers/hwtracing/coresight/coresight-stm.c | 11 ++--
> drivers/hwtracing/coresight/coresight-tmc.c | 13 ++---
> drivers/hwtracing/coresight/coresight-tpiu.c | 11 ++--
> include/linux/coresight.h | 7 +--
> 11 files changed, 80 insertions(+), 97 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
> index 671a05a..4595c67 100644
> --- a/drivers/hwtracing/coresight/coresight-catu.c
> +++ b/drivers/hwtracing/coresight/coresight-catu.c
> @@ -503,17 +503,14 @@ static int catu_probe(struct amba_device *adev, const struct amba_id *id)
> struct coresight_desc catu_desc;
> struct coresight_platform_data *pdata = NULL;
> struct device *dev = &adev->dev;
> - struct device_node *np = dev->of_node;
> void __iomem *base;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata)) {
> - ret = PTR_ERR(pdata);
> - goto out;
> - }
> - dev->platform_data = pdata;
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata)) {
> + ret = PTR_ERR(pdata);
> + goto out;
> }
> + dev->platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata) {
> diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
> index a471cbd..e4175849 100644
> --- a/drivers/hwtracing/coresight/coresight-etb10.c
> +++ b/drivers/hwtracing/coresight/coresight-etb10.c
> @@ -688,14 +688,11 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
> struct etb_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
> index 7137f06..b101464 100644
> --- a/drivers/hwtracing/coresight/coresight-etm3x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm3x.c
> @@ -788,20 +788,16 @@ static int etm_probe(struct amba_device *adev, const struct amba_id *id)
> struct etm_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> -
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
>
> + adev->dev.platform_data = pdata;
> drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
> dev_set_drvdata(dev, drvdata);
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
> index 8d5ee3b..bfc23ab 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x.c
> @@ -974,18 +974,15 @@ static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
> struct etmv4_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> dev_set_drvdata(dev, drvdata);
>
> diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
> index 1085f31..2590744 100644
> --- a/drivers/hwtracing/coresight/coresight-funnel.c
> +++ b/drivers/hwtracing/coresight/coresight-funnel.c
> @@ -185,14 +185,11 @@ static int funnel_probe(struct amba_device *adev, const struct amba_id *id)
> struct funnel_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c
> index 514cc2b..693e3f5 100644
> --- a/drivers/hwtracing/coresight/coresight-platform.c
> +++ b/drivers/hwtracing/coresight/coresight-platform.c
> @@ -17,6 +17,20 @@
> #include <linux/cpumask.h>
> #include <asm/smp_plat.h>
>
> +static int coresight_alloc_conns(struct device *dev,
> + struct coresight_platform_data *pdata)
> +{
> + if (pdata->nr_outport) {
> + pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
> + sizeof(*pdata->conns),
> + GFP_KERNEL);
> + if (!pdata->conns)
> + return -ENOMEM;
> + }
> +
> + return 0;
> +}
> +
> #ifdef CONFIG_OF
> static int of_dev_node_match(struct device *dev, void *data)
> {
> @@ -133,20 +147,6 @@ static void of_coresight_get_ports(const struct device_node *node,
> }
> }
>
> -static int of_coresight_alloc_memory(struct device *dev,
> - struct coresight_platform_data *pdata)
> -{
> - if (pdata->nr_outport) {
> - pdata->conns = devm_kzalloc(dev, pdata->nr_outport *
> - sizeof(*pdata->conns),
> - GFP_KERNEL);
> - if (!pdata->conns)
> - return -ENOMEM;
> - }
> -
> - return 0;
> -}
> -
> int of_coresight_get_cpu(const struct device_node *node)
> {
> int cpu;
> @@ -226,23 +226,17 @@ static int of_coresight_parse_endpoint(struct device *dev,
> return ret;
> }
>
> -struct coresight_platform_data *
> +static struct coresight_platform_data *
> of_get_coresight_platform_data(struct device *dev,
> - const struct device_node *node)
> + struct coresight_platform_data *pdata)
> {
> int ret = 0;
> - struct coresight_platform_data *pdata;
> struct coresight_connection *conn;
> struct device_node *ep = NULL;
> const struct device_node *parent = NULL;
> bool legacy_binding = false;
> + struct device_node *node = dev->of_node;
>
> - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> - if (!pdata)
> - return ERR_PTR(-ENOMEM);
> -
> - /* Use device name as sysfs handle */
> - pdata->name = dev_name(dev);
> pdata->cpu = of_coresight_get_cpu(node);
>
> /* Get the number of input and output port for this component */
> @@ -252,7 +246,7 @@ of_get_coresight_platform_data(struct device *dev,
> if (!pdata->nr_outport)
> return pdata;
>
> - ret = of_coresight_alloc_memory(dev, pdata);
> + ret = coresight_alloc_conns(dev, pdata);
I'm pretty sure you're doing this because you want to use
coresight_alloc_conns() for ACPI as well, and I'm fine with that. But it is
quite orthogonal to the rest of the work done in this patch and as such I think
it needs a patch of its own.
> if (ret)
> return ERR_PTR(ret);
>
> @@ -294,5 +288,26 @@ of_get_coresight_platform_data(struct device *dev,
>
> return pdata;
> }
> -EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
> #endif
> +
> +struct coresight_platform_data *
> +coresight_get_platform_data(struct device *dev)
> +{
> + struct coresight_platform_data *pdata;
> +
> + if (IS_ERR_OR_NULL(dev->fwnode))
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + /* Use device name as sysfs handle */
> + pdata->name = dev_name(dev);
> +
> + if (is_of_node(dev->fwnode))
> + return of_get_coresight_platform_data(dev, pdata);
> +
> + return ERR_PTR(-ENOENT);
> +}
> +EXPORT_SYMBOL_GPL(coresight_get_platform_data);
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index 8bbb008..7eb3bf7 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -177,15 +177,12 @@ static int replicator_probe(struct device *dev, struct resource *res)
> struct coresight_platform_data *pdata = NULL;
> struct replicator_drvdata *drvdata;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = dev->of_node;
> void __iomem *base;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - dev->platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + dev->platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> @@ -213,7 +210,6 @@ static int replicator_probe(struct device *dev, struct resource *res)
> }
>
> dev_set_drvdata(dev, drvdata);
> -
> desc.type = CORESIGHT_DEV_TYPE_LINK;
> desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
> desc.ops = &replicator_cs_ops;
> diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c
> index eb96bba..6514586 100644
> --- a/drivers/hwtracing/coresight/coresight-stm.c
> +++ b/drivers/hwtracing/coresight/coresight-stm.c
> @@ -809,14 +809,11 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id)
> size_t bitmap_size;
> struct coresight_desc desc = { 0 };
> struct coresight_device *csdev;
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
> diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
> index 7ce3427..147ab17 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc.c
> @@ -394,16 +394,13 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
> struct tmc_drvdata *drvdata;
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata)) {
> - ret = PTR_ERR(pdata);
> - goto out;
> - }
> - adev->dev.platform_data = pdata;
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata)) {
> + ret = PTR_ERR(pdata);
> + goto out;
> }
> + adev->dev.platform_data = pdata;
>
> ret = -ENOMEM;
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
> index 9763721..18a749a 100644
> --- a/drivers/hwtracing/coresight/coresight-tpiu.c
> +++ b/drivers/hwtracing/coresight/coresight-tpiu.c
> @@ -120,14 +120,11 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
> struct resource *res = &adev->res;
> struct coresight_desc desc = { 0 };
> struct coresight_device *csdev;
> - struct device_node *np = adev->dev.of_node;
>
> - if (np) {
> - pdata = of_get_coresight_platform_data(dev, np);
> - if (IS_ERR(pdata))
> - return PTR_ERR(pdata);
> - adev->dev.platform_data = pdata;
> - }
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + adev->dev.platform_data = pdata;
>
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> diff --git a/include/linux/coresight.h b/include/linux/coresight.h
> index 7b87965..5b29255 100644
> --- a/include/linux/coresight.h
> +++ b/include/linux/coresight.h
> @@ -293,14 +293,11 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {}
>
> #ifdef CONFIG_OF
> extern int of_coresight_get_cpu(const struct device_node *node);
> -extern struct coresight_platform_data *
> -of_get_coresight_platform_data(struct device *dev,
> - const struct device_node *node);
> #else
> static inline int of_coresight_get_cpu(const struct device_node *node)
> { return 0; }
> -static inline struct coresight_platform_data *of_get_coresight_platform_data(
> - struct device *dev, const struct device_node *node) { return NULL; }
> #endif
>
> +struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
> +
> #endif
> --
> 2.7.4
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-03-27 22:57 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-20 18:49 [PATCH 00/25] coresight: Support for ACPI bindings Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 01/25] coresight: tmc: Report DMA setup failures Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 02/25] coresight: dynamic-replicator: Clean up error handling Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 03/25] coresight: replicator: Prepare for merging with dynamic-replicator Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 04/25] coresight: dynamic-replicator: Prepare for merging with static replicator Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 05/25] coresight: Merge the static and dynamic replicator drivers Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-27 15:27 ` Mathieu Poirier
2019-03-27 15:27 ` Mathieu Poirier
2019-03-27 17:33 ` Suzuki K Poulose
2019-03-27 17:33 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 06/25] coresight: funnel: Clean up device book keeping Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 07/25] coresight: replicator: Cleanup device tracking Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 08/25] coresight: tmc: Clean up device specific data Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-26 21:53 ` Mathieu Poirier
2019-03-26 21:53 ` Mathieu Poirier
2019-03-27 11:45 ` Suzuki K Poulose
2019-03-27 11:45 ` Suzuki K Poulose
2019-03-27 14:42 ` Suzuki K Poulose
2019-03-27 14:42 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 09/25] coresight: catu: Cleanup " Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 10/25] coresight: tpiu: Clean up " Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-26 21:54 ` Mathieu Poirier
2019-03-26 21:54 ` Mathieu Poirier
2019-03-27 11:52 ` Suzuki K Poulose
2019-03-27 11:52 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 11/25] coresight: stm: Cleanup " Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 12/25] coresight: etm: Clean up " Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 13/25] coresight: etb10: " Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-27 21:39 ` Mathieu Poirier
2019-03-27 21:39 ` Mathieu Poirier
2019-03-28 11:09 ` Suzuki K Poulose
2019-03-28 11:09 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 14/25] coresight: Rename of_coresight to coresight-platform Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 15/25] coresight: etm3x: Rearrange cp14 access detection Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-27 22:05 ` Mathieu Poirier
2019-03-27 22:05 ` Mathieu Poirier
2019-03-28 11:03 ` Suzuki K Poulose
2019-03-28 11:03 ` Suzuki K Poulose
2019-03-28 11:03 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 16/25] coresight: stm: Rearrange probing the stimulus area Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 17/25] coresight: tmc-etr: Rearrange probing default buffer size Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 18/25] coresight: Introduce generic platform data helper Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-27 22:57 ` Mathieu Poirier [this message]
2019-03-27 22:57 ` Mathieu Poirier
2019-03-28 10:59 ` Suzuki K Poulose
2019-03-28 10:59 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 19/25] coresight: Make device to CPU mapping generic Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 20/25] coresight: platform: Use fwnode handle for device search Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 21/25] coresight: Use fwnode handle instead of device names Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-28 17:42 ` Mathieu Poirier
2019-03-28 17:42 ` Mathieu Poirier
2019-03-28 18:42 ` Suzuki K Poulose
2019-03-28 18:42 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 22/25] coresight: Use platform agnostic names Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-28 19:43 ` Mathieu Poirier
2019-03-28 19:43 ` Mathieu Poirier
2019-03-20 18:49 ` [PATCH 23/25] coresight: stm: ACPI support for parsing stimulus base Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-28 20:41 ` Mathieu Poirier
2019-03-28 20:41 ` Mathieu Poirier
2019-04-04 11:27 ` Suzuki K Poulose
2019-04-04 11:27 ` Suzuki K Poulose
2019-03-20 18:49 ` [PATCH 24/25] coresight: Support for ACPI bindings Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-29 19:09 ` Mathieu Poirier
2019-03-29 19:09 ` Mathieu Poirier
2019-03-20 18:49 ` [PATCH 25/25] coresight: acpi: Support for components Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-20 18:49 ` [TEST PATCH 26/25] edk2-platform: juno: Update ACPI CoreSight Bindings Suzuki K Poulose
2019-03-20 18:49 ` Suzuki K Poulose
2019-03-22 10:13 ` [PATCH 00/25] coresight: Support for ACPI bindings Suzuki K Poulose
2019-03-22 10:13 ` Suzuki K Poulose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190327225721.GC778@xps15 \
--to=mathieu.poirier@linaro.org \
--cc=coresight@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=robert.walker@arm.com \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.