From mboxrd@z Thu Jan 1 00:00:00 1970 From: agimenez@sysvalve.es (=?iso-8859-1?Q?L=2E_Alberto_Gim=E9nez?=) Date: Sat, 19 Apr 2014 18:44:12 +0200 Subject: Simple Read operation on a misc device driver In-Reply-To: <20140418213553.GA3211@kroah.com> References: <20140418213553.GA3211@kroah.com> Message-ID: <20140419164411.GA20856@bart.evergreen.loc> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Fri, Apr 18, 2014 at 02:35:53PM -0700, Greg KH wrote: > On Fri, Apr 18, 2014 at 06:30:44PM -0300, Aldo Esteban Paz wrote: > > 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? > > Yes, but you really should do your own research for stuff like this, > that's what the challenge is all about, not asking others to do it for > you :( I'm curious about this. I didn't get the simple, one-line function call feedback and my task was accepted with a regular function definition, similar to the one from the OP. -- L. Alberto Gim?nez GnuPG key ID 0xDD4E27AB