accesio / AIOSerial

0 stars 2 forks source link

error: ‘struct uart_port’ has no member named ‘timeout’ #2

Open milanraf73 opened 9 months ago

milanraf73 commented 9 months ago

Running kernel: 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC x86_64

cat /proc/tty/drivers: /dev/tty /dev/tty 5 0 system:/dev/tty /dev/console /dev/console 5 1 system:console /dev/ptmx /dev/ptmx 5 2 system /dev/vc/0 /dev/vc/0 4 0 system:vtmaster dbc_serial /dev/ttyDBC 242 0-63 serial ttyprintk /dev/ttyprintk 5 3 console max310x /dev/ttyMAX 204 209-224 serial serial /dev/ttyS 4 64-111 serial pty_slave /dev/pts 136 0-1048575 pty:slave pty_master /dev/ptm 128 0-1048575 pty:master unknown /dev/tty 4 1-63 console

ls /proc/tty/driver: dr-x------ 4 root root 0 feb 26 16:12 ./ dr-xr-xr-x 6 root root 0 feb 26 13:39 ../ -r--r--r-- 1 root root 0 feb 26 16:13 max310x -r--r--r-- 1 root root 0 feb 26 16:13 serial

Trying to compile, got the following error:

make -C /lib/modules/uname -r/build M=/home/connlab/Documents/code/xr17v35x/AIOSerial/XR modules make[1]: Entering directory '/usr/src/linux-headers-6.5.0-21-generic' CC [M] /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.o /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c: In function ‘serialxr_timeout’: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:1176:62: error: ‘struct uart_port’ has no member named ‘timeout’ 1176 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | ^ /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c: At top level: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:2158:27: error: initialization of ‘void ()(struct uart_port , struct ktermios , const struct ktermios )’ from incompatible pointer type ‘void ()(struct uart_port , struct ktermios , struct ktermios )’ [-Werror=incompatible-pointer-types] 2158 | .set_termios = serialxr_set_termios, | ^~~~~~~~ /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:2158:27: note: (near initialization for ‘serialxr_pops.set_termios’) cc1: some warnings being treated as errors make[3]: [scripts/Makefile.build:251: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.o] Error 1 make[2]: [/usr/src/linux-headers-6.5.0-21-generic/Makefile:2039: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR] Error 2 make[1]: [Makefile:234: __sub-make] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-21-generic' make: [Makefile:13: build] Error 2

jdolanIV commented 9 months ago

@milanraf73

What is the model of the ACCES card that you're working with?

-- Jay

jmitchell-accesio commented 9 months ago

I have not attempted to compile the XR code in years but It seems the newer serial library in the current linux kernel is no longer compatible with older implementations. The driver comes from MaxLinear, almost verbatim. You might try looking on their website for an updated driver.

On Mon, Feb 26, 2024 at 7:54 AM milanraf73 @.***> wrote:

Running kernel: 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC x86_64

cat /proc/tty/drivers: /dev/tty /dev/tty 5 0 system:/dev/tty /dev/console /dev/console 5 1 system:console /dev/ptmx /dev/ptmx 5 2 system /dev/vc/0 /dev/vc/0 4 0 system:vtmaster dbc_serial /dev/ttyDBC 242 0-63 serial ttyprintk /dev/ttyprintk 5 3 console max310x /dev/ttyMAX 204 209-224 serial serial /dev/ttyS 4 64-111 serial pty_slave /dev/pts 136 0-1048575 pty:slave pty_master /dev/ptm 128 0-1048575 pty:master unknown /dev/tty 4 1-63 console

ls /proc/tty/driver: dr-x------ 4 root root 0 feb 26 16:12 ./ dr-xr-xr-x 6 root root 0 feb 26 13:39 ../ -r--r--r-- 1 root root 0 feb 26 16:13 max310x -r--r--r-- 1 root root 0 feb 26 16:13 serial

Trying to compile, got the following error:

make -C /lib/modules/uname -r/build M=/home/connlab/Documents/code/xr17v35x/AIOSerial/XR modules make[1]: Entering directory '/usr/src/linux-headers-6.5.0-21-generic' CC [M] /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.o /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c: In function ‘serialxr_timeout’: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:1176:62: error: ‘struct uart_port’ has no member named ‘timeout’ 1176 | mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); | ^ /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c: At top level: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:2158:27: error: initialization of ‘void ()(struct uart_port , struct ktermios , const struct ktermios )’ from incompatible pointer type ‘void ()(struct uart_port , struct ktermios , struct ktermios )’ [-Werror=incompatible-pointer-types] 2158 | .set_termios = serialxr_set_termios, | ^~~~~~~~ /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.c:2158:27: note: (near initialization for ‘serialxr_pops.set_termios’) cc1: some warnings being treated as errors make[3]: [scripts/Makefile.build:251: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR/xr17v35x.o] Error 1 make[2]: [/usr/src/linux-headers-6.5.0-21-generic/Makefile:2039: /home/connlab/Documents/code/xr17v35x/AIOSerial/XR] Error 2 make[1]: [Makefile:234: __sub-make] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-21-generic' make: [Makefile:13: build] Error 2

— Reply to this email directly, view it on GitHub https://github.com/accesio/AIOSerial/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/APD4YBKXB6OOCJXH5XGJ2TLYVSVZPAVCNFSM6AAAAABD2OSBCGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE2TINJRGMYDSOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

milanraf73 commented 9 months ago

I am actually using an Advantech card which implements XR17V352. Advantech driver look almost identical this one. Same 'missing timeout member' error. Hence I tried to look for support here...I'm sorry for eventually not being compliant to your support policies...

Looking at driver implementation, it seems that no 'timeout' member is defined in uart_adv_port struct:

struct uart_adv_port {
        struct uart_port        port;
        struct timer_list       timer;          /* "no irq" timer */
        struct list_head        list;           /* ports on this IRQ */
        unsigned short          capabilities;   /* port capabilities */
        unsigned short          bugs;           /* port bugs */
        unsigned int            tx_loadsz;      /* transmit fifo load size */
        unsigned char           acr;
        unsigned char           ier;
        unsigned char           lcr;
        unsigned char           mcr;
        unsigned char           mcr_mask;       /* mask of user bits */
        unsigned char           mcr_force;      /* mask of forced bits */

        unsigned char           lsr_saved_flags;
        unsigned char           msr_saved_flags;

        unsigned short          deviceid;
        unsigned short          board_id;
        unsigned char           channelnum;

        /*
         * We provide a per-port pm hook.
         */
        void                    (*pm)(struct uart_port *port,
                                          unsigned int state, unsigned int old);

        int                     index;                  /* serial index in card, start at 0 */
        int                             serialMode;             /* RS232 or RS422 or RS485 */

        int                             current_card_nr;
        int                             fix_number_index;
}

albeit it is referenced in line 1190:

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void serialadv_timeout(unsigned long data)
#else
static void serialadv_timeout(struct timer_list *t)
#endif
{
        //NOTE: Due to API changing in the Kernel
        //we need to handle differnent kernel version
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
        struct uart_adv_port *up = (struct uart_adv_port *)data;
#else
        struct uart_adv_port *up = from_timer(up, t, timer);
#endif
        unsigned int iir;

        iir = serial_in(up, UART_IIR);
        if (!(iir & UART_IIR_NO_INT))
                serialadv_handle_port(up);
        mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));
}
milanraf73 commented 9 months ago

For kernel ver higher than 4 it will assign to pointer 'up' the value returned from 'from_timer' function, which in 'timer.h' is defined as:

#define from_timer(var, callback_timer, timer_fieldname) \
        container_of(callback_timer, typeof(*var), timer_fieldname)

Sadly, this is beyond my knowledge of C language...I cannot figure out the definition for the return value of this symbol

jmitchell-accesio commented 9 months ago

Unfortunately, I'm in the same boat. I was able to modify the XR driver to include our card but beyond that I'm at a loss. Sorry.

On Mon, Feb 26, 2024 at 8:50 AM milanraf73 @.***> wrote:

For kernel ver higher than 4 it will assign to pointer 'up' the value returned from 'from_timer' function, which in 'timer.h' is defined as:

define from_timer(var, callback_timer, timer_fieldname) \

    container_of(callback_timer, typeof(*var), timer_fieldname)

Sadly, this is beyond my knowledge of C language...I cannot figure out the definition for the return value of this symbol

— Reply to this email directly, view it on GitHub https://github.com/accesio/AIOSerial/issues/2#issuecomment-1964630471, or unsubscribe https://github.com/notifications/unsubscribe-auth/APD4YBOCOZB2SOVNDEZ3W4LYVS4MFAVCNFSM6AAAAABD2OSBCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGYZTANBXGE . You are receiving this because you commented.Message ID: @.***>

milanraf73 commented 9 months ago

Thank you for your feedback.

jdolanIV commented 9 months ago

Marking as low priority since not currently customer impacting.

milanraf73 commented 8 months ago

I made it compile, in the end.

The timeout member of uart_port struct had been dropped as stated here: https://www.spinics.net/lists/kernel/msg4396678.html

Moreover, the set_termios member of uart_ops struct is defined a CONST ktermios struct as third parameter.

Here is the diff on file adv17v35x.c

1187,1190d1186
<   int uart_timeout;
< 
<   uart_timeout =(int)(up->port.frame_time * up->port.fifosize);
< 
1194c1190
<   mod_timer(&up->timer, jiffies + poll_timeout(uart_timeout));
---
>   mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));
1605c1601
<              const struct ktermios *old)
---
>              struct ktermios *old)

Hope this could help your customers in future. Me, as an Advantech customer, had been left alone.

milanraf73 commented 8 months ago

I attach here the c file from Advantech driver I worked on (same as official EXAR one) adv17v35x.tar.gz

jmitchell-accesio commented 8 months ago

Great sleuthing!

On Mon, Mar 4, 2024 at 5:24 AM milanraf73 @.***> wrote:

I made it compile, in the end.

The timeout member of uart_port struct had been dropped as stated here: https://www.spinics.net/lists/kernel/msg4396678.html

Moreover, the set_termios member of uart_ops struct is defined a CONST ktermios struct as third parameter.

Here is the diff on file adv17v35x.c

1187,1190d1186 < int uart_timeout; < < uart_timeout =(int)(up->port.frame_time * up->port.fifosize); < 1194c1190 < mod_timer(&up->timer, jiffies + poll_timeout(uart_timeout));

mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout));

1605c1601 < const struct ktermios *old)

           struct ktermios *old)

Hope this could help your customers in future. Me, as an Advantech customer, had been left alone.

— Reply to this email directly, view it on GitHub https://github.com/accesio/AIOSerial/issues/2#issuecomment-1976575041, or unsubscribe https://github.com/notifications/unsubscribe-auth/APD4YBPJCZK5CC5DUYT3QFDYWRYYRAVCNFSM6AAAAABD2OSBCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZWGU3TKMBUGE . You are receiving this because you commented.Message ID: @.***>

jdolanIV commented 8 months ago

@milanraf73 Thank you for letting us know.

dTenebrae commented 1 month ago

Addressed this issue in #3 Hopefully it'll help.