* USB/network unregistration patches
@ 2012-02-15 8:03 Sascha Hauer
2012-02-15 8:03 ` [PATCH 1/6] usb net smsc95xx: remove unused variable Sascha Hauer
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:03 UTC (permalink / raw)
To: barebox
Registering devices works fine on barebox, unregistration often not so.
This series cleans up unregistration of network/USB devices.
Sascha Hauer (6):
usb net smsc95xx: remove unused variable
usb net smsc95xx: add missing mii_unregister
usb net: fix unregistration
net: fix eth device unregistration
net: set enetaddr to invalid address when an invalid string is passed
USB storage: fix disconnect
drivers/net/usb/smsc95xx.c | 7 +++----
drivers/net/usb/usbnet.c | 6 ++----
drivers/usb/storage/usb.c | 23 ++++++-----------------
drivers/usb/storage/usb.h | 1 +
net/eth.c | 5 ++++-
net/net.c | 6 ++++--
6 files changed, 20 insertions(+), 28 deletions(-)
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] usb net smsc95xx: remove unused variable
2012-02-15 8:03 USB/network unregistration patches Sascha Hauer
@ 2012-02-15 8:03 ` Sascha Hauer
2012-02-15 8:04 ` [PATCH 2/6] usb net smsc95xx: add missing mii_unregister Sascha Hauer
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:03 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/usb/smsc95xx.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index b518992..f2a2d00 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -722,8 +722,6 @@ static int smsc95xx_reset(struct usbnet *dev)
return 0;
}
-static struct usbnet *usbnet_global;
-
static int smsc95xx_bind(struct usbnet *dev)
{
struct smsc95xx_priv *pdata = NULL;
@@ -767,8 +765,6 @@ static void smsc95xx_unbind(struct usbnet *dev)
pdata = NULL;
dev->data[0] = 0;
}
-
- usbnet_global = NULL;
}
static int smsc95xx_rx_fixup(struct usbnet *dev, void *buf, int len)
--
1.7.9
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/6] usb net smsc95xx: add missing mii_unregister
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 ` Sascha Hauer
2012-02-15 8:04 ` [PATCH 3/6] usb net: fix unregistration Sascha Hauer
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/usb/smsc95xx.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index f2a2d00..c21705e 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -759,6 +759,9 @@ static int smsc95xx_bind(struct usbnet *dev)
static void smsc95xx_unbind(struct usbnet *dev)
{
struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
+
+ mii_unregister(&dev->miidev);
+
if (pdata) {
netif_dbg(dev, ifdown, dev->net, "free pdata\n");
free(pdata);
--
1.7.9
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/6] usb net: fix unregistration
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 ` Sascha Hauer
2012-02-15 8:04 ` [PATCH 4/6] net: fix eth device unregistration Sascha Hauer
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:04 UTC (permalink / raw)
To: barebox
First call mii_unregister which is done in the drivers unbind function,
then eth_unregister. Also, remove unregister_device which is done in
eth_unregister.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/usb/usbnet.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 5ffd7a6..c7e3606 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -235,13 +235,11 @@ void usbnet_disconnect(struct usb_device *usbdev)
struct eth_device *edev = &undev->edev;
struct driver_info *info;
- eth_unregister(edev);
- unregister_device(&edev->dev);
-
info = undev->driver_info;
if (info->unbind)
info->unbind(undev);
+ eth_unregister(edev);
+
free(undev);
}
-
--
1.7.9
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/6] net: fix eth device unregistration
2012-02-15 8:03 USB/network unregistration patches Sascha Hauer
` (2 preceding siblings ...)
2012-02-15 8:04 ` [PATCH 3/6] usb net: fix unregistration Sascha Hauer
@ 2012-02-15 8:04 ` 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 ` [PATCH 6/6] USB storage: fix disconnect Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:04 UTC (permalink / raw)
To: barebox
We register a device in eth_register, thus we have to unregister it in
eth_unregister. Also, if the device we unregister is the current device,
we have to set the current eth_device to NULL so that it isn't used anymore.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/eth.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/net/eth.c b/net/eth.c
index 621cb59..20fdbf4 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -244,8 +244,11 @@ int eth_register(struct eth_device *edev)
void eth_unregister(struct eth_device *edev)
{
- dev_remove_parameters(&edev->dev);
+ if (edev == eth_current)
+ eth_current = NULL;
+ dev_remove_parameters(&edev->dev);
+ unregister_device(&edev->dev);
list_del(&edev->list);
}
--
1.7.9
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/6] net: set enetaddr to invalid address when an invalid string is passed
2012-02-15 8:03 USB/network unregistration patches Sascha Hauer
` (3 preceding siblings ...)
2012-02-15 8:04 ` [PATCH 4/6] net: fix eth device unregistration Sascha Hauer
@ 2012-02-15 8:04 ` Sascha Hauer
2012-02-15 8:04 ` [PATCH 6/6] USB storage: fix disconnect Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:04 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/net.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/net.c b/net/net.c
index 26ba44e..2752884 100644
--- a/net/net.c
+++ b/net/net.c
@@ -166,8 +166,10 @@ int string_to_ethaddr(const char *str, char *enetaddr)
int reg;
char *e;
- if (!str || strlen(str) != 17)
- return -1;
+ if (!str || strlen(str) != 17) {
+ memset(enetaddr, 0, 6);
+ return -1;
+ }
if (str[2] != ':' || str[5] != ':' || str[8] != ':' ||
str[11] != ':' || str[14] != ':')
--
1.7.9
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/6] USB storage: fix disconnect
2012-02-15 8:03 USB/network unregistration patches Sascha Hauer
` (4 preceding siblings ...)
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
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2012-02-15 8:04 UTC (permalink / raw)
To: barebox
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-02-15 8:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 6/6] USB storage: fix disconnect Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox