Skip to content

Commit

Permalink
Fixed compilation and some runtime issues on kernel 5.16
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-vitek committed Mar 2, 2022
1 parent 7091aa2 commit 97d4bc0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ module_exit(triple_exit);
/* driver layer - (2) TTY line discipline */
static int triple_open (struct tty_struct *tty);
static void triple_close (struct tty_struct *tty);
static int triple_hangup(struct tty_struct *tty);
static void triple_hangup(struct tty_struct *tty);
static int triple_ioctl (struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
static void triple_receive_buf (struct tty_struct *tty, const unsigned char *cp, char *fp, int count);
static void triple_receive_buf (struct tty_struct *tty, const unsigned char *cp, const char *fp, int count);
static void triple_write_wakeup(struct tty_struct *tty);

static struct tty_ldisc_ops triple_ldisc =
{
.owner = THIS_MODULE,
.magic = TTY_LDISC_MAGIC,
.num = N_TRIPLE,
.name = "triplecan",
.open = triple_open,
.close = triple_close,
Expand Down Expand Up @@ -118,7 +118,7 @@ static void triple_setup(struct net_device *dev);
static void triple_fd_setup(struct net_device *dev);
static void triple_free_netdev(struct net_device *dev);

void print_func_trace (bool is_trace, int line, const char *func);
void print_func_trace(bool is_trace, int line, const char *func);

static int __init triple_init (void)
{
Expand All @@ -134,13 +134,13 @@ static int __init triple_init (void)
printk(banner);
printk(KERN_ERR "triple: %d interface channels.\n", maxdev);

triple_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL);
triple_devs = kcalloc(maxdev, sizeof(struct net_device *)*maxdev, GFP_KERNEL);

if (!triple_devs)
return -ENOMEM;

/* Fill in our line protocol discipline, and register it */
status = tty_register_ldisc(N_TRIPLE, &triple_ldisc);
status = tty_register_ldisc(&triple_ldisc);
printk(KERN_ERR "triple: register line discipline%d\n", N_TRIPLE);

if (status)
Expand Down Expand Up @@ -230,14 +230,11 @@ static void __exit triple_exit (void)
kfree(triple_devs);
triple_devs = NULL;

i = tty_unregister_ldisc(N_TRIPLE);

if (i)
printk(KERN_ERR "triple: can't unregister ldisc (err %d)\n", i);
tty_unregister_ldisc(&triple_ldisc);

} /* END: triple_exit() */

static void triple_receive_buf (struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
static void triple_receive_buf (struct tty_struct *tty, const unsigned char *cp, const char *fp, int count)
{
USB2CAN_TRIPLE *adapter = (USB2CAN_TRIPLE *) tty->disc_data;

Expand Down Expand Up @@ -357,6 +354,7 @@ static int triple_open (struct tty_struct *tty)
adapter->tty = NULL;
tty->disc_data = NULL;
clear_bit(SLF_INUSE, &adapter->flags);
rtnl_unlock();

ERR_EXIT:
rtnl_unlock();
Expand Down Expand Up @@ -397,14 +395,13 @@ static void triple_close (struct tty_struct *tty)
} /* END: triple_close() */


static int triple_hangup (struct tty_struct *tty)
static void triple_hangup (struct tty_struct *tty)
{
/*=======================================================*/
print_func_trace(trace_func_main, __LINE__, __FUNCTION__);
/*=======================================================*/

triple_close(tty);
return 0;


} /* END: triple_hangup() */
Expand Down Expand Up @@ -450,7 +447,7 @@ static int triple_ioctl (struct tty_struct *tty, struct file *file, unsigned int
return -EINVAL;

default:
return tty_mode_ioctl(tty, file, cmd, arg);
return tty_mode_ioctl(tty, cmd, arg);
}

} /* END: triple_ioctl() */
Expand Down

0 comments on commit 97d4bc0

Please sign in to comment.