[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFp+6iH5E3qZNS65AHWEAypMwy7bfRg62_TFc3dBEYu_H-K0mg@mail.gmail.com>
Date: Tue, 13 Mar 2018 15:28:47 +0530
From: Vivek Gautam <vivek.gautam@...eaurora.org>
To: "list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <joro@...tes.org>,
"robh+dt" <robh+dt@...nel.org>,
Robin Murphy <robin.murphy@....com>,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <iommu@...ts.linux-foundation.org>,
devicetree@...r.kernel.org,
open list <linux-kernel@...r.kernel.org>
Cc: Mark Rutland <mark.rutland@....com>,
Will Deacon <will.deacon@....com>,
Rob Clark <robdclark@...il.com>,
Tomasz Figa <tfiga@...omium.org>,
Sricharan R <sricharan@...eaurora.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Archit Taneja <architt@...eaurora.org>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>,
Vivek Gautam <vivek.gautam@...eaurora.org>,
"Rafael J . Wysocki" <rjw@...ysocki.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v9 1/5] driver core: Find an existing link between two devices
On Tue, Mar 13, 2018 at 2:25 PM, Vivek Gautam
<vivek.gautam@...eaurora.org> wrote:
> The lists managing the device-links can be traversed to
> find the link between two devices. The device_link_add() APIs
> does traverse these lists to check if there's already a link
> setup between the two devices.
> So, add a new APIs, device_link_find(), to find an existing
> device link between two devices - suppliers and consumers.
>
> Signed-off-by: Vivek Gautam <vivek.gautam@...eaurora.org>
> Cc: Rafael J. Wysocki <rjw@...ysocki.net>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> ---
>
> * New patch added to this series.
>
> drivers/base/core.c | 30 +++++++++++++++++++++++++++---
> include/linux/device.h | 2 ++
> 2 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 5847364f25d9..e8c9774e4ba2 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -144,6 +144,30 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)
> return 0;
> }
>
> +/**
> + * device_link_find - find any existing link between two devices.
> + * @consumer: Consumer end of the link.
> + * @supplier: Supplier end of the link.
> + *
> + * Returns pointer to the existing link between a supplier and
> + * and consumer devices, or NULL if no link exists.
> + */
> +struct device_link *device_link_find(struct device *consumer,
> + struct device *supplier)
> +{
> + struct device_link *link = NULL;
> +
> + if (!consumer || !supplier)
> + return NULL;
> +
> + list_for_each_entry(link, &supplier->links.consumers, s_node)
> + if (link->consumer == consumer)
> + break;
> +
> + return link;
My bad, this too needs fixing (didn't add the changes to the patch :( )
list_for_each_entry(link, &supplier->links.consumers, s_node)
if (link->consumer == consumer)
return link;
return NULL;
> +}
> +EXPORT_SYMBOL_GPL(device_link_find);
> +
> /**
> * device_link_add - Create a link between two devices.
> * @consumer: Consumer end of the link.
> @@ -195,9 +219,9 @@ struct device_link *device_link_add(struct device *consumer,
> goto out;
> }
>
> - list_for_each_entry(link, &supplier->links.consumers, s_node)
> - if (link->consumer == consumer)
> - goto out;
> + link = device_link_find(consumer, supplier);
> + if (link)
> + goto out;
>
> link = kzalloc(sizeof(*link), GFP_KERNEL);
> if (!link)
> diff --git a/include/linux/device.h b/include/linux/device.h
> index b093405ed525..13bc1884c3eb 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1278,6 +1278,8 @@ extern const char *dev_driver_string(const struct device *dev);
> struct device_link *device_link_add(struct device *consumer,
> struct device *supplier, u32 flags);
> void device_link_del(struct device_link *link);
> +struct device_link *device_link_find(struct device *consumer,
> + struct device *supplier);
>
> #ifdef CONFIG_PRINTK
>
> --
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Powered by blists - more mailing lists