mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 6/6] USB storage: fix disconnect
Date: Wed, 15 Feb 2012 09:04:04 +0100	[thread overview]
Message-ID: <1329293044-9967-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1329293044-9967-1-git-send-email-s.hauer@pengutronix.de>

USB storage support missed disconnect support. Implement this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/storage/usb.c |   23 ++++++-----------------
 drivers/usb/storage/usb.h |    1 +
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 865ba8e..5f15464 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -415,7 +415,7 @@ static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
 	if (result != 0)
 		dev_warn(dev, "No partition table found\n");
 
-	list_add_tail(&pblk_dev->list, &us_blkdev_list);
+	list_add_tail(&pblk_dev->list, &us->blk_dev_list);
 	US_DEBUGP("USB disk device successfully added\n");
 
 	return 0;
@@ -556,6 +556,7 @@ static int usb_stor_probe(struct usb_device *usbdev,
 	us->ifnum = intf->bInterfaceNumber;
 	us->subclass = intf->bInterfaceSubClass;
 	us->protocol = intf->bInterfaceProtocol;
+	INIT_LIST_HEAD(&us->blk_dev_list);
 
 	/* get standard transport and protocol settings */
 	get_transport(us);
@@ -582,30 +583,18 @@ BadDevice:
 /* Handle a USB mass-storage disconnect */
 static void usb_stor_disconnect(struct usb_device *usbdev)
 {
-#if 0
 	struct us_data *us = (struct us_data *)usbdev->drv_data;
 	struct us_blk_dev *bdev, *bdev_tmp;
 
-	US_DEBUGP("Disconnecting USB Mass Storage device %s\n",
-	          usbdev->dev.name);
-
-	/* release all block devices of this mass storage device */
-	list_for_each_entry_safe(bdev, bdev_tmp, &us_blkdev_list, list) {
-		if (bdev->us == us) {
-			US_DEBUGP("Releasing %s\n", bdev->dev.name);
-			list_del(&bdev->list);
-			unregister_device(&bdev->dev);
-			free(bdev);
-		}
+	list_for_each_entry_safe(bdev, bdev_tmp, &us->blk_dev_list, list) {
+		list_del(&bdev->list);
+		blockdevice_unregister(&bdev->blk);
+		free(bdev);
 	}
 
 	/* release device's private data */
 	usbdev->drv_data = 0;
 	free(us);
-#else
-	dev_err(&usbdev->dev, "Disk/partition removal not yet implemented "
-	                      "in the ATA disk driver.");
-#endif
 }
 
 #define USUAL_DEV(use_proto, use_trans, drv_info) \
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 5942393..1b73b00 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -81,6 +81,7 @@ struct us_data {
 
 	/* SCSI interfaces */
 	ccb			*srb;		/* current srb */
+	struct list_head	blk_dev_list;
 };
 
 /* one us_blk_dev object allocated per LUN */
-- 
1.7.9


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-02-15  8:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15  8:03 USB/network unregistration patches Sascha Hauer
2012-02-15  8:03 ` [PATCH 1/6] usb net smsc95xx: remove unused variable Sascha Hauer
2012-02-15  8:04 ` [PATCH 2/6] usb net smsc95xx: add missing mii_unregister Sascha Hauer
2012-02-15  8:04 ` [PATCH 3/6] usb net: fix unregistration Sascha Hauer
2012-02-15  8:04 ` [PATCH 4/6] net: fix eth device unregistration Sascha Hauer
2012-02-15  8:04 ` [PATCH 5/6] net: set enetaddr to invalid address when an invalid string is passed Sascha Hauer
2012-02-15  8:04 ` Sascha Hauer [this message]

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=1329293044-9967-7-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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