aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1_int.c
diff options
context:
space:
mode:
authorEvgeniy Polyakov <johnpol@2ka.mipt.ru>2006-03-23 11:11:58 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-22 14:22:50 -0400
commit12003375acd879e498c6c511faf27531296f9640 (patch)
treef69001169d28c6e56e1a12e04420683620e31d79 /drivers/w1/w1_int.c
parent81f6075ebcf3b0800321b7d81e4845d6ad9566d8 (diff)
[PATCH] w1: Userspace communication protocol over connector.
There are three types of messages between w1 core and userspace: 1. Events. They are generated each time new master or slave device found either due to automatic or requested search. 2. Userspace commands. Includes read/write and search/alarm search comamnds. 3. Replies to userspace commands. From: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1/w1_int.c')
-rw-r--r--drivers/w1/w1_int.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 68565aacec7..ae78473d11f 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -27,10 +27,19 @@
27#include "w1.h" 27#include "w1.h"
28#include "w1_log.h" 28#include "w1_log.h"
29#include "w1_netlink.h" 29#include "w1_netlink.h"
30#include "w1_int.h"
31 30
32static u32 w1_ids = 1; 31static u32 w1_ids = 1;
33 32
33extern struct device_driver w1_master_driver;
34extern struct bus_type w1_bus_type;
35extern struct device w1_master_device;
36extern int w1_max_slave_count;
37extern int w1_max_slave_ttl;
38extern struct list_head w1_masters;
39extern struct semaphore w1_mlock;
40
41extern int w1_process(void *);
42
34static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, 43static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
35 struct device_driver *driver, 44 struct device_driver *driver,
36 struct device *device) 45 struct device *device)
@@ -74,16 +83,11 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
74 83
75 dev->driver = driver; 84 dev->driver = driver;
76 85
77 dev->groups = 1;
78 dev->seq = 1; 86 dev->seq = 1;
79 dev_init_netlink(dev);
80 87
81 err = device_register(&dev->dev); 88 err = device_register(&dev->dev);
82 if (err) { 89 if (err) {
83 printk(KERN_ERR "Failed to register master device. err=%d\n", err); 90 printk(KERN_ERR "Failed to register master device. err=%d\n", err);
84
85 dev_fini_netlink(dev);
86
87 memset(dev, 0, sizeof(struct w1_master)); 91 memset(dev, 0, sizeof(struct w1_master));
88 kfree(dev); 92 kfree(dev);
89 dev = NULL; 93 dev = NULL;
@@ -92,7 +96,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
92 return dev; 96 return dev;
93} 97}
94 98
95static void w1_free_dev(struct w1_master *dev) 99void w1_free_dev(struct w1_master *dev)
96{ 100{
97 device_unregister(&dev->dev); 101 device_unregister(&dev->dev);
98} 102}
@@ -131,12 +135,12 @@ int w1_add_master_device(struct w1_bus_master *master)
131 135
132 dev->initialized = 1; 136 dev->initialized = 1;
133 137
134 spin_lock(&w1_mlock); 138 down(&w1_mlock);
135 list_add(&dev->w1_master_entry, &w1_masters); 139 list_add(&dev->w1_master_entry, &w1_masters);
136 spin_unlock(&w1_mlock); 140 up(&w1_mlock);
137 141
142 memset(&msg, 0, sizeof(msg));
138 msg.id.mst.id = dev->id; 143 msg.id.mst.id = dev->id;
139 msg.id.mst.pid = dev->thread->pid;
140 msg.type = W1_MASTER_ADD; 144 msg.type = W1_MASTER_ADD;
141 w1_netlink_send(dev, &msg); 145 w1_netlink_send(dev, &msg);
142 146
@@ -153,7 +157,6 @@ err_out_free_dev:
153void __w1_remove_master_device(struct w1_master *dev) 157void __w1_remove_master_device(struct w1_master *dev)
154{ 158{
155 struct w1_netlink_msg msg; 159 struct w1_netlink_msg msg;
156 pid_t pid = dev->thread->pid;
157 160
158 set_bit(W1_MASTER_NEED_EXIT, &dev->flags); 161 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
159 kthread_stop(dev->thread); 162 kthread_stop(dev->thread);
@@ -166,8 +169,8 @@ void __w1_remove_master_device(struct w1_master *dev)
166 flush_signals(current); 169 flush_signals(current);
167 } 170 }
168 171
172 memset(&msg, 0, sizeof(msg));
169 msg.id.mst.id = dev->id; 173 msg.id.mst.id = dev->id;
170 msg.id.mst.pid = pid;
171 msg.type = W1_MASTER_REMOVE; 174 msg.type = W1_MASTER_REMOVE;
172 w1_netlink_send(dev, &msg); 175 w1_netlink_send(dev, &msg);
173 176