Skip to content

Commit

Permalink
TTY: remove re-assignments to tty_driver members
Browse files Browse the repository at this point in the history
All num, magic and owner are set by alloc_tty_driver. No need to
re-set them on each allocation site.

pti driver sets something different to what it passes to
alloc_tty_driver. It is not a bug, since we don't use the lines
parameter in any way. Anyway this is fixed, and now we do the right
thing.

Signed-off-by: Jiri Slaby <[email protected]>
Acked-by: Tilman Schmidt <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jiri Slaby authored and gregkh committed Mar 8, 2012
1 parent 87cab16 commit 2f16669
Show file tree
Hide file tree
Showing 41 changed files with 3 additions and 59 deletions.
1 change: 0 additions & 1 deletion arch/ia64/hp/sim/simserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,6 @@ simrs_init (void)

/* Initialize the tty_driver structure */

hp_simserial_driver->owner = THIS_MODULE;
hp_simserial_driver->driver_name = "simserial";
hp_simserial_driver->name = "ttyS";
hp_simserial_driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion arch/m68k/emu/nfcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ static int __init nfcon_init(void)
if (!nfcon_tty_driver)
return -ENOMEM;

nfcon_tty_driver->owner = THIS_MODULE;
nfcon_tty_driver->driver_name = "nfcon";
nfcon_tty_driver->name = "nfcon";
nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
Expand Down
1 change: 0 additions & 1 deletion arch/xtensa/platforms/iss/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ int __init rs_init(void)

/* Initialize the tty_driver structure */

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = "iss_serial";
serial_driver->name = "ttyS";
serial_driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,6 @@ static int __init synclink_cs_init(void)

/* Initialize the tty_driver structure */

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = "synclink_cs";
serial_driver->name = "ttySLP";
serial_driver->major = ttymajor;
Expand Down
2 changes: 0 additions & 2 deletions drivers/char/ttyprintk.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,10 @@ static int __init ttyprintk_init(void)
if (!ttyprintk_driver)
return ret;

ttyprintk_driver->owner = THIS_MODULE;
ttyprintk_driver->driver_name = "ttyprintk";
ttyprintk_driver->name = "ttyprintk";
ttyprintk_driver->major = TTYAUX_MAJOR;
ttyprintk_driver->minor_start = 3;
ttyprintk_driver->num = 1;
ttyprintk_driver->type = TTY_DRIVER_TYPE_CONSOLE;
ttyprintk_driver->init_termios = tty_std_termios;
ttyprintk_driver->init_termios.c_oflag = OPOST | OCRNL | ONOCR | ONLRET;
Expand Down
1 change: 0 additions & 1 deletion drivers/isdn/capi/capi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,6 @@ static int __init capinc_tty_init(void)
kfree(capiminors);
return -ENOMEM;
}
drv->owner = THIS_MODULE;
drv->driver_name = "capi_nc";
drv->name = "capi";
drv->major = 0;
Expand Down
7 changes: 1 addition & 6 deletions drivers/isdn/gigaset/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,27 +669,22 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
const char *devname)
{
unsigned minors = drv->minors;
int ret;
struct tty_driver *tty;

drv->have_tty = 0;

drv->tty = tty = alloc_tty_driver(minors);
drv->tty = tty = alloc_tty_driver(drv->minors);
if (tty == NULL)
goto enomem;

tty->magic = TTY_DRIVER_MAGIC,
tty->type = TTY_DRIVER_TYPE_SERIAL,
tty->subtype = SERIAL_TYPE_NORMAL,
tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;

tty->driver_name = procname;
tty->name = devname;
tty->minor_start = drv->minor;
tty->num = drv->minors;

tty->owner = THIS_MODULE;

tty->init_termios = tty_std_termios;
tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
Expand Down
5 changes: 1 addition & 4 deletions drivers/misc/pti.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,20 +907,17 @@ static int __init pti_init(void)

/* First register module as tty device */

pti_tty_driver = alloc_tty_driver(1);
pti_tty_driver = alloc_tty_driver(PTITTY_MINOR_NUM);
if (pti_tty_driver == NULL) {
pr_err("%s(%d): Memory allocation failed for ptiTTY driver\n",
__func__, __LINE__);
return -ENOMEM;
}

pti_tty_driver->owner = THIS_MODULE;
pti_tty_driver->magic = TTY_DRIVER_MAGIC;
pti_tty_driver->driver_name = DRIVERNAME;
pti_tty_driver->name = TTYNAME;
pti_tty_driver->major = 0;
pti_tty_driver->minor_start = PTITTY_MINOR_START;
pti_tty_driver->num = PTITTY_MINOR_NUM;
pti_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
pti_tty_driver->subtype = SYSTEM_TYPE_SYSCONS;
pti_tty_driver->flags = TTY_DRIVER_REAL_RAW |
Expand Down
1 change: 0 additions & 1 deletion drivers/mmc/card/sdio_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,6 @@ static int __init sdio_uart_init(void)
if (!tty_drv)
return -ENOMEM;

tty_drv->owner = THIS_MODULE;
tty_drv->driver_name = "sdio_uart";
tty_drv->name = "ttySDIO";
tty_drv->major = 0; /* dynamically allocated */
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,6 @@ static int __init hso_init(void)

/* fill in all needed values */
tty_drv->magic = TTY_DRIVER_MAGIC;
tty_drv->owner = THIS_MODULE;
tty_drv->driver_name = driver_name;
tty_drv->name = tty_filename;

Expand All @@ -3322,7 +3321,6 @@ static int __init hso_init(void)
tty_drv->major = tty_major;

tty_drv->minor_start = 0;
tty_drv->num = HSO_SERIAL_TTY_MINORS;
tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
tty_drv->subtype = SERIAL_TYPE_NORMAL;
tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/char/con3215.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,6 @@ static int __init tty3215_init(void)
* proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
*/

driver->owner = THIS_MODULE;
driver->driver_name = "tty3215";
driver->name = "ttyS";
driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/char/sclp_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ sclp_tty_init(void)
return rc;
}

driver->owner = THIS_MODULE;
driver->driver_name = "sclp_line";
driver->name = "sclp_line";
driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/char/sclp_vt220.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ static int __init sclp_vt220_tty_init(void)
if (rc)
goto out_driver;

driver->owner = THIS_MODULE;
driver->driver_name = SCLP_VT220_DRIVER_NAME;
driver->name = SCLP_VT220_DEVICE_NAME;
driver->major = SCLP_VT220_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/s390/char/tty3270.c
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,6 @@ static int __init tty3270_init(void)
* Entries in tty3270_driver that are NOT initialized:
* proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
*/
driver->owner = THIS_MODULE;
driver->driver_name = "ttyTUB";
driver->name = "ttyTUB";
driver->major = IBM_TTY3270_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)

/* Initialize the tty_driver structure */

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = "amiserial";
serial_driver->name = "ttyS";
serial_driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/bfin_jtag_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ static int __init bfin_jc_init(void)
if (!bfin_jc_driver)
goto err_driver;

bfin_jc_driver->owner = THIS_MODULE;
bfin_jc_driver->driver_name = DRV_NAME;
bfin_jc_driver->name = DEV_NAME;
bfin_jc_driver->type = TTY_DRIVER_TYPE_SERIAL;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/cyclades.c
Original file line number Diff line number Diff line change
Expand Up @@ -4090,7 +4090,6 @@ static int __init cy_init(void)

/* Initialize the tty_driver structure */

cy_serial_driver->owner = THIS_MODULE;
cy_serial_driver->driver_name = "cyclades";
cy_serial_driver->name = "ttyC";
cy_serial_driver->major = CYCLADES_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/ehv_bytechan.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ static int __init ehv_bc_init(void)
goto error;
}

ehv_bc_driver->owner = THIS_MODULE;
ehv_bc_driver->driver_name = "ehv-bc";
ehv_bc_driver->name = ehv_bc_console.name;
ehv_bc_driver->type = TTY_DRIVER_TYPE_CONSOLE;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/hvc/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ static int hvc_init(void)
goto out;
}

drv->owner = THIS_MODULE;
drv->driver_name = "hvc";
drv->name = "hvc";
drv->major = HVC_MAJOR;
Expand Down
2 changes: 0 additions & 2 deletions drivers/tty/hvc/hvcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,6 @@ static int __devinit hvcs_initialize(void)
goto index_fail;
}

hvcs_tty_driver->owner = THIS_MODULE;

hvcs_tty_driver->driver_name = hvcs_driver_name;
hvcs_tty_driver->name = hvcs_device_node;

Expand Down
1 change: 0 additions & 1 deletion drivers/tty/hvc/hvsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,6 @@ static int __init hvsi_init(void)
if (!hvsi_driver)
return -ENOMEM;

hvsi_driver->owner = THIS_MODULE;
hvsi_driver->driver_name = "hvsi";
hvsi_driver->name = "hvsi";
hvsi_driver->major = HVSI_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/ipwireless/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ int ipwireless_tty_init(void)
if (!ipw_tty_driver)
return -ENOMEM;

ipw_tty_driver->owner = THIS_MODULE;
ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME;
ipw_tty_driver->name = "ttyIPWp";
ipw_tty_driver->major = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/isicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,6 @@ static int __init isicom_init(void)
goto error;
}

isicom_normal->owner = THIS_MODULE;
isicom_normal->name = "ttyM";
isicom_normal->major = ISICOM_NMAJOR;
isicom_normal->minor_start = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,6 @@ static int __init moxa_init(void)
if (!moxaDriver)
return -ENOMEM;

moxaDriver->owner = THIS_MODULE;
moxaDriver->name = "ttyMX";
moxaDriver->major = ttymajor;
moxaDriver->minor_start = 0;
Expand Down
3 changes: 0 additions & 3 deletions drivers/tty/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2658,12 +2658,9 @@ static int __init mxser_module_init(void)
MXSER_VERSION);

/* Initialize the tty_driver structure */
mxvar_sdriver->owner = THIS_MODULE;
mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
mxvar_sdriver->name = "ttyMI";
mxvar_sdriver->major = ttymajor;
mxvar_sdriver->minor_start = 0;
mxvar_sdriver->num = MXSER_PORTS + 1;
mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;
mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
mxvar_sdriver->init_termios = tty_std_termios;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/n_gsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,6 @@ static int __init gsm_init(void)
pr_err("gsm_init: tty allocation failed.\n");
return -EINVAL;
}
gsm_tty_driver->owner = THIS_MODULE;
gsm_tty_driver->driver_name = "gsmtty";
gsm_tty_driver->name = "gsmtty";
gsm_tty_driver->major = 0; /* Dynamic */
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/nozomi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,6 @@ static __init int nozomi_init(void)
if (!ntty_driver)
return -ENOMEM;

ntty_driver->owner = THIS_MODULE;
ntty_driver->driver_name = NOZOMI_NAME_TTY;
ntty_driver->name = "noz";
ntty_driver->major = 0;
Expand Down
4 changes: 0 additions & 4 deletions drivers/tty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ static void __init legacy_pty_init(void)
if (!pty_slave_driver)
panic("Couldn't allocate pty slave driver");

pty_driver->owner = THIS_MODULE;
pty_driver->driver_name = "pty_master";
pty_driver->name = "pty";
pty_driver->major = PTY_MASTER_MAJOR;
Expand All @@ -411,7 +410,6 @@ static void __init legacy_pty_init(void)
pty_driver->other = pty_slave_driver;
tty_set_operations(pty_driver, &master_pty_ops_bsd);

pty_slave_driver->owner = THIS_MODULE;
pty_slave_driver->driver_name = "pty_slave";
pty_slave_driver->name = "ttyp";
pty_slave_driver->major = PTY_SLAVE_MAJOR;
Expand Down Expand Up @@ -671,7 +669,6 @@ static void __init unix98_pty_init(void)
if (!pts_driver)
panic("Couldn't allocate Unix98 pts driver");

ptm_driver->owner = THIS_MODULE;
ptm_driver->driver_name = "pty_master";
ptm_driver->name = "ptm";
ptm_driver->major = UNIX98_PTY_MASTER_MAJOR;
Expand All @@ -690,7 +687,6 @@ static void __init unix98_pty_init(void)
ptm_driver->other = pts_driver;
tty_set_operations(ptm_driver, &ptm_unix98_ops);

pts_driver->owner = THIS_MODULE;
pts_driver->driver_name = "pty_slave";
pts_driver->name = "pts";
pts_driver->major = UNIX98_PTY_SLAVE_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/rocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,7 +2277,6 @@ static int __init rp_init(void)
* driver with the tty layer.
*/

rocket_driver->owner = THIS_MODULE;
rocket_driver->flags = TTY_DRIVER_DYNAMIC_DEV;
rocket_driver->name = "ttyR";
rocket_driver->driver_name = "Comtrol RocketPort";
Expand Down
3 changes: 0 additions & 3 deletions drivers/tty/serial/ifx6x60.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,12 +1375,9 @@ static int __init ifx_spi_init(void)
return -ENOMEM;
}

tty_drv->magic = TTY_DRIVER_MAGIC;
tty_drv->owner = THIS_MODULE;
tty_drv->driver_name = DRVNAME;
tty_drv->name = TTYNAME;
tty_drv->minor_start = IFX_SPI_TTY_ID;
tty_drv->num = 1;
tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
tty_drv->subtype = SERIAL_TYPE_NORMAL;
tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/serial/msm_smd_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ static int __init smd_tty_init(void)
if (smd_tty_driver == 0)
return -ENOMEM;

smd_tty_driver->owner = THIS_MODULE;
smd_tty_driver->driver_name = "smd_tty_driver";
smd_tty_driver->name = "smd";
smd_tty_driver->major = 0;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/serial/serial_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,6 @@ int uart_register_driver(struct uart_driver *drv)

drv->tty_driver = normal;

normal->owner = drv->owner;
normal->driver_name = drv->driver_name;
normal->name = drv->dev_name;
normal->major = drv->major;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/synclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -4333,7 +4333,6 @@ static int mgsl_init_tty(void)
if (!serial_driver)
return -ENOMEM;

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = "synclink";
serial_driver->name = "ttySL";
serial_driver->major = ttymajor;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/synclink_gt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3795,7 +3795,6 @@ static int __init slgt_init(void)

/* Initialize the tty_driver structure */

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = tty_driver_name;
serial_driver->name = tty_dev_prefix;
serial_driver->major = ttymajor;
Expand Down
1 change: 0 additions & 1 deletion drivers/tty/synclinkmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3977,7 +3977,6 @@ static int __init synclinkmp_init(void)

/* Initialize the tty_driver structure */

serial_driver->owner = THIS_MODULE;
serial_driver->driver_name = "synclinkmp";
serial_driver->name = "ttySLM";
serial_driver->major = ttymajor;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/vt/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,7 @@ int __init vty_init(const struct file_operations *console_fops)
console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
if (!console_driver)
panic("Couldn't allocate console driver\n");
console_driver->owner = THIS_MODULE;

console_driver->name = "tty";
console_driver->name_base = 1;
console_driver->major = TTY_MAJOR;
Expand Down
1 change: 0 additions & 1 deletion drivers/usb/class/cdc-acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,6 @@ static int __init acm_init(void)
acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
if (!acm_tty_driver)
return -ENOMEM;
acm_tty_driver->owner = THIS_MODULE,
acm_tty_driver->driver_name = "acm",
acm_tty_driver->name = "ttyACM",
acm_tty_driver->major = ACM_TTY_MAJOR,
Expand Down
1 change: 0 additions & 1 deletion drivers/usb/gadget/u_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,6 @@ int __init gserial_setup(struct usb_gadget *g, unsigned count)
if (!gs_tty_driver)
return -ENOMEM;

gs_tty_driver->owner = THIS_MODULE;
gs_tty_driver->driver_name = "g_serial";
gs_tty_driver->name = PREFIX;
/* uses dynamically assigned dev_t values */
Expand Down
1 change: 0 additions & 1 deletion drivers/usb/serial/usb-serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,6 @@ static int __init usb_serial_init(void)
goto exit_bus;
}

usb_serial_tty_driver->owner = THIS_MODULE;
usb_serial_tty_driver->driver_name = "usbserial";
usb_serial_tty_driver->name = "ttyUSB";
usb_serial_tty_driver->major = SERIAL_TTY_MAJOR;
Expand Down
Loading

0 comments on commit 2f16669

Please sign in to comment.