Line discipline problem in new kernels

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

 



I have a linux kernel driver for serial device, which uses line
discipline and char device. Driver works with all old kernels,
starting from 3.8 this driver still works, but when I unload it and
load again to the memory (modprobe -r bpsctl_mod, after modprobe
bpsctl_mod), it crashes the kernel. It can't unregister line
discipline, because this line discipline is busy. I use system device,
i.e., ttyS0. Here is problematic code:

int init_ebtty_module(void) {
filp = filp_open("ttyS0", O_RDWR, 0);
extbp_drv.ebtty_ldisc.magic = TTY_LDISC_MAGIC;
extbp_drv.ebtty_ldisc.name = BP_LDISC_NAME;
extbp_drv.ebtty_ldisc.flags = 0;
extbp_drv.ebtty_ldisc.open = ebtty_open;
extbp_drv.ebtty_ldisc.close = ebtty_close;
extbp_drv.ebtty_ldisc.read = NULL;
extbp_drv.ebtty_ldisc.write = NULL;
extbp_drv.ebtty_ldisc.ioctl = (int (*)(struct tty_struct *, struct
file *, unsigned int, unsigned long)) ebtty_ioctl;
extbp_drv.ebtty_ldisc.poll = NULL;
extbp_drv.ebtty_ldisc.receive_buf = ebtty_receive_buf;
extbp_drv.ebtty_ldisc.write_wakeup = NULL;
status = tty_register_ldisc(extbp_drv.line_disc, &extbp_drv.ebtty_ldisc);
extbp_drv.ebtty_major = register_chrdev(0, extbp_drv.drv_name, &ebtty_fops);
if (fd != NULL) {
bps_vfs_ioctl(fd, TIOCSETD, (unsigned long)&line_disc);
return 0;
}
void exit_ebtty_module(void) {
if (fd) {
filp_close(fd, NULL);
fd = 0;
}
if ((status = tty_unregister_ldisc(extbp_drv.line_disc)) != 0)
err_print(KERN_ERR, DBG_ERROR, ("Can't unregister line discipline (err
= %d)\n", status));

}

Please advice, maybe I should use something else, instead of line
discipline and char device, or maybe I should register and unregister
them other way?
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux