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

Compile error on kernel 5.15.84-v7+ #14

Open
Dinth opened this issue Mar 6, 2023 · 2 comments
Open

Compile error on kernel 5.15.84-v7+ #14

Dinth opened this issue Mar 6, 2023 · 2 comments

Comments

@Dinth
Copy link

Dinth commented Mar 6, 2023

Im getting the following error:

make -C /lib/modules/5.15.84-v7+/build M=/home/dinth/ttyebus modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.84-v7+'
  CC [M]  /home/dinth/ttyebus/ttyebusm.o
/home/dinth/ttyebus/ttyebusm.c: In function ‘ttyebus_raspi_model’:
/home/dinth/ttyebus/ttyebusm.c:805:27: error: implicit declaration of function ‘get_fs’; did you mean ‘sget_fc’? [-Werror=implicit-function-declaration]
  805 |     mm_segment_t old_fs = get_fs();
      |                           ^~~~~~
      |                           sget_fc
/home/dinth/ttyebus/ttyebusm.c:805:27: error: invalid initializer
/home/dinth/ttyebus/ttyebusm.c:806:5: error: implicit declaration of function ‘set_fs’; did you mean ‘sget_fc’? [-Werror=implicit-function-declaration]
  806 |     set_fs(KERNEL_DS);
      |     ^~~~~~
      |     sget_fc
/home/dinth/ttyebus/ttyebusm.c:806:12: error: ‘KERNEL_DS’ undeclared (first use in this function); did you mean ‘KERNFS_NS’?
  806 |     set_fs(KERNEL_DS);
      |            ^~~~~~~~~
      |            KERNFS_NS
/home/dinth/ttyebus/ttyebusm.c:806:12: note: each undeclared identifier is reported only once for each function it appears in
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:289: /home/dinth/ttyebus/ttyebusm.o] Error 1
make[1]: *** [Makefile:1902: /home/dinth/ttyebus] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.84-v7+'
make: *** [Makefile:24: all] Error 2

@Dinth
Copy link
Author

Dinth commented Mar 6, 2023

Possibly related to #6

@ITachiLab
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants