ipilcher / n5550

Thecus N5550 hardware support
GNU General Public License v2.0
8 stars 8 forks source link

Building modules on debian testing - kernel 5.9.0-4 #17

Closed bergercookie closed 2 years ago

bergercookie commented 3 years ago

Thanks for this project,

I've tried to compile the kernel modules on debian-testing (bullseye) which runs on my thecus n5550.

I'm getting the following error when running make from inside the modules directory:

berger@mosq [master]~/src/n5550-hw-support/modules$ make
make -C /lib/modules/5.9.0-4-amd64/build M=/home/berger/src/n5550-hw-support/modules modules
make[1]: Entering directory '/usr/src/linux-headers-5.9.0-4-amd64'
  CC [M]  /home/berger/src/n5550-hw-support/modules/n5550_board.o
/home/berger/src/n5550-hw-support/modules/n5550_board.c: In function ‘n5550_pca9532_setup’:
/home/berger/src/n5550-hw-support/modules/n5550_board.c:356:27: error: implicit declaration of function ‘i2c_new_device’ [-Werror=implicit-function-declaration]
  356 |  n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);
      |                           ^~~~~~~~~~~~~~
/home/berger/src/n5550-hw-support/modules/n5550_board.c:356:25: warning: assignment to ‘struct i2c_client *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  356 |  n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);
      |                         ^
/home/berger/src/n5550-hw-support/modules/n5550_board.c:363:25: warning: assignment to ‘struct i2c_client *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  363 |  n5550_pca9532_1_client = i2c_new_device(adapter, &n5550_pca9532_1_info);
      |                         ^
cc1: some warnings being treated as errors
make[3]: *** [/usr/src/linux-headers-5.9.0-4-common/scripts/Makefile.build:288: /home/berger/src/n5550-hw-support/modules/n5550_board.o] Error 1
make[2]: *** [/usr/src/linux-headers-5.9.0-4-common/Makefile:1796: /home/berger/src/n5550-hw-support/modules] Error 2
make[1]: *** [/usr/src/linux-headers-5.9.0-4-common/Makefile:185: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.9.0-4-amd64'
make: *** [Makefile:6: all] Error 2

Here's the relevant section of uname -a:

SMP Debian 5.9.11-1 (2020-11-27) x86_64 GNU/Linux

Any pointers?

ipilcher commented 3 years ago

It's possible that the i2c_new_device function doesn't exist any more in 5.9. (I've never tried to build the modules on anything later than CentOS 7, which has a very old kernel.) If you're lucky, its declaration has just been moved to a different header.)

On Tue, Dec 8, 2020, 5:58 PM Nikos Koukis notifications@github.com wrote:

Thanks for this project,

I've tried to compile the kernel modules on debian-testing (bullseye) which runs on my thecus n5550.

I'm getting the following error when running make from inside the modules directory:

berger@mosq [master]~/src/n5550-hw-support/modules$ make

make -C /lib/modules/5.9.0-4-amd64/build M=/home/berger/src/n5550-hw-support/modules modules

make[1]: Entering directory '/usr/src/linux-headers-5.9.0-4-amd64'

CC [M] /home/berger/src/n5550-hw-support/modules/n5550_board.o

/home/berger/src/n5550-hw-support/modules/n5550_board.c: In function ‘n5550_pca9532_setup’:

/home/berger/src/n5550-hw-support/modules/n5550_board.c:356:27: error: implicit declaration of function ‘i2c_new_device’ [-Werror=implicit-function-declaration]

356 | n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);

  |                           ^~~~~~~~~~~~~~

/home/berger/src/n5550-hw-support/modules/n5550_board.c:356:25: warning: assignment to ‘struct i2c_client *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

356 | n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);

  |                         ^

/home/berger/src/n5550-hw-support/modules/n5550_board.c:363:25: warning: assignment to ‘struct i2c_client *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

363 | n5550_pca9532_1_client = i2c_new_device(adapter, &n5550_pca9532_1_info);

  |                         ^

cc1: some warnings being treated as errors

make[3]: *** [/usr/src/linux-headers-5.9.0-4-common/scripts/Makefile.build:288: /home/berger/src/n5550-hw-support/modules/n5550_board.o] Error 1

make[2]: *** [/usr/src/linux-headers-5.9.0-4-common/Makefile:1796: /home/berger/src/n5550-hw-support/modules] Error 2

make[1]: *** [/usr/src/linux-headers-5.9.0-4-common/Makefile:185: __sub-make] Error 2

make[1]: Leaving directory '/usr/src/linux-headers-5.9.0-4-amd64'

make: *** [Makefile:6: all] Error 2

Here's the relevant section of uname -a:

SMP Debian 5.9.11-1 (2020-11-27) x86_64 GNU/Linux

Any pointers?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ipilcher/n5550/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIFLY3GGDHIU4KL6QMEBG3ST24T5ANCNFSM4USWMSAQ .

bergercookie commented 3 years ago

Yup, that's the case, i2c_new_device has been renamed to i2c_new_kernel_device. I also had to change the CLASS_ATTR macro. Here 's a patch to successfully compile the modules in kernel 5.9.0

diff --git a/modules/n5550_ahci_leds.c b/modules/n5550_ahci_leds.c
index 84be1f8..f3b971d 100644
--- a/modules/n5550_ahci_leds.c
+++ b/modules/n5550_ahci_leds.c
@@ -58,7 +58,8 @@ static struct led_trigger n5550_ahci_led_triggers[5] = {

 static struct class *n5550_ahci_leds_sysfs_class;

-static ssize_t n5550_ahci_leds_enabled_show(struct class *class,
+/*  n5550_ahci_leds_enabled_show */
+static ssize_t enabled_show(struct class *class,
                        struct class_attribute *attr,
                                             char *buf)
 {
@@ -76,7 +77,8 @@ static ssize_t n5550_ahci_leds_enabled_show(struct class *class,
    return sprintf(buf, "%d\n", i);
 }

-static ssize_t n5550_ahci_leds_enabled_store(struct class *class,
+/*  n5550_ahci_leds_enabled_store */
+static ssize_t enabled_store(struct class *class,
                         struct class_attribute *attr,
                                              const char *buf, size_t count)
 {
@@ -145,9 +147,7 @@ static ssize_t n5550_ahci_leds_enabled_store(struct class *class,
    return (ssize_t)count;
 }

-static CLASS_ATTR(enabled, 0644,
-         n5550_ahci_leds_enabled_show,
-                  n5550_ahci_leds_enabled_store);
+static CLASS_ATTR_RW(enabled);

 static int n5550_create_sysfs_file(void)
 {
diff --git a/modules/n5550_board.c b/modules/n5550_board.c
index 52a776d..83637ba 100644
--- a/modules/n5550_board.c
+++ b/modules/n5550_board.c
@@ -353,14 +353,14 @@ static int __init n5550_pca9532_setup(void)
        return -EBUSY;
    }

-   n5550_pca9532_0_client = i2c_new_device(adapter, &n5550_pca9532_0_info);
+   n5550_pca9532_0_client = i2c_new_client_device(adapter, &n5550_pca9532_0_info);
    if (n5550_pca9532_0_client == NULL) {
        module_put(adapter->owner);
        pci_dev_put(dev);
        return -ENODEV;
    }

-   n5550_pca9532_1_client = i2c_new_device(adapter, &n5550_pca9532_1_info);
+   n5550_pca9532_1_client = i2c_new_client_device(adapter, &n5550_pca9532_1_info);
    if (n5550_pca9532_1_client == NULL) {
        i2c_unregister_device(n5550_pca9532_0_client);
        module_put(adapter->owner);
ipilcher commented 2 years ago

I finally committed the fix for the i2c_new_device() ==> i2c_new_client_device() change. I didn't include the CLASS_ATTR() macro change, because I'm not a fan of how it forces the function names to change.