Re: [BUG] 2.5.70 tty_register_driver

Paul Fulghum (paulkf@microgate.com)
28 May 2003 14:27:38 -0500


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 <greg@kroah.com>)

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, paulkf@microgate.com
Microgate Corporation, http://www.microgate.com

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/