linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: sysfs attribute example
Date: Tue, 14 Jun 2005 00:54:03 +0000	[thread overview]
Message-ID: <20050614005403.GA17180@kroah.com> (raw)
In-Reply-To: <NDBBIKDDCLAGMMFDHHDBGEODDAAA.stephenm@glw.com>

On Mon, Jun 13, 2005 at 06:01:26PM -0500, Stephen Morgan wrote:
> > -----Original Message-----
> > From: Kay Sievers [mailto:kay.sievers@vrfy.org]
> > Sent: Friday, June 10, 2005 11:10 AM
> > To: Stephen Morgan
> > Cc: linux-hotplug-devel
> > Subject: Re: sysfs attribute example
> >
> >
> > On Fri, Jun 10, 2005 at 12:05:07PM -0500, Stephen Morgan wrote:
> > > Hello all,
> > >
> > > Can someone point me to an example of exporting a sysfs attribute from a
> > > driver?  (Or tell me if I shouldn't.)  I'm trying to get a
> > value from my USB
> > > device driver's probe() into an attribute so my udev .rules
> > file can pick it
> > > up.
> > >
> > > I've tried to follow what's in LDD 3rd ed. (page 374)
> > "...simply fill in an
> > > attribute and pass it to sysfs_create_file()"
> > >
> > > From my probe() function:
> > >
> > >   mydev->my_attribute.name = "my_attribute_name";
> > >   mydev->my_attribute.owner = THIS_MODULE;
> > >   mydev->my_attribute.mode = S_IRUGO;
> > >
> > >   sysfs_create_file(&(interface->class_dev->kobj),
> > &(mydev->my_attribute));
> > >
> > > When a device is probed, the file "my_attribute_name" shows up
> > in sysfs, but
> > > I get a "kernel NULL pointer dereference at virtual address 00000004"
> > > (address changes with the USB port I plug into).
> > >
> > > I'm also not seeing how to attach a value to the attribute.
> > So, clearly,
> > > I'm missing something crucial here :-)
> >
> > Sure, you do. :)
> >
> > Look for: DEVICE_ATTR() in the kernel code.
> >
> > Good luck,
> > Kay
> >
> 
> Hi Kay,
> 
> Thanks for your help.
> 
> This has gotten me much closer.  However, the show() function seems to be
> receiving a pointer to the usb_interface's class_device instead of its
> device.  Any ideas why?

Because that's where you registered the attribute?  :)

Care to show us your patch?

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r 
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

  parent reply	other threads:[~2005-06-14  0:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-10 17:05 sysfs attribute example Stephen Morgan
2005-06-10 17:10 ` Kay Sievers
2005-06-13 23:01 ` Stephen Morgan
2005-06-14  0:54 ` Greg KH [this message]
2005-06-16 17:09 ` Stephen Morgan
2005-06-16 17:27 ` Greg KH
2005-06-16 21:14 ` Stephen Morgan

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=20050614005403.GA17180@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-hotplug@vger.kernel.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 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).