All of lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: krzk@kernel.org
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
	Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH 2/3] w1: move slave uevent into w1_slave_device_type
Date: Fri, 21 Aug 2026 00:54:10 +0200	[thread overview]
Message-ID: <20260820225430.1847356-2-dakr@kernel.org> (raw)
In-Reply-To: <20260820225430.1847356-1-dakr@kernel.org>

The bus-level w1_uevent() only ever added uevent variables (W1_FID,
W1_SLAVE_ID) for slave devices.

Move the slave uevent logic into w1_slave_device_type.uevent where it
naturally belongs and remove the bus-level uevent callback entirely.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
Compile-tested only, no hardware available.

I think the dev_dbg() stuff wasn't really  useful, so I dropped it.
---
 drivers/w1/w1.c | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index faa1c03f4807..b40f2d9fd29d 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -164,11 +164,14 @@ static const struct device_type w1_master_device_type = {
 	.name = "w1_master",
 };
 
+static int w1_slave_uevent(const struct device *dev,
+			   struct kobj_uevent_env *env);
+
 static const struct device_type w1_slave_device_type = {
 	.name = "w1_slave",
+	.uevent = w1_slave_uevent,
 };
 
-static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env);
 static struct device_driver w1_slave_driver;
 
 static int w1_match(struct device *dev, const struct device_driver *drv)
@@ -183,7 +186,6 @@ static int w1_match(struct device *dev, const struct device_driver *drv)
 static const struct bus_type w1_bus_type = {
 	.name = "w1",
 	.match = w1_match,
-	.uevent = w1_uevent,
 };
 
 struct device_driver w1_master_driver = {
@@ -580,39 +582,18 @@ void w1_destroy_master_attributes(struct w1_master *master)
 	sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group);
 }
 
-static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env)
+static int w1_slave_uevent(const struct device *dev,
+			   struct kobj_uevent_env *env)
 {
-	const struct w1_master *md = NULL;
-	const struct w1_slave *sl = NULL;
-	const char *event_owner, *name;
-	int err = 0;
-
-	if (dev->type == &w1_master_device_type) {
-		md = container_of(dev, struct w1_master, dev);
-		event_owner = "master";
-		name = md->name;
-	} else if (dev->type == &w1_slave_device_type) {
-		sl = container_of(dev, struct w1_slave, dev);
-		event_owner = "slave";
-		name = sl->name;
-	} else {
-		dev_dbg(dev, "Unknown event.\n");
-		return -EINVAL;
-	}
-
-	dev_dbg(dev, "Hotplug event for %s %s, bus_id=%s.\n",
-			event_owner, name, dev_name(dev));
-
-	if (dev->type != &w1_slave_device_type || !sl)
-		goto end;
+	const struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
+	int err;
 
 	err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family);
 	if (err)
-		goto end;
+		return err;
 
 	err = add_uevent_var(env, "W1_SLAVE_ID=%024LX",
 			     (unsigned long long)sl->reg_num.id);
-end:
 	return err;
 }
 
-- 
2.55.0


  reply	other threads:[~2026-08-20 22:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 22:54 [PATCH 1/3] w1: use match() callback instead of hardwiring dev->driver Danilo Krummrich
2026-08-20 22:54 ` Danilo Krummrich [this message]
2026-08-20 22:54 ` [PATCH 3/3] w1: stop using struct device template for master devices Danilo Krummrich

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=20260820225430.1847356-2-dakr@kernel.org \
    --to=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=krzk@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.