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: 10281613 X-Patchwork-Delegate: agross@codeaurora.org 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 1559A602C2 for ; Wed, 14 Mar 2018 08:17:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07F1128768 for ; Wed, 14 Mar 2018 08:17:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFA3728770; Wed, 14 Mar 2018 08:17:06 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D61028768 for ; Wed, 14 Mar 2018 08:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753395AbeCNIQu (ORCPT ); Wed, 14 Mar 2018 04:16:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60830 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752594AbeCNIO7 (ORCPT ); Wed, 14 Mar 2018 04:14:59 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7AD1360851; 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 Cc: mark.rutland@arm.com, will.deacon@arm.com, robdclark@gmail.com, tfiga@chromium.org, sricharan@codeaurora.org, m.szyprowski@samsung.com, architt@codeaurora.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, vivek.gautam@codeaurora.org, "Rafael J . Wysocki" , Greg Kroah-Hartman 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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