如何修复Android三星Note 3手机嵌入式设备驱动程序C代码中的指针错误?

如何修复Android三星Note 3手机嵌入式设备驱动程序C代码中的指针错误?,android,module,linux-kernel,device-driver,Android,Module,Linux Kernel,Device Driver,我试图将第2段中的代码编译为设备驱动程序,但我得到了以下错误。你知道我为什么会出现这个错误,以及如何修复它吗 drivers/char/tbt/tbt.c:61:1: error: unknown field 'ioctl' specified in initializer drivers/char/tbt/tbt.c:61:1: warning: initialization from incompatible pointer type [enabled by default] #inclu

我试图将第2段中的代码编译为设备驱动程序,但我得到了以下错误。你知道我为什么会出现这个错误,以及如何修复它吗

drivers/char/tbt/tbt.c:61:1: error: unknown field 'ioctl' specified in initializer
drivers/char/tbt/tbt.c:61:1: warning: initialization from incompatible pointer type [enabled by default]

#include <linux/module.h>
#include <linux/fs.h>
#define HELLO_MAJOR 234
static int debug_enable = 0;
module_param(debug_enable, int, 0);
MODULE_PARM_DESC(debug_enable, "Enable module debug mode.");
struct file_operations hello_fops;
static int hello_open(struct inode *inode, struct file *file)
{
printk("hello_open: successful\n");
return 0;
}
static int hello_release(struct inode *inode, struct file *file)
{
printk("hello_release: successful\n");
return 0;
}
static ssize_t hello_read(struct file *file, char *buf, size_t count,
loff_t *ptr)
{
printk("hello_read: returning zero bytes\n");
return 0;
}
static ssize_t hello_write(struct file *file, const char *buf,
size_t count, loff_t * ppos)
{
printk("hello_read: accepting zero bytes\n");
return 0;
}
static long hello_ioctl(struct file *filep,
  unsigned  int cmd, unsigned long arg)

{
  printk("hello_ioctl: cmd=%ld, arg=%ld\n", cmd, arg);
  return 0;
}
static int __init hello_init(void)
{
  int ret;
  printk("Hello Example Init - debug mode is %s\n",
  debug_enable ? "enabled" : "disabled");
  ret = register_chrdev(HELLO_MAJOR, "hello1", &hello_fops);
  if (ret < 0) {
  printk("Error registering hello device\n");
  goto hello_fail1;
}
printk("Hello: registered module successfully!\n");
/* Init processing here... */
return 0;
hello_fail1:
return ret;
}
  static void __exit hello_exit(void)
{
printk("Hello Example Exit\n");
}
struct file_operations hello_fops = {
owner: THIS_MODULE,
read: hello_read,
write: hello_write,
unloced_ioctl: hello_ioctl,
open: hello_open,
release: hello_release,
};
...
因此,我将以下程序更改如下:

 static long hello_ioctl(struct file *filep,
      unsigned  long cmd, unsigned long arg)

    {
      printk("hello_ioctl: cmd=%ld, arg=%ld\n", cmd, arg);
      return 0;
    }

@nsilent-我起床很长时间了,没有清晰地思考。我现在明白了,将打印类型更改为与正在打印的变量相同才有意义。谢谢你也发现了拼写错误

您可能应该将%ld更改为%u,而不是更改函数的原型。我也相信应该有解锁而不是解锁的ioctl。
 static long hello_ioctl(struct file *filep,
      unsigned  long cmd, unsigned long arg)

    {
      printk("hello_ioctl: cmd=%ld, arg=%ld\n", cmd, arg);
      return 0;
    }