Lines Matching refs:dev
37 struct atm_dev *dev; in __alloc_atm_dev() local
39 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in __alloc_atm_dev()
40 if (!dev) in __alloc_atm_dev()
42 dev->type = type; in __alloc_atm_dev()
43 dev->signal = ATM_PHY_SIG_UNKNOWN; in __alloc_atm_dev()
44 dev->link_rate = ATM_OC3_PCR; in __alloc_atm_dev()
45 spin_lock_init(&dev->lock); in __alloc_atm_dev()
46 INIT_LIST_HEAD(&dev->local); in __alloc_atm_dev()
47 INIT_LIST_HEAD(&dev->lecs); in __alloc_atm_dev()
49 return dev; in __alloc_atm_dev()
54 struct atm_dev *dev; in __atm_dev_lookup() local
56 list_for_each_entry(dev, &atm_devs, dev_list) { in __atm_dev_lookup()
57 if (dev->number == number) { in __atm_dev_lookup()
58 atm_dev_hold(dev); in __atm_dev_lookup()
59 return dev; in __atm_dev_lookup()
67 struct atm_dev *dev; in atm_dev_lookup() local
70 dev = __atm_dev_lookup(number); in atm_dev_lookup()
72 return dev; in atm_dev_lookup()
80 struct atm_dev *dev, *inuse; in atm_dev_register() local
82 dev = __alloc_atm_dev(type); in atm_dev_register()
83 if (!dev) { in atm_dev_register()
93 kfree(dev); in atm_dev_register()
96 dev->number = number; in atm_dev_register()
98 dev->number = 0; in atm_dev_register()
99 while ((inuse = __atm_dev_lookup(dev->number))) { in atm_dev_register()
101 dev->number++; in atm_dev_register()
105 dev->ops = ops; in atm_dev_register()
107 dev->flags = *flags; in atm_dev_register()
109 memset(&dev->flags, 0, sizeof(dev->flags)); in atm_dev_register()
110 memset(&dev->stats, 0, sizeof(dev->stats)); in atm_dev_register()
111 refcount_set(&dev->refcnt, 1); in atm_dev_register()
113 if (atm_proc_dev_register(dev) < 0) { in atm_dev_register()
118 if (atm_register_sysfs(dev, parent) < 0) { in atm_dev_register()
120 atm_proc_dev_deregister(dev); in atm_dev_register()
124 list_add_tail(&dev->dev_list, &atm_devs); in atm_dev_register()
128 return dev; in atm_dev_register()
131 kfree(dev); in atm_dev_register()
132 dev = NULL; in atm_dev_register()
137 void atm_dev_deregister(struct atm_dev *dev) in atm_dev_deregister() argument
139 BUG_ON(test_bit(ATM_DF_REMOVED, &dev->flags)); in atm_dev_deregister()
140 set_bit(ATM_DF_REMOVED, &dev->flags); in atm_dev_deregister()
148 list_del(&dev->dev_list); in atm_dev_deregister()
151 atm_dev_release_vccs(dev); in atm_dev_deregister()
152 atm_unregister_sysfs(dev); in atm_dev_deregister()
153 atm_proc_dev_deregister(dev); in atm_dev_deregister()
155 atm_dev_put(dev); in atm_dev_deregister()
175 static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats __user *arg, in fetch_stats() argument
181 copy_aal_stats(&dev->stats.aal0, &tmp.aal0); in fetch_stats()
182 copy_aal_stats(&dev->stats.aal34, &tmp.aal34); in fetch_stats()
183 copy_aal_stats(&dev->stats.aal5, &tmp.aal5); in fetch_stats()
187 subtract_aal_stats(&dev->stats.aal0, &tmp.aal0); in fetch_stats()
188 subtract_aal_stats(&dev->stats.aal34, &tmp.aal34); in fetch_stats()
189 subtract_aal_stats(&dev->stats.aal5, &tmp.aal5); in fetch_stats()
197 struct atm_dev *dev; in atm_getnames() local
216 list_for_each_entry(dev, &atm_devs, dev_list) { in atm_getnames()
217 *tmp_p++ = dev->number; in atm_getnames()
231 struct atm_dev *dev; in atm_dev_ioctl() local
236 dev = try_then_request_module(atm_dev_lookup(number), "atm-device-%d", in atm_dev_ioctl()
238 if (!dev) in atm_dev_ioctl()
243 size = strlen(dev->type) + 1; in atm_dev_ioctl()
244 if (copy_to_user(buf, dev->type, size)) { in atm_dev_ioctl()
251 if (copy_to_user(buf, dev->esi, size)) { in atm_dev_ioctl()
261 if (dev->esi[i]) { in atm_dev_ioctl()
279 memcpy(dev->esi, esi, ESI_LEN); in atm_dev_ioctl()
291 error = fetch_stats(dev, buf, cmd == ATM_GETSTATZ); in atm_dev_ioctl()
297 if (copy_to_user(buf, &dev->ci_range, size)) { in atm_dev_ioctl()
304 if (copy_to_user(buf, &dev->link_rate, size)) { in atm_dev_ioctl()
314 atm_reset_addr(dev, ATM_ADDR_LOCAL); in atm_dev_ioctl()
333 error = atm_add_addr(dev, &addr, in atm_dev_ioctl()
337 error = atm_del_addr(dev, &addr, in atm_dev_ioctl()
344 error = atm_get_addr(dev, buf, len, in atm_dev_ioctl()
375 if (!dev->ops->compat_ioctl) { in atm_dev_ioctl()
379 size = dev->ops->compat_ioctl(dev, cmd, buf); in atm_dev_ioctl()
382 if (!dev->ops->ioctl) { in atm_dev_ioctl()
386 size = dev->ops->ioctl(dev, cmd, buf); in atm_dev_ioctl()
399 atm_dev_put(dev); in atm_dev_ioctl()