我一直在学习名为“LINUX内核开发初学者指南”的LFD103课程。在“编写您的第一个内核修补程序”一节中,我们对'uvcvideo‘驱动程序进行更改并重新编译它。但我就是不能让它起作用。正如教程所提到的,我添加了pr_info()函数。
static int uvc_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct uvc_device *dev;
const struct uvc_device_info *info =
(const struct uvc_device_info *)id->driver_info;
int function;
int ret;
pr_info("I changed uvcvideo driver in the Linux Kernel\n");
if (id->idVendor && id->idProduct)
uvc_trace(UVC_TRACE_PROBE, "Probing known UVC device %s "
"(%04x:%04x)\n", udev->devpath, id->idVendor,
id->idProduct);
else
uvc_trace(UVC_TRACE_PROBE, "Probing generic UVC device %s\n",
udev->devpath);之后,我们配置了CONFIG_USB_VIDEO_CLASS=y。make -j3 all返回以下内容:

内核版本: 6.2.7
我做错了什么?我试图通过在互联网上进行研究和咨询其他来源来解决这个问题,但不幸的是,我的努力没有成功。我也尝试使用uvc_probe和UVC_DBG_PROBE,但是它导致了更多的错误。如果有人能帮我那就太好了。
发布于 2023-03-22 11:43:23
如果您正在脱离当前的主流内核,那么LFD103课程就有点过时了,或者更确切地说,它不像可能的那样清晰。您必须只添加pr_info行,忽略它周围的行;因此,对于今天的内核,结果是
static int uvc_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct uvc_device *dev;
const struct uvc_device_info *info =
(const struct uvc_device_info *)id->driver_info;
int function;
int ret;
pr_info("I changed uvcvideo driver in the Linux Kernel\n");
/* Allocate memory for the device and initialize it. */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL)
return -ENOMEM;对uvc_trace行进行了修改,并进一步降低了功能;它们现在使用的是uvc_dbg:
if (id->idVendor && id->idProduct)
uvc_dbg(dev, PROBE, "Probing known UVC device %s (%04x:%04x)\n",
udev->devpath, id->idVendor, id->idProduct);
else
uvc_dbg(dev, PROBE, "Probing generic UVC device %s\n",
udev->devpath);https://unix.stackexchange.com/questions/740557
复制相似问题