Lines Matching refs:dev

28 	struct w1_master *dev;  in w1_alloc_dev()  local
34 dev = kzalloc(sizeof(struct w1_master) + sizeof(struct w1_bus_master), GFP_KERNEL); in w1_alloc_dev()
35 if (!dev) { in w1_alloc_dev()
42 dev->bus_master = (struct w1_bus_master *)(dev + 1); in w1_alloc_dev()
44 dev->owner = THIS_MODULE; in w1_alloc_dev()
45 dev->max_slave_count = slave_count; in w1_alloc_dev()
46 dev->slave_count = 0; in w1_alloc_dev()
47 dev->attempts = 0; in w1_alloc_dev()
48 dev->initialized = 0; in w1_alloc_dev()
49 dev->id = id; in w1_alloc_dev()
50 dev->slave_ttl = slave_ttl; in w1_alloc_dev()
51 dev->search_count = w1_search_count; in w1_alloc_dev()
52 dev->enable_pullup = w1_enable_pullup; in w1_alloc_dev()
56 atomic_set(&dev->refcnt, 1); in w1_alloc_dev()
58 INIT_LIST_HEAD(&dev->slist); in w1_alloc_dev()
59 INIT_LIST_HEAD(&dev->async_list); in w1_alloc_dev()
60 mutex_init(&dev->mutex); in w1_alloc_dev()
61 mutex_init(&dev->bus_mutex); in w1_alloc_dev()
62 mutex_init(&dev->list_mutex); in w1_alloc_dev()
64 memcpy(&dev->dev, device, sizeof(struct device)); in w1_alloc_dev()
65 dev_set_name(&dev->dev, "w1_bus_master%u", dev->id); in w1_alloc_dev()
66 snprintf(dev->name, sizeof(dev->name), "w1_bus_master%u", dev->id); in w1_alloc_dev()
67 dev->dev.init_name = dev->name; in w1_alloc_dev()
69 dev->driver = driver; in w1_alloc_dev()
71 dev->seq = 1; in w1_alloc_dev()
73 err = device_register(&dev->dev); in w1_alloc_dev()
76 put_device(&dev->dev); in w1_alloc_dev()
77 dev = NULL; in w1_alloc_dev()
80 return dev; in w1_alloc_dev()
83 static void w1_free_dev(struct w1_master *dev) in w1_free_dev() argument
85 device_unregister(&dev->dev); in w1_free_dev()
94 struct w1_master *dev, *entry; in w1_add_master_device() local
122 dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl, in w1_add_master_device()
124 if (!dev) { in w1_add_master_device()
129 retval = w1_create_master_attributes(dev); in w1_add_master_device()
135 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); in w1_add_master_device()
137 dev->initialized = 1; in w1_add_master_device()
139 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); in w1_add_master_device()
140 if (IS_ERR(dev->thread)) { in w1_add_master_device()
141 retval = PTR_ERR(dev->thread); in w1_add_master_device()
142 dev_err(&dev->dev, in w1_add_master_device()
149 list_add(&dev->w1_master_entry, &w1_masters); in w1_add_master_device()
153 msg.id.mst.id = dev->id; in w1_add_master_device()
155 w1_netlink_send(dev, &msg); in w1_add_master_device()
161 set_bit(W1_ABORT_SEARCH, &dev->flags); in w1_add_master_device()
162 kthread_stop(dev->thread); in w1_add_master_device()
165 w1_destroy_master_attributes(dev); in w1_add_master_device()
167 w1_free_dev(dev); in w1_add_master_device()
173 void __w1_remove_master_device(struct w1_master *dev) in __w1_remove_master_device() argument
179 list_del(&dev->w1_master_entry); in __w1_remove_master_device()
182 set_bit(W1_ABORT_SEARCH, &dev->flags); in __w1_remove_master_device()
183 kthread_stop(dev->thread); in __w1_remove_master_device()
185 mutex_lock(&dev->mutex); in __w1_remove_master_device()
186 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
187 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in __w1_remove_master_device()
188 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
190 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
192 w1_destroy_master_attributes(dev); in __w1_remove_master_device()
193 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
194 mutex_unlock(&dev->mutex); in __w1_remove_master_device()
195 atomic_dec(&dev->refcnt); in __w1_remove_master_device()
197 while (atomic_read(&dev->refcnt)) { in __w1_remove_master_device()
198 dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", in __w1_remove_master_device()
199 dev->name, atomic_read(&dev->refcnt)); in __w1_remove_master_device()
203 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
204 w1_process_callbacks(dev); 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()
208 w1_process_callbacks(dev); in __w1_remove_master_device()
209 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
212 msg.id.mst.id = dev->id; in __w1_remove_master_device()
214 w1_netlink_send(dev, &msg); in __w1_remove_master_device()
216 w1_free_dev(dev); in __w1_remove_master_device()
225 struct w1_master *dev, *found = NULL; in w1_remove_master_device() local
227 list_for_each_entry(dev, &w1_masters, w1_master_entry) { in w1_remove_master_device()
228 if (!dev->initialized) in w1_remove_master_device()
231 if (dev->bus_master->data == bm->data) { in w1_remove_master_device()
232 found = dev; in w1_remove_master_device()