From patchwork Wed Mar 14 08:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10281601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 250A7602C2 for ; Wed, 14 Mar 2018 08:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 180CD2876D for ; Wed, 14 Mar 2018 08:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C95628771; Wed, 14 Mar 2018 08:16:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D48B2876D for ; Wed, 14 Mar 2018 08:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9oQzhxnQ14YcMPYQZLO+ygBas+aZjpuXx3NuV0/AGMU=; b=eTOX/Wfc1APhOLjGYOQq+CV8kX V2qVsJPe84Lfn0368dnvqXgkuIoDHwKdjefpq+nDyUiK1s2wLTM9KctWEtdNSvyrDL7diOyPtFseg 6A+cyXK89aLh976tdyQ++4XW/TByZKuYvjJzir+0DWQ2vu+IkyGAI7vPq+w26Te38C7/HGqCQeWuH VxpiLNVQwhmKloopBQs7WH3S4kjNi5z4JVOw0NqRlY0CvUQ96pJ+72LDbc4R8irBeOkxQGrUHDMNg /Rl5G0KOnMlINocntgdyIDFHzZ+M6npkkPonBekNWzGJb/0d2ZQ7/xFdthGg3wDLg4y/Y9Sms6AAc K6H+RK1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew1Zp-0005fU-JM; Wed, 14 Mar 2018 08:16:01 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew1Yt-0003kA-V2 for linux-arm-kernel@lists.infradead.org; Wed, 14 Mar 2018 08:15:07 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6B95460592; Wed, 14 Mar 2018 08:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521015298; bh=sk5Pnj+Bibytm9zhc1hok6XG+O/7hZH9vHIAVKIjWHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lcQjhQ925AH7bYgwlGfsgWJtAYaJ4BrSRVEYp7G6guGT+XxfbmZUHJgISFg9H3eP3 L3pCDARmLDjGKaSkoZq4NJ/k4IBvdx/EyZKPY6rn2+RZTA1kn84gfvLZLuQ2t3kNIa jSponr8Teasw/0QTDz1ZyRayZNgsMS3k6i9LFOwg= Received: from blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 787C960592; Wed, 14 Mar 2018 08:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521015296; bh=sk5Pnj+Bibytm9zhc1hok6XG+O/7hZH9vHIAVKIjWHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oD965LhMWmGpTolWtuGQHMnq4J5gNHEapfL3jPugt+3O/ap9lbdVS7nZGZYRxU6PH DR/sSCiU0FFiJQ/5y7LwUShdwVLeFq1R5U/XKdyu79p490iJ7nSYtJMSjdwMWWHgFn 66bdCLmqBEb8bZOx4gUqd1z/NJH/hDwRJus2DtBo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 787C960592 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 From: Vivek Gautam To: joro@8bytes.org, robh+dt@kernel.org, rafael.j.wysocki@intel.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 1/5] driver core: Delete the link between two given devices Date: Wed, 14 Mar 2018 13:44:30 +0530 Message-Id: <20180314081434.30875-2-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180314081434.30875-1-vivek.gautam@codeaurora.org> References: <20180314081434.30875-1-vivek.gautam@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180314_011504_119512_60B67E10 X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, "Rafael J . Wysocki" , architt@codeaurora.org, linux-arm-msm@vger.kernel.org, will.deacon@arm.com, tfiga@chromium.org, robdclark@gmail.com, vivek.gautam@codeaurora.org, Greg Kroah-Hartman , sricharan@codeaurora.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Given the consumer and supplier devices, add an API to delete the link between them. Suggested-by: Tomasz Figa Signed-off-by: Vivek Gautam Cc: Rafael J. Wysocki Cc: Greg Kroah-Hartman --- - This patch replaces an earlier patch [1] that was adding device_link_find() API. [1] https://patchwork.kernel.org/patch/10277975/ drivers/base/core.c | 31 +++++++++++++++++++++++++++++++ include/linux/device.h | 1 + 2 files changed, 32 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 5847364f25d9..e13d904e1e12 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -336,6 +336,37 @@ void device_link_del(struct device_link *link) } EXPORT_SYMBOL_GPL(device_link_del); +/** + * device_link_del_dev - Delete a link between two given devices + * @consumer: Consumer end of the link. + * @supplier: Supplier end of the link. + * + * The caller must ensure proper synchronization of this function with runtime + * PM. + */ +void device_link_del_dev(struct device *consumer, struct device *supplier) +{ + struct device_link *link; + + if (!consumer || !supplier) + return; + + device_links_write_lock(); + device_pm_lock(); + + list_for_each_entry(link, &supplier->links.consumers, s_node) { + if (link->consumer == consumer) { + __device_link_del(link); + /* just one link between the devices */ + break; + } + } + + device_pm_unlock(); + device_links_write_unlock(); +} +EXPORT_SYMBOL_GPL(device_link_del_dev); + static void device_links_missing_supplier(struct device *dev) { struct device_link *link; diff --git a/include/linux/device.h b/include/linux/device.h index b093405ed525..14508d843f67 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1278,6 +1278,7 @@ 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); +void device_link_del_dev(struct device *consumer, struct device *supplier); #ifdef CONFIG_PRINTK