我从这个网站获得了以下代码,所以我正在尝试它,但每次编译时我都会收到一个错误。错误说“意外令牌附近的语法错误”GPL“。
我不知道这意味着什么,但他们说它有效。有没有一种特殊的方式应该编译?
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/list.h>
MODULE_LICENSE("GPL");
int ourinitmodule(void)
{
int chix = 0;
struct usb_device *dev, *childdev = NULL;
struct usb_bus *bus = NULL;
list_for_each_entry(bus, &usb_bus_list, bus_list)
{
printk("\n USB Bus : %d", bus->busnum);
dev = bus->root_hub;
printk("\n Vendor Id:%x, Product Id:%x\n", dev->descriptor.idVendor, dev- > descriptor.idProduct);
#if 0 //usb_hub_for_each_child macro not supported in 3.2.0, so trying with 3.7.6.
usb_hub_for_each_child(dev, chix, childdev)
{
if(childdev)
{
printk("\n Vendor Id:%x, Product Id:%x\n", childdev->descriptor.idVendor, childdev- >descriptor.idProduct);
}
}
#endif
}
printk(KERN_ALERT "\n Hello Jay, Welcome to sample application.... \n");
return 0;
}
void ourcleanupmodule(void)
{
printk(KERN_ALERT "\n Hello Jay, Thanks....Exiting Application. \n");
return;
}
module_init(ourinitmodule);
module_exit(ourcleanupmodule);