All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: "Rick L. Vinyard, Jr." <rvinyard@cs.nmsu.edu>
Cc: Linux USB <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Purpose of parameter in sysfs binary read
Date: Tue, 18 Aug 2009 08:14:27 -0700	[thread overview]
Message-ID: <20090818151427.GA6295@kroah.com> (raw)
In-Reply-To: <9f97a27ccc13bd63ce99be04018b6bde.squirrel@intranet.cs.nmsu.edu>

On Tue, Aug 18, 2009 at 08:55:29AM -0600, Rick L. Vinyard, Jr. wrote:
> The read function pointer of the sysfs bin_attribute structure has this
> signature:
> 
> ssize_t (*read)(struct kobject *kobj, struct bin_attribute *attr,
>                         char *buf, loff_t offset, size_t size);
> 
> I've figured out the purpose of all the parameters except the loff_t
> parameter.
> 
> Obviously it's an offset of some sort, but what is the meaning of the offset?

The same as any read() call, it comes from the vfs.

> If I have binary data in a char* named bindata of size bsize, should it be
> copied into buf+offset in something like:
>   memcpy(buf+offset, bindata, bsize);
> 
> Or, is it an offset from both buf and bindata in something like:
>   memcpy(buf+offset, bindata+offset, bsize-offset);

What are you using the binary sysfs attribute for?  It should ONLY be
used as a pass-through to and from hardware, with no interpretation by
the kernel at all.

See the existing users of this interface in the kernel for examples of
how to use the offset parameter.

thanks,

greg k-h

  reply	other threads:[~2009-08-18 15:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-18 14:55 Purpose of parameter in sysfs binary read Rick L. Vinyard, Jr.
2009-08-18 15:14 ` Greg KH [this message]
2009-08-18 15:41   ` Rick L. Vinyard, Jr.
2009-08-18 16:02     ` Greg KH
2009-08-18 17:46       ` Rick L. Vinyard, Jr.
2009-08-19 16:05     ` Alan Cox
2009-08-19 17:41       ` Rick L. Vinyard, Jr.
2009-08-19 18:11         ` Greg KH
2009-08-19 18:26           ` Rick L. Vinyard, Jr.
2009-08-19 18:19         ` Alan Cox
2009-08-19 18:25           ` Rick L. Vinyard, Jr.
2009-08-19 18:34             ` Alan Cox
2009-11-25 19:19               ` Rick L. Vinyard, Jr.
2009-11-25 20:09                 ` Alan Cox
2009-12-02 17:06                   ` Dynamically attaching fbcon to a framebuffer Rick L. Vinyard, Jr.
2009-08-25 11:36         ` Purpose of parameter in sysfs binary read Pavel Machek
2009-08-18 15:16 ` Alan Stern
2009-08-18 15:43   ` Rick L. Vinyard, Jr.

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=20090818151427.GA6295@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rvinyard@cs.nmsu.edu \
    /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.