Lines Matching +full:dynamic +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
14 * Made things a lot mode modular - easy to compile in just one or two
17 * Support for loadable modules. 8-Sep-95 Philip Blundell <pjb27@cam.ac.uk>
20 * Alan Cox <alan@lxorguk.ukuu.org.uk> 21-Jan-96
22 * Dynamic minors and /proc/mice by Alessandro Rubini. 26-Mar-96
24 * Renamed to misc and miscdevice to be more accurate. Alan Cox 26-Mar-96
34 * Added devfs support. Richard Gooch <rgooch@atnf.csiro.au> 10-Jan-1998
61 * Assigned numbers, used for dynamic minors
63 #define DYNAMIC_MINORS 128 /* like dynamic majors */
70 ret = ida_alloc_max(&misc_minors_ida, DYNAMIC_MINORS - 1, GFP_KERNEL); in misc_minor_alloc()
72 ret = DYNAMIC_MINORS - ret - 1; in misc_minor_alloc()
83 ida_free(&misc_minors_ida, DYNAMIC_MINORS - minor - 1); in misc_minor_free()
109 seq_printf(seq, "%3i %s\n", p->minor, p->name ? p->name : ""); in misc_seq_show()
126 int err = -ENODEV; in misc_open()
132 if (iter->minor != minor) in misc_open()
135 new_fops = fops_get(iter->fops); in misc_open()
141 request_module("char-major-%d-%d", MISC_MAJOR, minor); in misc_open()
145 if (iter->minor != minor) in misc_open()
148 new_fops = fops_get(iter->fops); in misc_open()
158 * file operations, including f_op->open below in misc_open()
160 file->private_data = c; in misc_open()
164 if (file->f_op->open) in misc_open()
165 err = file->f_op->open(inode, file); in misc_open()
171 static char *misc_devnode(const struct device *dev, umode_t *mode) in misc_devnode() argument
175 if (mode && c->mode) in misc_devnode()
176 *mode = c->mode; in misc_devnode()
177 if (c->nodename) in misc_devnode()
178 return kstrdup(c->nodename, GFP_KERNEL); in misc_devnode()
194 * misc_register - register a miscellaneous device
204 * syscall to the device sets file->private_data to point to the
215 bool is_dynamic = (misc->minor == MISC_DYNAMIC_MINOR); in misc_register()
217 INIT_LIST_HEAD(&misc->list); in misc_register()
225 err = -EBUSY; in misc_register()
228 misc->minor = i; in misc_register()
233 if (c->minor == misc->minor) { in misc_register()
234 err = -EBUSY; in misc_register()
240 dev = MKDEV(MISC_MAJOR, misc->minor); in misc_register()
242 misc->this_device = in misc_register()
243 device_create_with_groups(&misc_class, misc->parent, dev, in misc_register()
244 misc, misc->groups, "%s", misc->name); in misc_register()
245 if (IS_ERR(misc->this_device)) { in misc_register()
247 misc_minor_free(misc->minor); in misc_register()
248 misc->minor = MISC_DYNAMIC_MINOR; in misc_register()
250 err = PTR_ERR(misc->this_device); in misc_register()
258 list_add(&misc->list, &misc_list); in misc_register()
266 * misc_deregister - unregister a miscellaneous device
275 if (WARN_ON(list_empty(&misc->list))) in misc_deregister()
279 list_del(&misc->list); in misc_deregister()
280 device_destroy(&misc_class, MKDEV(MISC_MAJOR, misc->minor)); in misc_deregister()
281 misc_minor_free(misc->minor); in misc_deregister()
296 err = -EIO; in misc_init()