mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pascal PAILLET-LME <p.paillet@st.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"benjamin.gaignard@linaro.org" <benjamin.gaignard@linaro.org>
Cc: Pascal PAILLET-LME <p.paillet@st.com>
Subject: [PATCH 1/3] driver core: Add device_link_remove function
Date: Thu, 5 Jul 2018 14:25:56 +0000	[thread overview]
Message-ID: <1530800748-7300-2-git-send-email-p.paillet@st.com> (raw)
In-Reply-To: <1530800748-7300-1-git-send-email-p.paillet@st.com>

From: pascal paillet <p.paillet@st.com>

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 <p.paillet@st.com>
---
 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

  reply	other threads:[~2018-07-05 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 14:25 [PATCH 0/3] link regulator consumer with driver Pascal PAILLET-LME
2018-07-05 14:25 ` Pascal PAILLET-LME [this message]
2018-07-05 16:54   ` [PATCH 1/3] driver core: Add device_link_remove function Mark Brown
2018-07-05 17:55   ` Applied "driver core: Add device_link_remove function" to the regulator tree Mark Brown
2018-07-05 14:25 ` [PATCH 2/3] regulator: core: Link consumer with regulator driver Pascal PAILLET-LME
2018-07-05 16:53   ` Mark Brown
2018-07-05 17:53     ` gregkh
2018-07-05 17:55   ` Applied "regulator: core: Link consumer with regulator driver" to the regulator tree Mark Brown
     [not found]     ` <CGME20180709111753eucas1p1f32e66fb2f7ea3216097cd72a132355d@eucas1p1.samsung.com>
2018-07-09 11:17       ` Marek Szyprowski
2018-07-09 12:13         ` Benjamin Gaignard
2018-07-09 12:26           ` Mark Brown
2018-07-05 14:25 ` [PATCH 3/3] regulator: core: Change suspend_late to suspend Pascal PAILLET-LME
2018-07-05 17:08   ` Applied "regulator: core: Change suspend_late to suspend" to the regulator tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1530800748-7300-2-git-send-email-p.paillet@st.com \
    --to=p.paillet@st.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®