Lines Matching refs:dev

45 	struct w1_master *dev;  in w1_alloc_dev()  local
51 dev = kzalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL); in w1_alloc_dev()
52 if (!dev) { in w1_alloc_dev()
59 dev->bus_master = (struct w1_bus_master *)(dev + 1); in w1_alloc_dev()
61 dev->owner = THIS_MODULE; in w1_alloc_dev()
62 dev->max_slave_count = slave_count; in w1_alloc_dev()
63 dev->slave_count = 0; in w1_alloc_dev()
64 dev->attempts = 0; in w1_alloc_dev()
65 dev->initialized = 0; in w1_alloc_dev()
66 dev->id = id; in w1_alloc_dev()
67 dev->slave_ttl = slave_ttl; in w1_alloc_dev()
68 dev->search_count = w1_search_count; in w1_alloc_dev()
69 dev->enable_pullup = w1_enable_pullup; in w1_alloc_dev()
74 atomic_set(&dev->refcnt, 2); in w1_alloc_dev()
76 INIT_LIST_HEAD(&dev->slist); in w1_alloc_dev()
77 INIT_LIST_HEAD(&dev->async_list); in w1_alloc_dev()
78 mutex_init(&dev->mutex); in w1_alloc_dev()
79 mutex_init(&dev->bus_mutex); in w1_alloc_dev()
80 mutex_init(&dev->list_mutex); in w1_alloc_dev()
82 memcpy(&dev->dev, device, sizeof(struct device)); in w1_alloc_dev()
83 dev_set_name(&dev->dev, "w1_bus_master%u", dev->id); in w1_alloc_dev()
84 snprintf(dev->name, sizeof(dev->name), "w1_bus_master%u", dev->id); in w1_alloc_dev()
85 dev->dev.init_name = dev->name; in w1_alloc_dev()
87 dev->driver = driver; in w1_alloc_dev()
89 dev->seq = 1; in w1_alloc_dev()
91 err = device_register(&dev->dev); in w1_alloc_dev()
94 put_device(&dev->dev); in w1_alloc_dev()
95 dev = NULL; in w1_alloc_dev()
98 return dev; in w1_alloc_dev()
101 static void w1_free_dev(struct w1_master *dev) in w1_free_dev() argument
103 device_unregister(&dev->dev); in w1_free_dev()
112 struct w1_master *dev, *entry; in w1_add_master_device() local
140 dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl, in w1_add_master_device()
142 if (!dev) { in w1_add_master_device()
147 retval = w1_create_master_attributes(dev); in w1_add_master_device()
153 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); in w1_add_master_device()
155 dev->initialized = 1; in w1_add_master_device()
157 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); in w1_add_master_device()
158 if (IS_ERR(dev->thread)) { in w1_add_master_device()
159 retval = PTR_ERR(dev->thread); in w1_add_master_device()
160 dev_err(&dev->dev, in w1_add_master_device()
167 list_add(&dev->w1_master_entry, &w1_masters); in w1_add_master_device()
171 msg.id.mst.id = dev->id; in w1_add_master_device()
173 w1_netlink_send(dev, &msg); in w1_add_master_device()
179 set_bit(W1_ABORT_SEARCH, &dev->flags); in w1_add_master_device()
180 kthread_stop(dev->thread); in w1_add_master_device()
183 w1_destroy_master_attributes(dev); in w1_add_master_device()
185 w1_free_dev(dev); in w1_add_master_device()
190 void __w1_remove_master_device(struct w1_master *dev) in __w1_remove_master_device() argument
196 list_del(&dev->w1_master_entry); in __w1_remove_master_device()
199 set_bit(W1_ABORT_SEARCH, &dev->flags); in __w1_remove_master_device()
200 kthread_stop(dev->thread); in __w1_remove_master_device()
202 mutex_lock(&dev->mutex); in __w1_remove_master_device()
203 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
204 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in __w1_remove_master_device()
205 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
207 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
209 w1_destroy_master_attributes(dev); in __w1_remove_master_device()
210 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
211 mutex_unlock(&dev->mutex); in __w1_remove_master_device()
212 atomic_dec(&dev->refcnt); in __w1_remove_master_device()
214 while (atomic_read(&dev->refcnt)) { in __w1_remove_master_device()
215 dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", in __w1_remove_master_device()
216 dev->name, atomic_read(&dev->refcnt)); in __w1_remove_master_device()
220 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
221 w1_process_callbacks(dev); in __w1_remove_master_device()
222 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
224 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
225 w1_process_callbacks(dev); in __w1_remove_master_device()
226 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
229 msg.id.mst.id = dev->id; in __w1_remove_master_device()
231 w1_netlink_send(dev, &msg); in __w1_remove_master_device()
233 w1_free_dev(dev); in __w1_remove_master_device()
242 struct w1_master *dev, *found = NULL; in w1_remove_master_device() local
244 list_for_each_entry(dev, &w1_masters, w1_master_entry) { in w1_remove_master_device()
245 if (!dev->initialized) in w1_remove_master_device()
248 if (dev->bus_master->data == bm->data) { in w1_remove_master_device()
249 found = dev; in w1_remove_master_device()