Open Dinth opened 1 year ago
Possibly related to https://github.com/eBUS/ttyebus/issues/6
The bad news are that in newer Kernel versions the functions get_fs
and set_fs
are not available by default. The good news – they are not used for anything critical in ttyebus, and can be completely removed from the code as a one-time workaround. Tested on Raspberry Pi Zero W v1.1 running on the latest Raspbian Kernel (6.1.21+).
The patch below should explain everything:
diff --git a/ttyebusm.c b/ttyebusm.c
index f79468c..3197e75 100644
--- a/ttyebusm.c
+++ b/ttyebusm.c
@@ -782,59 +782,6 @@ static long ttyebus_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
}
-// ===============================================================================================
-//
-// ttyebus_raspi_model
-//
-// ===============================================================================================
-// Description:
-// Get the Rasperry Pi model number from /sys/firmware/devicetree/base/model. The string
-// has usually the form "Raspberry Pi 3 Model B Rev 1.2"
-// Extract the number and return it.
-//
-// ===============================================================================================
-unsigned int ttyebus_raspi_model(void)
- {
- struct file* filp = NULL;
- char buf[32];
- unsigned int NumBytes = 0;
-
- // get current segment descriptor, set segment descriptor
- // associated to kernel space
- // ======================================================
- mm_segment_t old_fs = get_fs();
- set_fs(KERNEL_DS);
-
- // read the file
- // =============
- filp = filp_open("/sys/firmware/devicetree/base/model", O_RDONLY, 0);
- if (filp == NULL)
- {
- set_fs(old_fs);
- return 0;
- }
- NumBytes = filp->f_op->read(filp, buf, sizeof(buf), &filp->f_pos);
- set_fs(old_fs);
-
- // restore the segment descriptor
- // ==============================
- filp_close(filp, NULL);
-
- // interpret the data from the file
- // ================================
- if (NumBytes < 14)
- return 0;
-
- switch(buf[13])
- {
- case '2' : return 2; break;
- case '3' : return 3; break;
- case '4' : return 4; break;
- default: return 1;
- }
- }
-
-
// ===============================================================================================
//
// ttyebus_register
@@ -864,7 +811,7 @@ int ttyebus_register(void)
// Get the RASPI model
// ===================
- RaspiModel = ttyebus_raspi_model();
+ RaspiModel = 1; // Change accordingly to your Raspberry model
if (RaspiModel < 1 || RaspiModel > 4)
{
printk(KERN_NOTICE "ttyebus: Unknown RASPI model %d\n", RaspiModel);
Im getting the following error: