aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/w1_int.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2005-06-22 21:26:47 -0400
committerSteve French <sfrench@us.ibm.com>2005-06-22 21:26:47 -0400
commitea0daab4ae4a2f853f06c76961c0ed324fd0804c (patch)
treef6fbe2db5772695181b7a7257b05e43343bd8d75 /drivers/w1/w1_int.c
parent58aab753de605c14b9878a897e7349c3063afeff (diff)
parent1bdf7a78c2b21fb94dfe7994dbe89310b18479d2 (diff)
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git
Diffstat (limited to 'drivers/w1/w1_int.c')
-rw-r--r--drivers/w1/w1_int.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 5f0bafbbd575..35e85d961702 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * w1_int.c 2 * w1_int.c
3 * 3 *
4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> 4 * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -39,8 +39,9 @@ extern spinlock_t w1_mlock;
39 39
40extern int w1_process(void *); 40extern int w1_process(void *);
41 41
42struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, 42static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
43 struct device_driver *driver, struct device *device) 43 struct device_driver *driver,
44 struct device *device)
44{ 45{
45 struct w1_master *dev; 46 struct w1_master *dev;
46 int err; 47 int err;
@@ -60,14 +61,15 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
60 61
61 dev->bus_master = (struct w1_bus_master *)(dev + 1); 62 dev->bus_master = (struct w1_bus_master *)(dev + 1);
62 63
63 dev->owner = THIS_MODULE; 64 dev->owner = THIS_MODULE;
64 dev->max_slave_count = slave_count; 65 dev->max_slave_count = slave_count;
65 dev->slave_count = 0; 66 dev->slave_count = 0;
66 dev->attempts = 0; 67 dev->attempts = 0;
67 dev->kpid = -1; 68 dev->kpid = -1;
68 dev->initialized = 0; 69 dev->initialized = 0;
69 dev->id = id; 70 dev->id = id;
70 dev->slave_ttl = slave_ttl; 71 dev->slave_ttl = slave_ttl;
72 dev->search_count = -1; /* continual scan */
71 73
72 atomic_set(&dev->refcnt, 2); 74 atomic_set(&dev->refcnt, 2);
73 75
@@ -105,7 +107,7 @@ struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
105 return dev; 107 return dev;
106} 108}
107 109
108void w1_free_dev(struct w1_master *dev) 110static void w1_free_dev(struct w1_master *dev)
109{ 111{
110 device_unregister(&dev->dev); 112 device_unregister(&dev->dev);
111 if (dev->nls && dev->nls->sk_socket) 113 if (dev->nls && dev->nls->sk_socket)
@@ -120,6 +122,13 @@ int w1_add_master_device(struct w1_bus_master *master)
120 int retval = 0; 122 int retval = 0;
121 struct w1_netlink_msg msg; 123 struct w1_netlink_msg msg;
122 124
125 /* validate minimum functionality */
126 if (!(master->touch_bit && master->reset_bus) &&
127 !(master->write_bit && master->read_bit)) {
128 printk(KERN_ERR "w1_add_master_device: invalid function set\n");
129 return(-EINVAL);
130 }
131
123 dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device); 132 dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device);
124 if (!dev) 133 if (!dev)
125 return -ENOMEM; 134 return -ENOMEM;
@@ -153,7 +162,7 @@ int w1_add_master_device(struct w1_bus_master *master)
153 return 0; 162 return 0;
154 163
155err_out_kill_thread: 164err_out_kill_thread:
156 dev->need_exit = 1; 165 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
157 if (kill_proc(dev->kpid, SIGTERM, 1)) 166 if (kill_proc(dev->kpid, SIGTERM, 1))
158 dev_err(&dev->dev, 167 dev_err(&dev->dev,
159 "Failed to send signal to w1 kernel thread %d.\n", 168 "Failed to send signal to w1 kernel thread %d.\n",
@@ -171,7 +180,7 @@ void __w1_remove_master_device(struct w1_master *dev)
171 int err; 180 int err;
172 struct w1_netlink_msg msg; 181 struct w1_netlink_msg msg;
173 182
174 dev->need_exit = 1; 183 set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
175 err = kill_proc(dev->kpid, SIGTERM, 1); 184 err = kill_proc(dev->kpid, SIGTERM, 1);
176 if (err) 185 if (err)
177 dev_err(&dev->dev, 186 dev_err(&dev->dev,
@@ -197,10 +206,8 @@ void __w1_remove_master_device(struct w1_master *dev)
197void w1_remove_master_device(struct w1_bus_master *bm) 206void w1_remove_master_device(struct w1_bus_master *bm)
198{ 207{
199 struct w1_master *dev = NULL; 208 struct w1_master *dev = NULL;
200 struct list_head *ent, *n;
201 209
202 list_for_each_safe(ent, n, &w1_masters) { 210 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
203 dev = list_entry(ent, struct w1_master, w1_master_entry);
204 if (!dev->initialized) 211 if (!dev->initialized)
205 continue; 212 continue;
206 213