Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve nullpointer crash on kernel 5.10 #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ttyebusm.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,21 @@ static int IrqCounter = 0;
// The UART interrupt on model B+ is allocated to 81.
// The UART interrupt on RASPI2,3 is allocated to 87, beginning with kernel 4.19.42, it is allocated to 81.
// For RASPI 4, the interrupt is 34 and is shared with all other UARTs.
// Beginning with kernel 5.10 RASPI 2 and 3 uses IRQ 114 and RASPI 4 uses IRQ 29
#define RASPI_1_UART_IRQ 81
#define RASPI_4_UART_IRQ 34
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,42)
#define RASPI_23_UART_IRQ 87
#else
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
#define RASPI_23_UART_IRQ 81
#else
#define RASPI_23_UART_IRQ 114
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
#define RASPI_4_UART_IRQ 34
#else
#define RASPI_4_UART_IRQ 29
#endif


// PL011 UART register (16C650 type)
// =================================
Expand Down Expand Up @@ -813,7 +821,11 @@ unsigned int ttyebus_raspi_model(void)
set_fs(old_fs);
return 0;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)
NumBytes = kernel_read(filp, buf, sizeof(buf), 0);
#else
NumBytes = filp->f_op->read(filp, buf, sizeof(buf), &filp->f_pos);
#endif
set_fs(old_fs);

// restore the segment descriptor
Expand Down