AnsweredAssumed Answered

error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]

Question asked by Santhosh Kumar on Aug 21, 2019
Latest reply on Aug 22, 2019 by Santhosh Kumar

Hi,

I am getting this error, I dont know for what reason i am getting this error, works for when compiled for PC

doesnt work when compiled for i.mx8mmini

------------------------------------------Error------------------------------------------------------

error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
   .write=device_write,
          ^~~~~~~~~~~~
/home/santhosh/Desktop/IP_Camera/App_development/Driver/imx8mmini_gpio_platformdevice.c:280:10: note: (near initialization for 'Fops.write')
/home/santhosh/Desktop/IP_Camera/App_development/Driver/imx8mmini_gpio_platformdevice.c:283:19: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
   .unlocked_ioctl=gpio_ioctl

--------------------------------------------------------------------------------------------------------------

 

The code is for quick reference

-------------------------------------start-code--------------------------------------------------------

struct file_operations Fops =
{
      .owner            =    THIS_MODULE,
      .read            =    device_read,
      .write            =    device_write,
      .open            =    device_open,
      .release        =    device_release,
      .unlocked_ioctl    =    gpio_ioctl
};

static int device_open(struct inode *inode, struct file *file)
{
  return 0;
}
static int device_release(struct inode *inode, struct file *file)
{
  return 0;
}
static ssize_t device_read(struct file *file, char __user *buffer, size_t length, loff_t * offset)
{
    return 0;
}
//static ssize_t device_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos)
static ssize_t device_write(struct file *file, char __user *buffer, size_t length, loff_t * offset)
{
  return 0;
}

 

int gpio_ioctl(struct file *file, unsigned int ioctl_num, unsigned long ioctl_param)
{

    return 0;

}

------------------------------------------------end-Code-----------------------------------------------------------

How can i resolve this issue

 

Regards

Santhosh

Outcomes