Messages in this thread | | | Date | Tue, 23 Nov 2010 11:14:16 -0600 | From | Timur Tabi <> | Subject | Re: How do I choose an arbitrary minor number for my tty device? |
| |
Alan Cox wrote: > Your console driver provides a device method (see kernel/printk.c). > When /dev/console is opened the kernel iterates the console list looking > for one with ->device and then calls that method. On success it expects > the passed int * to contain the minor number to use.
Are you talking about this:
static struct tty_driver *ehv_bc_console_device(struct console *co, int *index) { *index = co->index;
return ehv_bc_driver; }
I never really understood this function, but almost everyone does the same thing, and it seems to work for me. Looking at console_device(), it appears that all of the xxx_console_device functions are called in order until one of them returns non-NULL.
How is this related to add_preferred_console()? When I call this function, I also specify the same index and the name from the struct console device:
static struct console ehv_bc_console = { .name = "ttyEHV", .write = ehv_bc_console_write, .device = ehv_bc_console_device, .flags = CON_PRINTBUFFER | CON_ENABLED, };
add_preferred_console(ehv_bc_console.name, ehv_bc_console.index, NULL); register_console(&ehv_bc_console);
> I suspect in your case you probably want to attach the primary byte > channel to minor 0 in the driver (and reserve it for that), or some > similar rule.
Yes, that's a good idea. It does simplify things a lot.
-- Timur Tabi Linux kernel developer at Freescale
| |