* Simple Read operation on a misc device driver
@ 2014-04-18 21:30 Aldo Esteban Paz
2014-04-18 21:35 ` Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Aldo Esteban Paz @ 2014-04-18 21:30 UTC (permalink / raw)
To: kernelnewbies
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Simple Read operation on a misc device driver
2014-04-18 21:30 Simple Read operation on a misc device driver Aldo Esteban Paz
@ 2014-04-18 21:35 ` Greg KH
2014-04-19 16:44 ` L. Alberto Giménez
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2014-04-18 21:35 UTC (permalink / raw)
To: kernelnewbies
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 :(
^ permalink raw reply [flat|nested] 4+ messages in thread
* Simple Read operation on a misc device driver
2014-04-18 21:35 ` Greg KH
@ 2014-04-19 16:44 ` L. Alberto Giménez
2014-04-19 18:18 ` Fernando Apesteguía
0 siblings, 1 reply; 4+ messages in thread
From: L. Alberto Giménez @ 2014-04-19 16:44 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Simple Read operation on a misc device driver
2014-04-19 16:44 ` L. Alberto Giménez
@ 2014-04-19 18:18 ` Fernando Apesteguía
0 siblings, 0 replies; 4+ messages in thread
From: Fernando Apesteguía @ 2014-04-19 18:18 UTC (permalink / raw)
To: kernelnewbies
El 19/04/2014 18:52, "L. Alberto Gim?nez" <agimenez@sysvalve.es> escribi?:
>
> 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.
That feedback may come in the next tasks ;)
>
> --
> L. Alberto Gim?nez
> GnuPG key ID 0xDD4E27AB
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140419/29301043/attachment.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-19 18:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-18 21:30 Simple Read operation on a misc device driver Aldo Esteban Paz
2014-04-18 21:35 ` Greg KH
2014-04-19 16:44 ` L. Alberto Giménez
2014-04-19 18:18 ` Fernando Apesteguía
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).