Skip to content

Commit dd63794

Browse files
committed
fix build issue with RHEL 9.5
1 parent 99c3e35 commit dd63794

1 file changed

Lines changed: 47 additions & 5 deletions

File tree

driver/xr_usb_serial_common.c

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,14 @@ static void xr_usb_serial_tty_close(struct tty_struct *tty, struct file *filp)
718718
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,6,0)
719719
static ssize_t xr_usb_serial_tty_write(struct tty_struct *tty,
720720
const unsigned char *buf, size_t count)
721+
#elif defined(RHEL_RELEASE_CODE)
722+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
723+
static ssize_t xr_usb_serial_tty_write(struct tty_struct *tty,
724+
const unsigned char *buf, size_t count)
725+
# else
726+
static int xr_usb_serial_tty_write(struct tty_struct *tty,
727+
const unsigned char *buf, int count)
728+
# endif
721729
#else
722730
static int xr_usb_serial_tty_write(struct tty_struct *tty,
723731
const unsigned char *buf, int count)
@@ -1101,17 +1109,23 @@ static int xr_usb_serial_tty_ioctl(struct tty_struct *tty,
11011109
return rv;
11021110
}
11031111

1104-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)
1112+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
1113+
static void xr_usb_serial_tty_set_termios(struct tty_struct *tty, const struct ktermios *termios_old)
1114+
#elif defined(RHEL_RELEASE_CODE)
1115+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
1116+
static void xr_usb_serial_tty_set_termios(struct tty_struct *tty, const struct ktermios *termios_old)
1117+
# else
11051118
static void xr_usb_serial_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old)
1119+
# endif
11061120
#else
1107-
static void xr_usb_serial_tty_set_termios(struct tty_struct *tty, const struct ktermios *termios_old)
1121+
static void xr_usb_serial_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old)
11081122
#endif
11091123
{
11101124
struct xr_usb_serial *xr_usb_serial = tty->driver_data;
1111-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)
1112-
struct ktermios *termios = tty->termios;
1125+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
1126+
struct ktermios *termios = &tty->termios;
11131127
#else
1114-
struct ktermios *termios = &tty->termios;
1128+
struct ktermios *termios = tty->termios;
11151129
#endif
11161130
unsigned int cflag = termios->c_cflag;
11171131
struct usb_cdc_line_coding newline;
@@ -2036,6 +2050,16 @@ static int __init xr_usb_serial_init(void)
20362050
xr_usb_serial_tty_driver = tty_alloc_driver(XR_USB_SERIAL_TTY_MINORS, 0);
20372051
if (IS_ERR(xr_usb_serial_tty_driver))
20382052
return PTR_ERR(xr_usb_serial_tty_driver);
2053+
#elif defined(RHEL_RELEASE_CODE)
2054+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
2055+
xr_usb_serial_tty_driver = tty_alloc_driver(XR_USB_SERIAL_TTY_MINORS, 0);
2056+
if (IS_ERR(xr_usb_serial_tty_driver))
2057+
return PTR_ERR(xr_usb_serial_tty_driver);
2058+
# else
2059+
xr_usb_serial_tty_driver = alloc_tty_driver(XR_USB_SERIAL_TTY_MINORS);
2060+
if (!xr_usb_serial_tty_driver)
2061+
return -ENOMEM;
2062+
# endif
20392063
#else
20402064
xr_usb_serial_tty_driver = alloc_tty_driver(XR_USB_SERIAL_TTY_MINORS);
20412065
if (!xr_usb_serial_tty_driver)
@@ -2057,6 +2081,12 @@ static int __init xr_usb_serial_init(void)
20572081
if (retval) {
20582082
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
20592083
tty_driver_kref_put(xr_usb_serial_tty_driver);
2084+
#elif defined(RHEL_RELEASE_CODE)
2085+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
2086+
tty_driver_kref_put(xr_usb_serial_tty_driver);
2087+
# else
2088+
put_tty_driver(xr_usb_serial_tty_driver);
2089+
# endif
20602090
#else
20612091
put_tty_driver(xr_usb_serial_tty_driver);
20622092
#endif
@@ -2068,6 +2098,12 @@ static int __init xr_usb_serial_init(void)
20682098
tty_unregister_driver(xr_usb_serial_tty_driver);
20692099
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
20702100
tty_driver_kref_put(xr_usb_serial_tty_driver);
2101+
#elif defined(RHEL_RELEASE_CODE)
2102+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
2103+
tty_driver_kref_put(xr_usb_serial_tty_driver);
2104+
# else
2105+
put_tty_driver(xr_usb_serial_tty_driver);
2106+
# endif
20712107
#else
20722108
put_tty_driver(xr_usb_serial_tty_driver);
20732109
#endif
@@ -2085,6 +2121,12 @@ static void __exit xr_usb_serial_exit(void)
20852121
tty_unregister_driver(xr_usb_serial_tty_driver);
20862122
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
20872123
tty_driver_kref_put(xr_usb_serial_tty_driver);
2124+
#elif defined(RHEL_RELEASE_CODE)
2125+
# if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9,5)
2126+
tty_driver_kref_put(xr_usb_serial_tty_driver);
2127+
# else
2128+
put_tty_driver(xr_usb_serial_tty_driver);
2129+
# endif
20882130
#else
20892131
put_tty_driver(xr_usb_serial_tty_driver);
20902132
#endif

0 commit comments

Comments
 (0)