2005-01-27 13:46:47

by Olaf Hering

[permalink] [raw]
Subject: [PATCH] use misc dynamic minor for sonypi driver


Whats the reason for using -1 as minor number?
No idea if that works well, it probably does.
Maybe add a comment if -1 is supposed to work.


--- ../linux-2.6.11-rc2/drivers/char/sonypi.c 2005-01-22 02:48:34.000000000 +0100
+++ ./drivers/char/sonypi.c 2005-01-27 14:40:47.873882682 +0100
@@ -649,7 +649,7 @@
};

struct miscdevice sonypi_misc_device = {
- .minor = -1,
+ .minor = MISC_DYNAMIC_MINOR,
.name = "sonypi",
.fops = &sonypi_misc_fops,
};


2005-01-27 14:01:27

by Stelian Pop

[permalink] [raw]
Subject: Re: [PATCH] use misc dynamic minor for sonypi driver

On Thu, Jan 27, 2005 at 02:46:40PM +0100, Olaf Hering wrote:

>
> Whats the reason for using -1 as minor number?
> No idea if that works well, it probably does.
> Maybe add a comment if -1 is supposed to work.
>
>
> --- ../linux-2.6.11-rc2/drivers/char/sonypi.c 2005-01-22 02:48:34.000000000 +0100
> +++ ./drivers/char/sonypi.c 2005-01-27 14:40:47.873882682 +0100
> @@ -649,7 +649,7 @@
> };
>
> struct miscdevice sonypi_misc_device = {
> - .minor = -1,
> + .minor = MISC_DYNAMIC_MINOR,
> .name = "sonypi",
> .fops = &sonypi_misc_fops,
> };

It works because sonypi_misc_device.minor get overridden later:

662 sonypi_misc_device.minor = (minor == -1) ?
663 MISC_DYNAMIC_MINOR : minor;

This test could be simplified too in addition to your patch.

Stelian.
--
Stelian Pop <[email protected]>