Ubuntu22.04 USB转串口驱动

本文解决ch9102x芯片驱动在Ubuntu22.04上编译错误的问题,包括指针类型不匹配及函数声明缺失等,并提供修改后的驱动代码链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ch9102x芯片的旧版驱动程序用在ubuntu22.04时,编译时会产生如下错误:

make[1]: Entering directory '/usr/src/linux-headers-5.16.15-76051615-generic'
  CC [M]  /home/maz/driver/ch343.o
/home/maz/driver/ch343.c:1684:33: error: initialization of ‘unsigned int (*)(struct tty_struct *)’ from incompatible pointer type ‘int (*)(struct tty_struct *)’ [-Werror=incompatible-pointer-types]
 1684 |         .write_room =           ch343_tty_write_room,
      |                                 ^~~~~~~~~~~~~~~~~~~~
/home/maz/driver/ch343.c:1684:33: note: (near initialization for ‘ch343_ops.write_room’)
/home/maz/driver/ch343.c:1686:33: error: initialization of ‘unsigned int (*)(struct tty_struct *)’ from incompatible pointer type ‘int (*)(struct tty_struct *)’ [-Werror=incompatible-pointer-types]
 1686 |         .chars_in_buffer =      ch343_tty_chars_in_buffer,
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/maz/driver/ch343.c:1686:33: note: (near initialization for ‘ch343_ops.chars_in_buffer’)
/home/maz/driver/ch343.c: In function ‘ch343_init’:
/home/maz/driver/ch343.c:1699:28: error: implicit declaration of function ‘alloc_tty_driver’ [-Werror=implicit-function-declaration]
 1699 |         ch343_tty_driver = alloc_tty_driver(CH343_TTY_MINORS);
      |                            ^~~~~~~~~~~~~~~~
/home/maz/driver/ch343.c:1699:26: warning: assignment to ‘struct tty_driver *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 1699 |         ch343_tty_driver = alloc_tty_driver(CH343_TTY_MINORS);
      |                          ^
/home/maz/driver/ch343.c:1716:17: error: implicit declaration of function ‘put_tty_driver’ [-Werror=implicit-function-declaration]
 1716 |                 put_tty_driver(ch343_tty_driver);
      |                 ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors

 GreatestCapacity 修改了代码,使其与新的Linux内核兼容。如果设备工作正常,驱动程序将在/dev目录下创建tty设备,命名为“ttyCH343USBx”。驱动代码如下:

https://github.com/WCHSoftGroup/ch343ser_linux/issues/8

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值