Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp698432imm; Thu, 5 Jul 2018 07:28:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdHRoxsmFgX7DrxzrJNkwAvo07MV9kBo6G94E+8DBr8x3WQbEldWwO8c6MDnYAoBpIlT7Iv X-Received: by 2002:a17:902:8601:: with SMTP id f1-v6mr6416885plo.196.1530800917480; Thu, 05 Jul 2018 07:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530800917; cv=none; d=google.com; s=arc-20160816; b=j0eO0yR5VozeQllQnRbj/f0h+bD/NZkigyHrzRGSO5jta5RfRdWWpOTEo+Tyo9nmEv GFY4Dv7DCtZoGlZBwB1+Ibcah02z1B0CP5QdHaNMlw9zrB6gzdsGPLwvVf/F/xA7J5Xx 7HBt2v5kXcrmrWPoq47zst23yw4ON3d31EzY77oryRJ9MGuXuMNx2Z1PCJRq+fi+f3+y l+qZT2agNJNMgIEEUJtZCO9H1yHLPeEYxvxwp9Bqz8cEuK7m178eXHLrdCt/kknFU2A7 +q81wdcQzUhE3nNTy77vdl2zvIuqqzCk5uTCg806xF/xPMlTbe9I3ECEcHns72nFgj6J TGkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=YJUn19vZHsc5rDtDTB+FBOIQ2uFnKRmg47HdieD7uOg=; b=LPxXOgq6OYM1BvAZyYPNHEEy3iZmjjOeH9szK6y7QWw0KfS4sO6KzgWhVqogRQJrmW 1y6CNHsx0oWdW/JxB3QwJ3at+csqAmt/8vrb4xfxlm/L7INXxMpFQPsYFcshc8x/cKl+ yRnrB4BRlamqOpJuzl5V6sxKWAcLdFvPA9KQr8EbDoVNd/imiXOAHKUsHvHxHtjfAQjC fYkDexUYtYzwf/zYprZlOoViNSQbHOfgp88vbPNnH2ZFiK8svbkdSTVCYcxRTEYttq9p OpHd8z8bgTgY+YaPOE11cl1FYXE+QsCL/dMcmzcDCaVAtsKArTuxzLpuEs1FGWjFyHBe yUJA== ARC-Authentication-Results: i=1; mx.google.com; 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 w135-v6si6480049pff.8.2018.07.05.07.28.22; Thu, 05 Jul 2018 07:28:37 -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; 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 S1754119AbeGEO0J convert rfc822-to-8bit (ORCPT + 99 others); Thu, 5 Jul 2018 10:26:09 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:47495 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753809AbeGEO0F (ORCPT ); Thu, 5 Jul 2018 10:26:05 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w65EO86E025421; Thu, 5 Jul 2018 16:25:57 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2k0dnr1mxe-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 05 Jul 2018 16:25:57 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B15613A; Thu, 5 Jul 2018 14:25:56 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 917B72064; Thu, 5 Jul 2018 14:25:56 +0000 (GMT) Received: from SFHDAG6NODE2.st.com (10.75.127.17) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 5 Jul 2018 16:25:56 +0200 Received: from SFHDAG6NODE2.st.com ([fe80::a56f:c186:bab7:13d6]) by SFHDAG6NODE2.st.com ([fe80::a56f:c186:bab7:13d6%20]) with mapi id 15.00.1347.000; Thu, 5 Jul 2018 16:25:56 +0200 From: Pascal PAILLET-LME To: "gregkh@linuxfoundation.org" , "lgirdwood@gmail.com" , "broonie@kernel.org" , "linux-kernel@vger.kernel.org" , "benjamin.gaignard@linaro.org" CC: Pascal PAILLET-LME Subject: [PATCH 1/3] driver core: Add device_link_remove function Thread-Topic: [PATCH 1/3] driver core: Add device_link_remove function Thread-Index: AQHUFGwWCME9OX6GqUWbR0NHHzmfQA== Date: Thu, 5 Jul 2018 14:25:56 +0000 Message-ID: <1530800748-7300-2-git-send-email-p.paillet@st.com> References: <1530800748-7300-1-git-send-email-p.paillet@st.com> In-Reply-To: <1530800748-7300-1-git-send-email-p.paillet@st.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.51] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-05_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: pascal paillet Device_link_remove uses the same arguments than device_link_add. The Goal is to avoid storing the link pointer. Signed-off-by: pascal paillet --- drivers/base/core.c | 30 ++++++++++++++++++++++++++++++ include/linux/device.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 36622b5..3b380b1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -365,6 +365,36 @@ void device_link_del(struct device_link *link) } EXPORT_SYMBOL_GPL(device_link_del); +/** + * device_link_remove - remove a link between two 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_remove(void *consumer, struct device *supplier) +{ + struct device_link *link; + + if (WARN_ON(consumer == supplier)) + return; + + device_links_write_lock(); + device_pm_lock(); + + list_for_each_entry(link, &supplier->links.consumers, s_node) { + if (link->consumer == consumer) { + kref_put(&link->kref, __device_link_del); + break; + } + } + + device_pm_unlock(); + device_links_write_unlock(); +} +EXPORT_SYMBOL_GPL(device_link_remove); + 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 055a69d..9c1c3b1 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1316,6 +1316,7 @@ extern void devm_device_remove_group(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_remove(void *consumer, struct device *supplier); #ifdef CONFIG_PRINTK -- 1.9.1