1-wire: in-kernel notification on device events
PATCH 1/1 1-wire: in-kernel notification on device events
Before this patch 1-wire subsystem didn't provide access to its add/remove events to other parts of the kernel. Now it is possible to register a standard notifier_block observer, which will be informed of subsequent device insertions and removals.
The framework is copied from USB subsystem.
--- drivers/w1/Kconfig | 7 ++ drivers/w1/Makefile | 3 +- drivers/w1/notify.c | 76 ++++++++++++++++++++ drivers/w1/w1.c | 2 + drivers/w1/w1.h | 160 ++++-------------------------------------- drivers/w1/w1_int.c | 2 + drivers/w1/w1_netlink.h | 11 +-- include/linux/w1.h | 176 +++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 279 insertions(+), 158 deletions(-) create mode 100644 drivers/w1/notify.c create mode 100644 include/linux/w1.h
drivers/w1/Kconfig +7 -0
@@ -25,6 +25,13 @@ config W1_CON 2. Userspace commands. Includes read/write and search/alarm search commands. 3. Replies to userspace commands. +config W1_NOTIFY + bool "Dallas's 1-wire device notifications" + default n + ---help--- + This allows other parts of kernel to be notified of 1-wire hotplug + events. + source drivers/w1/masters/Kconfig source drivers/w1/slaves/Kconfig
drivers/w1/Makefile +2 -1
@@ -3,7 +3,8 @@ # obj-$(CONFIG_W1) += wire.o -wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o +wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o \ + notify.o obj-y += masters/ slaves/
drivers/w1/notify.c new file +76 -0
76 lines not on this page · raw message
drivers/w1/w1.c +2 -0
@@ -709,6 +709,7 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)memcpy (msg.id.id, rn,sizeof (msg.id)); msg.type =W1_SLAVE_ADD ;w1_netlink_send (dev, &msg); +w1_notify_add_slave (sl);return 0 ; }
@@ -728,6 +729,7 @@ void w1_slave_detach(struct w1_slave *sl)memcpy (msg.id.id, &sl->reg_num,sizeof (msg.id)); msg.type =W1_SLAVE_REMOVE ;w1_netlink_send (sl->master, &msg); +w1_notify_remove_slave (sl);device_remove_file (&sl->dev, &w1_slave_attr_id);device_remove_file (&sl->dev, &w1_slave_attr_name);
drivers/w1/w1.h +13 -147
186 lines not on this page · raw message
drivers/w1/w1_int.c +2 -0
@@ -179,6 +179,7 @@ int w1_add_master_device(struct w1_bus_master *master) msg.id.mst.id = dev->id; msg.type =W1_MASTER_ADD ;w1_netlink_send (dev, &msg); +w1_notify_add_master (dev);return 0 ;
@@ -224,6 +225,7 @@ void __w1_remove_master_device(struct w1_master *dev) msg.id.mst.id = dev->id; msg.type =W1_MASTER_REMOVE ;w1_netlink_send (dev, &msg); +w1_notify_remove_master (dev);w1_free_dev (dev); }
drivers/w1/w1_netlink.h +1 -10
@@ -25,18 +25,9 @@#include <asm/types.h> #include <linux/connector.h> +#include <linux/w1.h> #include "w1.h" -enum w1_netlink_message_types { -W1_SLAVE_ADD =0 , -W1_SLAVE_REMOVE , -W1_MASTER_ADD , -W1_MASTER_REMOVE , -W1_MASTER_CMD , -W1_SLAVE_CMD , -W1_LIST_MASTERS , -}; -struct w1_netlink_msg {__u8 type;
include/linux/w1.h new file +176 -0
176 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 8 lines · Sergey Yanovich
Before this patch 1-wire subsystem didn't provide access to its add/remove events to other parts of the kernel. Now it is possible to register a standard
notifier_blockobserver, which will be informed of subsequent device insertions and removals.The framework is copied from USB subsystem.
Signed-off-by Sergey Yanovich <[email protected]>
Thanks Sergey, patch looks good to me
Greg, please pull it into your tree.
Thank you
Signature · 1 line
Evgeniy Polyakov