Re: platform device , uevent file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 9, 2009 at 9:45 PM, Greg KH <greg@xxxxxxxxx> wrote:
> On Mon, Feb 09, 2009 at 09:23:47PM +0200, Daniel Baluta wrote:
>> On Mon, Feb 9, 2009 at 7:56 PM, Daniel Baluta <daniel.baluta@xxxxxxxxx> wrote:
>> > On Mon, Feb 9, 2009 at 7:19 PM, Greg KH <greg@xxxxxxxxx> wrote:
>> >> On Mon, Feb 09, 2009 at 06:43:51PM +0200, Daniel Baluta wrote:
>> >>> On Mon, Feb 9, 2009 at 12:20 AM, Greg KH <greg@xxxxxxxxx> wrote:
>> >>> > On Sun, Feb 08, 2009 at 07:47:05PM +0200, Daniel Baluta wrote:
>> >>> >> Hello,
>> >>> >>
>> >>> >> I don't really understand how kernel generates events when working
>> >>> >> with platform devices and drivers ( [1] ).
>> >>> >> I have registered my driver with platform_driver_register and my
>> >>> >> device with platform_device_register_simple.
>> >>> >>
>> >>> >> I want to dynamically create the node in /dev , and for that i need
>> >>> >> the kernel to send events like ( MAJOR=x, MINOR=y)
>> >>> >> that will be interpreted by the udev daemon acording to rules from
>> >>> >> /etc/udev/rules.d.
>> >>> >
>> >>> > Platform devices can't do this, you need to use a "real" struct device,
>> >>> > or register with a class that handles major/minor allocation for you
>> >>> > (input, block, etc.)
>> >>> >
>> >>> > hope this helps,
>> >>> >
>> >>> > greg k-h
>> >>> >
>> >>>
>> >>> thanks for your answer.
>> >>>
>> >>> I'm writing a driver for a character device [hex display] .
>> >>>
>> >>> Registering with an existing class its pretty hard since it doesn't
>> >>> fit well in none of the existing classes.
>> >>
>> >> There are other drivers in the kernel that already do something like
>> >> this, are you sure there isn't an existing class for you already?
>> >>
>> >
>> > I'm still searching for it. Any suggestion , it's welcomed.
>
> I know one staging driver supports it, and I think a few different USB
> ones do as well.  Have you looked at the LED class?  That might be what
> I was thinking of.
>
>> >>> One good option would be misc class but this enforces the usage of major 10.
>> >>
>> >> What's wrong with that?  It's a dynamic minor number that will "just
>> >> work" for your device.
>> >>
>> > Yes , you are right here it's "just working". But I have some requirements
>> > that ask for major to be dynamically allocated.
>
> What kind of requirement would require something like that?  Do you
> really need to support 16k different devices?  Hm, even with that kind
> of requirement, the misc interface would still work just fine.
>
> Have a pointer to your code anywhere?
>
> thanks,
>
> greg k-h
>

Hello ,

Led class seems to be a very good idea.

You can find below a snippet of my reworked code:


static struct led_classdev hex_classdev = {
    .name           = "hexclass",
};

static int my_probe(struct platform_device *pdev)
{
    int ret;

    ret = led_classdev_register(&pdev->dev, &hex_classdev);
    if (ret < 0)
        return ret;
    printk("led_classdev_register called in probe!\n");
    return ret;
}

static int my_remove(struct platform_device *pdev)
{
    led_classdev_unregister(&hex_classdev);
    printk("led_clasdev_unregister called in remove\n");

    return 0;
}


static struct platform_driver my_driver = {
    .probe      = my_probe,
    .remove     = my_remove,
    .driver     = {
        .name       = "led",
        .owner      = THIS_MODULE,
    },
};

static struct platform_device *my_device;
static int __init my_init(void)
{

    my_device = platform_device_register_simple("led", -1 , NULL, 0);

    return platform_driver_register(&my_driver);
}

static void __exit my_exit(void)
{

    platform_device_unregister(my_device);
    platform_driver_unregister(&my_driver);
}


The idea is that i want to dynamically create /dev/hexd in order to
write to my hexdisplay.
So i need to send an event like MAJOR=x, MINOR=y to udev and this
should do mknod /dev/hexd c MAJOR MINOR.

 I've noticed that for example , for printer class there is a file
/sys/class/printer/lp0/dev that contains MAJOR:MINOR.

When i run my code there is no  /sys/class/leds/hexclass/dev file created.
Could this be the problem? Is there any special function that must be called.


Thanks,
Daniel.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux