lkml.org 
[lkml]   [2010]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: 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



    \
     
     \ /
      Last update: 2010-11-23 18:19    [W:0.023 / U:1.480 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site