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 memset(dev, 0, sizeof(struct w1_master)); in w1_alloc_dev()
95 kfree(dev); in w1_alloc_dev()
96 dev = NULL; in w1_alloc_dev()
99 return dev; in w1_alloc_dev()
102 static void w1_free_dev(struct w1_master *dev) in w1_free_dev() argument
104 device_unregister(&dev->dev); in w1_free_dev()
113 struct w1_master *dev, *entry; in w1_add_master_device() local
141 dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl, in w1_add_master_device()
143 if (!dev) { in w1_add_master_device()
148 retval = w1_create_master_attributes(dev); in w1_add_master_device()
154 memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); in w1_add_master_device()
156 dev->initialized = 1; in w1_add_master_device()
158 dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); in w1_add_master_device()
159 if (IS_ERR(dev->thread)) { in w1_add_master_device()
160 retval = PTR_ERR(dev->thread); in w1_add_master_device()
161 dev_err(&dev->dev, in w1_add_master_device()
168 list_add(&dev->w1_master_entry, &w1_masters); in w1_add_master_device()
172 msg.id.mst.id = dev->id; in w1_add_master_device()
174 w1_netlink_send(dev, &msg); in w1_add_master_device()
180 set_bit(W1_ABORT_SEARCH, &dev->flags); in w1_add_master_device()
181 kthread_stop(dev->thread); in w1_add_master_device()
184 w1_destroy_master_attributes(dev); in w1_add_master_device()
186 w1_free_dev(dev); in w1_add_master_device()
191 void __w1_remove_master_device(struct w1_master *dev) in __w1_remove_master_device() argument
197 list_del(&dev->w1_master_entry); in __w1_remove_master_device()
200 set_bit(W1_ABORT_SEARCH, &dev->flags); in __w1_remove_master_device()
201 kthread_stop(dev->thread); in __w1_remove_master_device()
203 mutex_lock(&dev->mutex); in __w1_remove_master_device()
204 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
205 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in __w1_remove_master_device()
206 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
208 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
210 w1_destroy_master_attributes(dev); in __w1_remove_master_device()
211 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
212 mutex_unlock(&dev->mutex); in __w1_remove_master_device()
213 atomic_dec(&dev->refcnt); in __w1_remove_master_device()
215 while (atomic_read(&dev->refcnt)) { in __w1_remove_master_device()
216 dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n", in __w1_remove_master_device()
217 dev->name, atomic_read(&dev->refcnt)); in __w1_remove_master_device()
221 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
222 w1_process_callbacks(dev); in __w1_remove_master_device()
223 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
225 mutex_lock(&dev->list_mutex); in __w1_remove_master_device()
226 w1_process_callbacks(dev); in __w1_remove_master_device()
227 mutex_unlock(&dev->list_mutex); in __w1_remove_master_device()
230 msg.id.mst.id = dev->id; in __w1_remove_master_device()
232 w1_netlink_send(dev, &msg); in __w1_remove_master_device()
234 w1_free_dev(dev); in __w1_remove_master_device()
243 struct w1_master *dev, *found = NULL; in w1_remove_master_device() local
245 list_for_each_entry(dev, &w1_masters, w1_master_entry) { in w1_remove_master_device()
246 if (!dev->initialized) in w1_remove_master_device()
249 if (dev->bus_master->data == bm->data) { in w1_remove_master_device()
250 found = dev; in w1_remove_master_device()