2003-05-28 15:56:11

by Paul Fulghum

[permalink] [raw]
Subject: [BUG] 2.5.70 tty_register_driver


There was a large patch applied in 2.5.70 to
the tty layer that has broken registration of tty
devices.

The tty drivers I maintain get a success return
value from tty_register_driver() and dynamic
major/minor device numbers are assigned, but
it does not appear to actually create the
char devices. (They do not show up in proc/devices).

I'm trying to dig through this and understand the
purpose of the changes, but it might be
more informative if the person responsible for the
patch would explain the purpose and what modification
of tty drivers are necessary to work with the changes.

--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com



2003-05-28 19:14:18

by Paul Fulghum

[permalink] [raw]
Subject: Re: [BUG] 2.5.70 tty_register_driver

On Wed, 2003-05-28 at 11:09, Paul Fulghum wrote:
> There was a large patch applied in 2.5.70 to
> the tty layer that has broken registration of tty
> devices.

Below is the broken code that was added in 2.5.70
to the tty_register_driver() function in drivers/char/tty_io.c
(apparently submitted by Greg Kroah-Hartman <[email protected]>)

If a tty device uses dynamic major device numbers
(driver->major set to zero), then the new code fails
to honor the driver->minor_start value. Previously
the driver->minor_start specified the starting device
minor number for all calls to tty_register_driver()
regardless of if major is dynamically allocated or
staticly specified.

The result is the device minor numbers change for
dynamically assigned major device numbers resulting
in a loss of compatibility.

tty_register_driver() should be fixed
(along with alloc_chrdev_region) to once again honor
the base minor number.

if (!driver->major) {
- error = register_chrdev_region(0, driver->minor_start,
- driver->num, driver->name, &tty_fops);
- if (error > 0)
- driver->major = error;
+ error = alloc_chrdev_region(&dev, driver->num,
+ (char*)driver->name);
+ if (!error) {
+ driver->major = MAJOR(dev);
+ driver->minor_start = MINOR(dev);
+ }
} else {
- error = get_range(driver);
+ dev = MKDEV(driver->major, driver->minor_start);
+ error = register_chrdev_region(dev, driver->num,
+ (char*)driver->name);
}


--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com


2003-05-29 14:14:05

by Paul Fulghum

[permalink] [raw]
Subject: [PATCH] 2.5.70 tty_register_driver

This patch corrects changes made in 2.5.70 to
tty_register_device() which caused the device
minor base specified by tty drivers using dynamically
allocated device major number to be ignored.

I have posted to lkml and to the originator of the
2.5.70 patch, and have received no dissenting views.

Please apply.

--- linux-2.5.70/drivers/char/tty_io.c 2003-05-29 09:14:30.000000000 -0500
+++ linux-2.5.70-mg/drivers/char/tty_io.c 2003-05-29 08:24:41.000000000 -0500
@@ -2255,7 +2255,7 @@
return 0;

if (!driver->major) {
- error = alloc_chrdev_region(&dev, driver->num,
+ error = alloc_chrdev_region(&dev, driver->minor_start, driver->num,
(char*)driver->name);
if (!error) {
driver->major = MAJOR(dev);
--- linux-2.5.70/include/linux/fs.h 2003-05-29 09:14:01.000000000 -0500
+++ linux-2.5.70-mg/include/linux/fs.h 2003-05-29 08:23:46.000000000 -0500
@@ -1059,7 +1059,7 @@
extern void blk_run_queues(void);

/* fs/char_dev.c */
-extern int alloc_chrdev_region(dev_t *, unsigned, char *);
+extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, char *);
extern int register_chrdev_region(dev_t, unsigned, char *);
extern int register_chrdev(unsigned int, const char *,
struct file_operations *);
--- linux-2.5.70/fs/char_dev.c 2003-05-29 09:14:18.000000000 -0500
+++ linux-2.5.70-mg/fs/char_dev.c 2003-05-29 08:24:25.000000000 -0500
@@ -177,10 +177,10 @@
return PTR_ERR(cd);
}

-int alloc_chrdev_region(dev_t *dev, unsigned count, char *name)
+int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, char *name)
{
struct char_device_struct *cd;
- cd = __register_chrdev_region(0, 0, count, name);
+ cd = __register_chrdev_region(0, baseminor, count, name);
if (IS_ERR(cd))
return PTR_ERR(cd);
*dev = MKDEV(cd->major, cd->baseminor);




--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com


2003-05-29 16:41:05

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] 2.5.70 tty_register_driver

On Thu, May 29, 2003 at 09:27:28AM -0500, Paul Fulghum wrote:
> This patch corrects changes made in 2.5.70 to
> tty_register_device() which caused the device
> minor base specified by tty drivers using dynamically
> allocated device major number to be ignored.
>
> I have posted to lkml and to the originator of the
> 2.5.70 patch, and have received no dissenting views.

Hm, I wasn't the originator of the 2.5.70 change in this area, that's Al
Viro. I suggest you run this by him first.

thanks,

greg k-h

2003-05-29 17:13:55

by Paul Fulghum

[permalink] [raw]
Subject: Re: [PATCH] 2.5.70 tty_register_driver

On Thu, 2003-05-29 at 11:56, Greg KH wrote:
> On Thu, May 29, 2003 at 09:27:28AM -0500, Paul Fulghum wrote:
> > I have posted to lkml and to the originator of the
> > 2.5.70 patch, and have received no dissenting views.
>
> Hm, I wasn't the originator of the 2.5.70 change in this area, that's Al
> Viro. I suggest you run this by him first.
>
> thanks,
>
> greg k-h

Sorry, in the 2.5.70 announcement by Linus, I saw some
tty changes listed under your name.

It does look like Al Viro is responsible for
the changes in question.

--
Paul Fulghum, [email protected]
Microgate Corporation, http://www.microgate.com