Lines Matching full:unit

56 	struct xilly_unit *unit, *u;  in xillybus_init_chrdev()  local
58 unit = kzalloc(sizeof(*unit), GFP_KERNEL); in xillybus_init_chrdev()
60 if (!unit) in xillybus_init_chrdev()
66 snprintf(unit->name, UNITNAMELEN, "%s", prefix); in xillybus_init_chrdev()
69 snprintf(unit->name, UNITNAMELEN, "%s_%02d", in xillybus_init_chrdev()
74 if (!strcmp(unit->name, u->name)) { in xillybus_init_chrdev()
80 rc = alloc_chrdev_region(&mdev, 0, num_nodes, unit->name); in xillybus_init_chrdev()
87 unit->major = MAJOR(mdev); in xillybus_init_chrdev()
88 unit->lowest_minor = MINOR(mdev); in xillybus_init_chrdev()
89 unit->num_nodes = num_nodes; in xillybus_init_chrdev()
90 unit->private_data = private_data; in xillybus_init_chrdev()
92 unit->cdev = cdev_alloc(); in xillybus_init_chrdev()
93 if (!unit->cdev) { in xillybus_init_chrdev()
97 unit->cdev->ops = fops; in xillybus_init_chrdev()
98 unit->cdev->owner = owner; in xillybus_init_chrdev()
100 rc = cdev_add(unit->cdev, MKDEV(unit->major, unit->lowest_minor), in xillybus_init_chrdev()
101 unit->num_nodes); in xillybus_init_chrdev()
105 kobject_put(&unit->cdev->kobj); in xillybus_init_chrdev()
119 unit->name, idt); in xillybus_init_chrdev()
126 MKDEV(unit->major, in xillybus_init_chrdev()
127 i + unit->lowest_minor), in xillybus_init_chrdev()
145 list_add_tail(&unit->list_entry, &unit_list); in xillybus_init_chrdev()
155 device_destroy(xillybus_class, MKDEV(unit->major, in xillybus_init_chrdev()
156 i + unit->lowest_minor)); in xillybus_init_chrdev()
158 cdev_del(unit->cdev); in xillybus_init_chrdev()
161 unregister_chrdev_region(MKDEV(unit->major, unit->lowest_minor), in xillybus_init_chrdev()
162 unit->num_nodes); in xillybus_init_chrdev()
167 kfree(unit); in xillybus_init_chrdev()
177 struct xilly_unit *unit = NULL, *iter; in xillybus_cleanup_chrdev() local
183 unit = iter; in xillybus_cleanup_chrdev()
187 if (!unit) { in xillybus_cleanup_chrdev()
188 dev_err(dev, "Weird bug: Failed to find unit\n"); in xillybus_cleanup_chrdev()
193 for (minor = unit->lowest_minor; in xillybus_cleanup_chrdev()
194 minor < (unit->lowest_minor + unit->num_nodes); in xillybus_cleanup_chrdev()
196 device_destroy(xillybus_class, MKDEV(unit->major, minor)); in xillybus_cleanup_chrdev()
198 cdev_del(unit->cdev); in xillybus_cleanup_chrdev()
200 unregister_chrdev_region(MKDEV(unit->major, unit->lowest_minor), in xillybus_cleanup_chrdev()
201 unit->num_nodes); in xillybus_cleanup_chrdev()
204 unit->num_nodes); in xillybus_cleanup_chrdev()
206 list_del(&unit->list_entry); in xillybus_cleanup_chrdev()
207 kfree(unit); in xillybus_cleanup_chrdev()
218 struct xilly_unit *unit = NULL, *iter; in xillybus_find_inode() local
226 unit = iter; in xillybus_find_inode()
232 if (!unit) in xillybus_find_inode()
235 *private_data = unit->private_data; in xillybus_find_inode()
236 *index = minor - unit->lowest_minor; in xillybus_find_inode()