linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Matt_Domsch@Dell.com
Cc: mdharm-usb@one-eyed-alien.net, mochel@osdl.org,
	linux-kernel@vger.kernel.org
Subject: Re: devicefs requests
Date: Thu, 26 Sep 2002 21:41:05 -0700	[thread overview]
Message-ID: <20020927044104.GA8728@kroah.com> (raw)
In-Reply-To: <20BF5713E14D5B48AA289F72BD372D68C1E8C5@AUSXMPC122.aus.amer.dell.com>

On Thu, Sep 26, 2002 at 11:13:37AM -0500, Matt_Domsch@Dell.com wrote:
> 
> What I'm picturing is something like this (feedback welcome!):

<nice picture snipped>

Yes, I think this is a nice goal, and that driverfs is the right way to
do this.  But you might want to walk the bus lists of the different
devices a bit differently.  Here's a small example of how to walk all of
the USB devices in a system, and see if they match a specific vendor_id
and product_id:


static int match_device (struct usb_device *dev)
{
	int retval = -ENODEV;
	int child;

	dbg ("looking at vendor %d, product %d\n",
	dev->descriptor.idVendor,
	dev->descriptor.idProduct);

	/* see if this device matches */
	if ((dev->descriptor.idVendor == vendor_id) &&
	    (dev->descriptor.idProduct == product_id)) {
		dbg ("found the device!\n");
		retval = 0;
		goto exit;
	}

	/* look through all of the children of this device */
	for (child = 0; child < dev->maxchild; ++child) {
		if (dev->children[child]) {
			retval = match_device (dev->children[child]);
			if (retval == 0)
				goto exit;
		}
	}
exit:
	return retval;
}

static int find_usb_device (void)
{
	struct list_head *buslist;
	struct usb_bus *bus;
	int retval = -ENODEV;

	down (&usb_bus_list_lock);
	for (buslist = usb_bus_list.next;
		buslist != &usb_bus_list; 
		buslist = buslist->next) {
		bus = container_of (buslist, struct usb_bus, bus_list);
		retval = match_device(bus->root_hub);
		if (retval == 0)
			goto exit;
		}
exit:
	up (&usb_bus_list_lock);
	return retval;
}

I think usb_bus_list_lock and usb_bus_list needs to be exported for
these functions to work outside of the USB core, but if you need them,
I'd don't have a problem with exporting them.

Doing something like this might be easier than trying to get the driver
core to let you walk all of its devices.  But Pat could answer that
better than I could.

Good luck,

greg k-h

  reply	other threads:[~2002-09-27  4:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-26 16:13 Matt_Domsch
2002-09-27  4:41 ` Greg KH [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-09-26  3:48 Matt_Domsch
2002-09-26  4:14 ` Greg KH
2002-09-26 14:41   ` Randy.Dunlap
2002-09-25 22:11 Matt_Domsch
2002-09-25 22:03 Matt_Domsch
2002-09-25 22:46 ` Greg KH
2002-10-01  1:39 ` Patrick Mochel
2002-09-25 19:28 Matt_Domsch
2002-09-25 21:33 ` Greg KH
2002-09-25 21:33 ` Greg KH
2002-10-01  1:32 ` Patrick Mochel

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=20020927044104.GA8728@kroah.com \
    --to=greg@kroah.com \
    --cc=Matt_Domsch@Dell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=mochel@osdl.org \
    --subject='Re: devicefs requests' \
    /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

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).