All of lore.kernel.org
 help / color / mirror / Atom feed
From: agimenez@sysvalve.es (L. Alberto Giménez)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Simple Read operation on a misc device driver
Date: Sat, 19 Apr 2014 18:44:12 +0200	[thread overview]
Message-ID: <20140419164411.GA20856@bart.evergreen.loc> (raw)
In-Reply-To: <20140418213553.GA3211@kroah.com>

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

  reply	other threads:[~2014-04-19 16:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-04-19 18:18     ` Fernando Apesteguía

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140419164411.GA20856@bart.evergreen.loc \
    --to=agimenez@sysvalve.es \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.