projects
/
elmcan.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Forward port to Linux v5.17-rc3
[elmcan.git]
/
module
/
elmcan.c
diff --git
a/module/elmcan.c
b/module/elmcan.c
index d0b769439b30542483a93debe6c8cd6baf9e6be3..acb605781c6d4387e50e0f4a6d7eece20afa47ae 100644
(file)
--- a/
module/elmcan.c
+++ b/
module/elmcan.c
@@
-40,9
+40,12
@@
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/tty.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/tty.h>
+#include <linux/tty_ldisc.h>
#include <linux/version.h>
#include <linux/workqueue.h>
#include <linux/version.h>
#include <linux/workqueue.h>
+#include <uapi/linux/tty.h>
+
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
#include <linux/can.h>
#include <linux/can/dev.h>
#include <linux/can/error.h>
@@
-982,8
+985,13
@@
static bool elmcan_is_valid_rx_char(char c)
* This will not be re-entered while running, but other ldisc
* functions may be called in parallel.
*/
* This will not be re-entered while running, but other ldisc
* functions may be called in parallel.
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)
static void elmcan_ldisc_rx(struct tty_struct *tty,
const unsigned char *cp, char *fp, int count)
static void elmcan_ldisc_rx(struct tty_struct *tty,
const unsigned char *cp, char *fp, int count)
+#else
+static void elmcan_ldisc_rx(struct tty_struct *tty,
+ const unsigned char *cp, const char *fp, int count)
+#endif
{
struct elmcan *elm = get_elm(tty);
{
struct elmcan *elm = get_elm(tty);
@@
-1231,13
+1239,22
@@
static void elmcan_ldisc_close(struct tty_struct *tty)
free_candev(elm->dev);
}
free_candev(elm->dev);
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0)
static int elmcan_ldisc_hangup(struct tty_struct *tty)
static int elmcan_ldisc_hangup(struct tty_struct *tty)
+#else
+static void elmcan_ldisc_hangup(struct tty_struct *tty)
+#endif
{
elmcan_ldisc_close(tty);
{
elmcan_ldisc_close(tty);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0)
return 0;
return 0;
+#endif
}
}
-static int elmcan_ldisc_ioctl(struct tty_struct *tty, struct file *file,
+static int elmcan_ldisc_ioctl(struct tty_struct *tty,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,17,0)
+ struct file *file,
+#endif
unsigned int cmd, unsigned long arg)
{
struct elmcan *elm = get_elm(tty);
unsigned int cmd, unsigned long arg)
{
struct elmcan *elm = get_elm(tty);
@@
-1263,13
+1280,18
@@
static int elmcan_ldisc_ioctl(struct tty_struct *tty, struct file *file,
default:
put_elm(elm);
default:
put_elm(elm);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0)
return tty_mode_ioctl(tty, file, cmd, arg);
return tty_mode_ioctl(tty, file, cmd, arg);
+#else
+ return tty_mode_ioctl(tty, cmd, arg);
+#endif
}
}
static struct tty_ldisc_ops elmcan_ldisc = {
.owner = THIS_MODULE,
.name = "elmcan",
}
}
static struct tty_ldisc_ops elmcan_ldisc = {
.owner = THIS_MODULE,
.name = "elmcan",
+ .num = N_ELMCAN,
.receive_buf = elmcan_ldisc_rx,
.write_wakeup = elmcan_ldisc_tx_wakeup,
.open = elmcan_ldisc_open,
.receive_buf = elmcan_ldisc_rx,
.write_wakeup = elmcan_ldisc_tx_wakeup,
.open = elmcan_ldisc_open,
@@
-1285,7
+1307,11
@@
static int __init elmcan_init(void)
pr_info("ELM327 based best effort CAN interface driver\n");
pr_info("This device is severely limited as a CAN interface, see documentation.\n");
pr_info("ELM327 based best effort CAN interface driver\n");
pr_info("This device is severely limited as a CAN interface, see documentation.\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)
status = tty_register_ldisc(N_ELMCAN, &elmcan_ldisc);
status = tty_register_ldisc(N_ELMCAN, &elmcan_ldisc);
+#else
+ status = tty_register_ldisc(&elmcan_ldisc);
+#endif
if (status)
pr_err("Can't register line discipline\n");
if (status)
pr_err("Can't register line discipline\n");
@@
-1297,12
+1323,16
@@
static void __exit elmcan_exit(void)
/* This will only be called when all channels have been closed by
* userspace - tty_ldisc.c takes care of the module's refcount.
*/
/* This will only be called when all channels have been closed by
* userspace - tty_ldisc.c takes care of the module's refcount.
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)
int status;
status = tty_unregister_ldisc(N_ELMCAN);
if (status)
pr_err("Can't unregister line discipline (error: %d)\n",
status);
int status;
status = tty_unregister_ldisc(N_ELMCAN);
if (status)
pr_err("Can't unregister line discipline (error: %d)\n",
status);
+#else
+ tty_unregister_ldisc(&elmcan_ldisc);
+#endif
}
module_init(elmcan_init);
}
module_init(elmcan_init);