Simple Read operation on a misc device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For the Eudyptula's Chanllenge Task 6, i need to write a misc device
driver with simple read/write operations.
 The following was the answer to part of my code:

> static char eid[] = EUDYPTULAID;
>
> static ssize_t misc_device_read(struct file *file, char __user *buf,
>                                         size_t count, loff_t *ppos)
> {
>         if (*ppos == sizeof(eid))
>                 return 0;
>         else
>                 if (*ppos != 0 || count < sizeof(eid))
>                         return -EINVAL;
>
>         if (copy_to_user(buf, eid, sizeof(eid)))
>                 return -EINVAL;
>
>         *ppos = sizeof(eid);
>
>         return *ppos;
> }

This whole function can be made much more "simple" and reduced to one
single line {hint} (It's just a "simple" function call {hint}).

Anyone know that "single" function?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux