From: Greg KH <greg@kroah.com>
To: linux-usb-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] USB and Driver Core patches for 2.6.10
Date: Fri, 7 Jan 2005 21:47:49 -0800 [thread overview]
Message-ID: <11051632692510@kroah.com> (raw)
In-Reply-To: <11051632683091@kroah.com>
ChangeSet 1.1938.446.45, 2004/12/20 14:20:30-08:00, stern@rowland.harvard.edu
[PATCH] USB: Create usb_hcd structures within usbcore [6/13]
This patch alters the dummy_hcd driver, removing the routine that
allocates the hcd structure and introducing inline functions to convert
safely between the public and private hcd structures.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/usb/gadget/dummy_hcd.c | 44 +++++++++++++----------------------------
1 files changed, 14 insertions(+), 30 deletions(-)
diff -Nru a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
--- a/drivers/usb/gadget/dummy_hcd.c 2005-01-07 15:43:14 -08:00
+++ b/drivers/usb/gadget/dummy_hcd.c 2005-01-07 15:43:14 -08:00
@@ -149,7 +149,6 @@
};
struct dummy {
- struct usb_hcd hcd; /* must come first! */
spinlock_t lock;
/*
@@ -178,12 +177,17 @@
static inline struct dummy *hcd_to_dummy (struct usb_hcd *hcd)
{
- return container_of(hcd, struct dummy, hcd);
+ return (struct dummy *) (hcd->hcd_priv);
+}
+
+static inline struct usb_hcd *dummy_to_hcd (struct dummy *dum)
+{
+ return container_of((void *) dum, struct usb_hcd, hcd_priv);
}
static inline struct device *dummy_dev (struct dummy *dum)
{
- return dum->hcd.self.controller;
+ return dummy_to_hcd(dum)->self.controller;
}
static inline struct dummy *ep_to_dummy (struct dummy_ep *ep)
@@ -1368,7 +1372,7 @@
ep->already_seen = ep->setup_stage = 0;
spin_unlock (&dum->lock);
- usb_hcd_giveback_urb (&dum->hcd, urb, 0);
+ usb_hcd_giveback_urb (dummy_to_hcd(dum), urb, 0);
spin_lock (&dum->lock);
goto restart;
@@ -1570,20 +1574,6 @@
/*-------------------------------------------------------------------------*/
-static struct usb_hcd *dummy_alloc (void)
-{
- struct dummy *dum;
-
- dum = kmalloc (sizeof *dum, SLAB_KERNEL);
- if (dum == NULL)
- return NULL;
- the_controller = dum;
- memset (dum, 0, sizeof *dum);
- return &dum->hcd;
-}
-
-/*-------------------------------------------------------------------------*/
-
static inline ssize_t
show_urb (char *buf, size_t size, struct urb *urb)
{
@@ -1711,13 +1701,14 @@
static const struct hc_driver dummy_hcd = {
.description = (char *) driver_name,
+ .product_desc = "Dummy host controller",
+ .hcd_priv_size = sizeof(struct dummy),
+
.flags = HCD_USB2,
.start = dummy_start,
.stop = dummy_stop,
- .hcd_alloc = dummy_alloc,
-
.urb_enqueue = dummy_urb_enqueue,
.urb_dequeue = dummy_urb_dequeue,
@@ -1737,7 +1728,7 @@
dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
- hcd = dummy_alloc ();
+ hcd = usb_create_hcd (&dummy_hcd);
if (hcd == NULL) {
dev_dbg (dev, "hcd_alloc failed\n");
return -ENOMEM;
@@ -1745,9 +1736,8 @@
dev_set_drvdata (dev, hcd);
dum = hcd_to_dummy (hcd);
+ the_controller = dum;
- hcd->driver = (struct hc_driver *) &dummy_hcd;
- hcd->description = dummy_hcd.description;
hcd->self.controller = dev;
/* FIXME don't require the pci-based buffer/alloc impls;
@@ -1760,13 +1750,7 @@
goto err1;
}
- usb_bus_init (&hcd->self);
- hcd->self.op = &usb_hcd_operations;
- hcd->self.release = &usb_hcd_release;
- hcd->self.hcpriv = hcd;
hcd->self.bus_name = dev->bus_id;
- hcd->product_desc = "Dummy host controller";
-
usb_register_bus (&hcd->self);
if ((retval = dummy_start (hcd)) < 0)
@@ -1774,7 +1758,7 @@
return retval;
err1:
- kfree (hcd);
+ usb_put_hcd (hcd);
dev_set_drvdata (dev, NULL);
return retval;
}
next prev parent reply other threads:[~2005-01-08 6:26 UTC|newest]
Thread overview: 103+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-08 5:46 [BK PATCH] USB and Driver Core patches for 2.6.10 Greg KH
2005-01-08 5:47 ` [PATCH] " Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH [this message]
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 5:47 ` Greg KH
2005-01-08 12:08 ` Christoph Hellwig
2005-01-08 22:42 ` Greg KH
2005-01-08 23:33 ` Alessandro Suardi
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=11051632692510@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
/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).