Received: by 10.213.65.68 with SMTP id h4csp245044imn; Tue, 13 Mar 2018 03:00:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELsbAmhH8CsPkcUgoBbTkSz83CfXG77F/iXxVqB02+AMS9FBRf8wvBClnwuRZysLz7UC8hzu X-Received: by 10.99.56.68 with SMTP id h4mr7910pgn.230.1520935233911; Tue, 13 Mar 2018 03:00:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520935233; cv=none; d=google.com; s=arc-20160816; b=iTbuqyFjjDDZcgM+DmokOGpLyqrMybGf5ZLgoBPQFAryWuF9BxMmgovTz5MDh8xrRD 8FlgUVeCV7NwG4848H3OeMORrmmP0Dcubk/zWtTzs8TfaTezNrzgxG2XGv3kTmeX5KvX IjWmiwE99L+xHcmUMsHG8DeOzev0M3RjoJxcMuadODFXrhgEbmLGK4qdrIWqc8fInQnL fDIivBiOV+wqBAlcWLY00y1ztIpjaMfXPrjC9xCqdrglKjy16S/e2BhHBtqxli38KqQy rYbuiKyqJBEm806tFCfHPFk+kFrhA+2Uw1J7CE6Miy3HeVeGjLmsvk3PAUYwSLuqnYQH ma5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=hnHnbclzHB1BY3sn1vpgU1pEBUBfCLor18ccQ3l2UKs=; b=0VdOghKNxl9gdZ5QeIPuylTJloMQsYlvblfftKiy8TdxRJzyYd9IsaC4AUWj1kea8J vpoBvx3MGSeADb4qhvC+HJ1p9oFfweE8+ahtEuvhrbBEr3loxo3fVMqnyhBGvHMJaMlT SHn7unqzrRHvxP6MUPFu5VW1fP1lWD6co0kKuRQ+2AuxDaWmfUjq/PbU+bWEQ44xHOrX 6FoOU2FydEKU9zhqSdESC7dAdWMg6wiEBf+P48ekJpSyPYqqW6d7QorxalG6jw/18syM NO84wwo1W+xMDUlo2RyfCOtsXMAgP8g40a9ZUct8gGGHbKQItKrNY4knhik5v1ZGpC03 ruow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Gf4I7+Bg; dkim=pass header.i=@codeaurora.org header.s=default header.b=QEXuaglM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i23-v6si7791828pll.579.2018.03.13.03.00.19; Tue, 13 Mar 2018 03:00:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Gf4I7+Bg; dkim=pass header.i=@codeaurora.org header.s=default header.b=QEXuaglM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752707AbeCMJ6y (ORCPT + 99 others); Tue, 13 Mar 2018 05:58:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46790 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752692AbeCMJ6v (ORCPT ); Tue, 13 Mar 2018 05:58:51 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 81BF86081C; Tue, 13 Mar 2018 09:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520935130; bh=oawujmpHJB/LEO99ENixQu13LP+WiX+lNPhWjxcBG7o=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Gf4I7+BgShdg/f3o2lh+CaTJ32G2NfkMB08vW/d2x+xdVTFDJ1GBaIZrpM1hhG1p3 5JcOdBkuy1nQVJIl0bUjAADhm84tj6He8vc6qa1zpnhUL1eaA+nHOd0nVWlBC0M9cd M6kODB6rKAHaWW9ed9lt/lVhknIPR+p/jVKW3+a0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail-qk0-f178.google.com (mail-qk0-f178.google.com [209.85.220.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D335C60853; Tue, 13 Mar 2018 09:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520935129; bh=oawujmpHJB/LEO99ENixQu13LP+WiX+lNPhWjxcBG7o=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=QEXuaglM4NLGjEns/c3OYHsLf+eRxZLVwOhtKQ+MEko7B+Xgvtmj+gMiwRtM7FVEF U5R8VFuVHRCQQtZXY5Xwg21G6xXjAyoisHGb9kFafJeWFGdJbTkFytX/mgt7PbM2X+ e+lr3XZ/OWdZ/l/21x2w0QBEPzM1trwsQsIvpT98= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D335C60853 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Received: by mail-qk0-f178.google.com with SMTP id s78so5107051qkl.8; Tue, 13 Mar 2018 02:58:48 -0700 (PDT) X-Gm-Message-State: AElRT7G8A0jJaYAeUAKvW+OmwxJxun/ABFG3qWci/p0TgD1fOUCZX/xJ wbd7o2ruPek4Fu/vYYQYjkuwLGa/50mmX7c+AGk= X-Received: by 10.55.16.135 with SMTP id 7mr15531611qkq.85.1520935128013; Tue, 13 Mar 2018 02:58:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.83.10 with HTTP; Tue, 13 Mar 2018 02:58:47 -0700 (PDT) In-Reply-To: <20180313085534.11650-2-vivek.gautam@codeaurora.org> References: <20180313085534.11650-1-vivek.gautam@codeaurora.org> <20180313085534.11650-2-vivek.gautam@codeaurora.org> From: Vivek Gautam Date: Tue, 13 Mar 2018 15:28:47 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 1/5] driver core: Find an existing link between two devices To: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , "robh+dt" , Robin Murphy , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, open list Cc: Mark Rutland , Will Deacon , Rob Clark , Tomasz Figa , Sricharan R , Marek Szyprowski , Archit Taneja , linux-arm-msm , Vivek Gautam , "Rafael J . Wysocki" , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 2:25 PM, Vivek Gautam 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 > Cc: Rafael J. Wysocki > Cc: Greg Kroah-Hartman > --- > > * 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@vger.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