* [PATCH 1/5] usb: musb: dsps: Do not use priv pointer
2015-04-28 11:05 AM335x fixes Sascha Hauer
@ 2015-04-28 11:05 ` Sascha Hauer
2015-04-28 11:05 ` [PATCH 2/5] usb: musb: set controller->priv pointer Sascha Hauer
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-04-28 11:05 UTC (permalink / raw)
To: Barebox List
Use container_of instead of dev->priv pointer. dev->priv is
used by the musb core layer (which maybe should not be the
case, but using container_of is good anyway).
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/musb/musb_dsps.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 36a316a..7bad1f8 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -129,14 +129,17 @@ struct dsps_glue {
struct musb_hdrc_platform_data pdata;
};
+static struct dsps_glue *to_dsps_glue(struct musb *musb)
+{
+ return container_of(musb, struct dsps_glue, musb);
+}
+
/**
* dsps_musb_enable - enable interrupts
*/
static void dsps_musb_enable(struct musb *musb)
{
- struct device_d *dev = musb->controller;
- struct device_d *pdev = dev;
- struct dsps_glue *glue = pdev->priv;
+ struct dsps_glue *glue = to_dsps_glue(musb);
const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base;
u32 epmask, coremask;
@@ -158,9 +161,7 @@ static void dsps_musb_enable(struct musb *musb)
*/
static void dsps_musb_disable(struct musb *musb)
{
- struct device_d *dev = musb->controller;
- struct device_d *pdev = dev;
- struct dsps_glue *glue = pdev->priv;
+ struct dsps_glue *glue = to_dsps_glue(musb);
const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base;
@@ -173,8 +174,7 @@ static void dsps_musb_disable(struct musb *musb)
static irqreturn_t dsps_interrupt(struct musb *musb)
{
void __iomem *reg_base = musb->ctrl_base;
- struct device_d *dev = musb->controller;
- struct dsps_glue *glue = dev->priv;
+ struct dsps_glue *glue = to_dsps_glue(musb);
const struct dsps_musb_wrapper *wrp = glue->wrp;
unsigned long flags;
irqreturn_t ret = IRQ_NONE;
@@ -213,8 +213,7 @@ out:
static int dsps_musb_init(struct musb *musb)
{
- struct device_d *dev = musb->controller;
- struct dsps_glue *glue = dev->priv;
+ struct dsps_glue *glue = to_dsps_glue(musb);
const struct dsps_musb_wrapper *wrp = glue->wrp;
u32 rev, val, mode;
@@ -377,8 +376,6 @@ static int dsps_probe(struct device_d *dev)
glue->dev = dev;
glue->wrp = wrp;
- dev->priv = glue;
-
pdata = &glue->pdata;
glue->musb.mregs = dev_request_mem_region(dev, 0);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] usb: musb: set controller->priv pointer
2015-04-28 11:05 AM335x fixes Sascha Hauer
2015-04-28 11:05 ` [PATCH 1/5] usb: musb: dsps: Do not use priv pointer Sascha Hauer
@ 2015-04-28 11:05 ` Sascha Hauer
2015-04-28 11:05 ` [PATCH 3/5] net: phy: Add missing phy_unregister_device Sascha Hauer
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-04-28 11:05 UTC (permalink / raw)
To: Barebox List
This is used by the detect callback but never initialized.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/musb/musb_barebox.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/musb_barebox.c b/drivers/usb/musb/musb_barebox.c
index 6bc232b..b1f38c3 100644
--- a/drivers/usb/musb/musb_barebox.c
+++ b/drivers/usb/musb/musb_barebox.c
@@ -139,6 +139,7 @@ int musb_register(struct musb *musb)
host->submit_control_msg = submit_control_msg;
host->submit_bulk_msg = submit_bulk_msg;
+ musb->controller->priv = musb;
musb->controller->detect = musb_detect;
usb_register_host(host);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] net: phy: Add missing phy_unregister_device
2015-04-28 11:05 AM335x fixes Sascha Hauer
2015-04-28 11:05 ` [PATCH 1/5] usb: musb: dsps: Do not use priv pointer Sascha Hauer
2015-04-28 11:05 ` [PATCH 2/5] usb: musb: set controller->priv pointer Sascha Hauer
@ 2015-04-28 11:05 ` Sascha Hauer
2015-04-28 11:05 ` [PATCH 4/5] eth: halt active ethernet device on unregister Sascha Hauer
2015-04-28 11:05 ` [PATCH 5/5] net: cpsw: unregister device on remove callback Sascha Hauer
4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-04-28 11:05 UTC (permalink / raw)
To: Barebox List
The counterpart of phy_register_device is missing. Add it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/phy/phy.c | 11 +++++++++++
include/linux/phy.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index f3dffca..edf5d03 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -272,6 +272,17 @@ int phy_register_device(struct phy_device *phydev)
return ret;
}
+void phy_unregister_device(struct phy_device *phydev)
+{
+ if (!phydev->registered)
+ return;
+
+ phydev->bus->phy_map[phydev->addr] = NULL;
+
+ unregister_device(&phydev->dev);
+ phydev->registered = 0;
+}
+
static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
{
struct device_d *dev;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index c0fd4ff..9a451a6 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -266,6 +266,7 @@ int phy_init(void);
int phy_init_hw(struct phy_device *phydev);
int phy_register_device(struct phy_device* dev);
+void phy_unregister_device(struct phy_device *phydev);
/**
* phy_read - Convenience function for reading a given PHY register
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] eth: halt active ethernet device on unregister
2015-04-28 11:05 AM335x fixes Sascha Hauer
` (2 preceding siblings ...)
2015-04-28 11:05 ` [PATCH 3/5] net: phy: Add missing phy_unregister_device Sascha Hauer
@ 2015-04-28 11:05 ` Sascha Hauer
2015-04-28 11:05 ` [PATCH 5/5] net: cpsw: unregister device on remove callback Sascha Hauer
4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-04-28 11:05 UTC (permalink / raw)
To: Barebox List
When an active ethernet device is unregistered it should
be halted to quiesce the device.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
net/eth.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/eth.c b/net/eth.c
index 89bddba..0c1ff73 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -385,6 +385,9 @@ void eth_unregister(struct eth_device *edev)
if (edev == eth_current)
eth_current = NULL;
+ if (edev->active)
+ edev->halt(edev);
+
if (IS_ENABLED(CONFIG_OFDEVICE))
free(edev->nodepath);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] net: cpsw: unregister device on remove callback
2015-04-28 11:05 AM335x fixes Sascha Hauer
` (3 preceding siblings ...)
2015-04-28 11:05 ` [PATCH 4/5] eth: halt active ethernet device on unregister Sascha Hauer
@ 2015-04-28 11:05 ` Sascha Hauer
4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2015-04-28 11:05 UTC (permalink / raw)
To: Barebox List
The CPSW uses DMA, so we should quiesce the device before leaving
barebox. This patch unregisters the CPSW properly on the device
remove callback. To do this we have to fix the error path in
cpsw_slave_setup, since this function can fail and we need a
known slave status in the remove function.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 44 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 7687254..c0db96b 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -916,20 +916,22 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
struct phy_device *phy;
phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
- if (IS_ERR(phy))
- return PTR_ERR(phy);
+ if (IS_ERR(phy)) {
+ ret = PTR_ERR(phy);
+ goto err_out;
+ }
phy->dev.device_node = priv->slaves[slave_num].dev.device_node;
ret = phy_register_device(phy);
if (ret)
- return ret;
+ goto err_out;
sprintf(dev->name, "cpsw-slave");
dev->id = slave->slave_num;
dev->parent = priv->dev;
ret = register_device(dev);
if (ret)
- return ret;
+ goto err_register_dev;
dev_dbg(&slave->dev, "* %s\n", __func__);
@@ -948,7 +950,20 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
edev->set_ethaddr = cpsw_set_hwaddr;
edev->parent = dev;
- return eth_register(edev);
+ ret = eth_register(edev);
+ if (ret)
+ goto err_register_edev;
+
+ return 0;
+
+err_register_dev:
+ phy_unregister_device(phy);
+err_register_edev:
+ unregister_device(dev);
+err_out:
+ slave->slave_num = -1;
+
+ return ret;
}
struct cpsw_data {
@@ -1219,6 +1234,8 @@ int cpsw_probe(struct device_d *dev)
}
}
+ dev->priv = priv;
+
return 0;
out:
free(priv->slaves);
@@ -1227,6 +1244,22 @@ out:
return ret;
}
+static void cpsw_remove(struct device_d *dev)
+{
+ struct cpsw_priv *priv = dev->priv;
+ int i;
+
+ for (i = 0; i < priv->num_slaves; i++) {
+ struct cpsw_slave *slave = &priv->slaves[i];
+ if (slave->slave_num < 0)
+ continue;
+
+ eth_unregister(&slave->edev);
+ }
+
+ mdiobus_unregister(&priv->miibus);
+}
+
static __maybe_unused struct of_device_id cpsw_dt_ids[] = {
{
.compatible = "ti,cpsw",
@@ -1238,6 +1271,7 @@ static __maybe_unused struct of_device_id cpsw_dt_ids[] = {
static struct driver_d cpsw_driver = {
.name = "cpsw",
.probe = cpsw_probe,
+ .remove = cpsw_remove,
.of_compatible = DRV_OF_COMPAT(cpsw_dt_ids),
};
device_platform_driver(cpsw_driver);
--
2.1.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread