* [RFC PATCH v3 2/5] net: dsa: bcm_sf2: cleanup resources in remove callback
@ 2015-10-29 14:45 Neil Armstrong
2015-10-29 15:17 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Neil Armstrong @ 2015-10-29 14:45 UTC (permalink / raw)
To: David S. Miller
Cc: Andrew Lunn, Florian Fainelli, Guenter Roeck, vivien.didelot,
Fabian Frederick, Pavel Nakonechny, Joe Perches, netdev,
linux-kernel
Implement a remove callback allowing the switch driver to cleanup
resources it used: interrupts and remapped register ranges.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/net/dsa/bcm_sf2.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 6f946fe..e0be318 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1054,6 +1054,25 @@ out_unmap:
return ret;
}
+static void bcm_sf2_sw_remove(struct dsa_switch *ds)
+{
+ struct bcm_sf2_priv *priv = ds_to_priv(ds);
+ void __iomem **base;
+ unsigned int i;
+
+ /* Disable all interrupts and free them */
+ bcm_sf2_intr_disable(priv);
+
+ free_irq(priv->irq0, priv);
+ free_irq(priv->irq1, priv);
+
+ base = &priv->core;
+ for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
+ iounmap(*base);
+ base++;
+ }
+}
+
static int bcm_sf2_sw_set_addr(struct dsa_switch *ds, u8 *addr)
{
return 0;
@@ -1367,6 +1386,7 @@ static struct dsa_switch_driver bcm_sf2_switch_driver = {
.tag_protocol = DSA_TAG_PROTO_BRCM,
.priv_size = sizeof(struct bcm_sf2_priv),
.probe = bcm_sf2_sw_probe,
+ .remove = bcm_sf2_sw_remove,
.setup = bcm_sf2_sw_setup,
.set_addr = bcm_sf2_sw_set_addr,
.get_phy_flags = bcm_sf2_sw_get_phy_flags,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [RFC PATCH v3 2/5] net: dsa: bcm_sf2: cleanup resources in remove callback
2015-10-29 14:45 [RFC PATCH v3 2/5] net: dsa: bcm_sf2: cleanup resources in remove callback Neil Armstrong
@ 2015-10-29 15:17 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2015-10-29 15:17 UTC (permalink / raw)
To: Neil Armstrong
Cc: David S. Miller, Florian Fainelli, Guenter Roeck, vivien.didelot,
Fabian Frederick, Pavel Nakonechny, Joe Perches, netdev,
linux-kernel
On Thu, Oct 29, 2015 at 03:45:30PM +0100, Neil Armstrong wrote:
> Implement a remove callback allowing the switch driver to cleanup
> resources it used: interrupts and remapped register ranges.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
> drivers/net/dsa/bcm_sf2.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 6f946fe..e0be318 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -1054,6 +1054,25 @@ out_unmap:
> return ret;
> }
>
> +static void bcm_sf2_sw_remove(struct dsa_switch *ds)
> +{
> + struct bcm_sf2_priv *priv = ds_to_priv(ds);
> + void __iomem **base;
> + unsigned int i;
> +
> + /* Disable all interrupts and free them */
> + bcm_sf2_intr_disable(priv);
> +
> + free_irq(priv->irq0, priv);
> + free_irq(priv->irq1, priv);
> +
> + base = &priv->core;
> + for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
> + iounmap(*base);
> + base++;
Something for Florian to consider. Would it be possible to move to
using devm_ for interrupts and iomem? The question would be, what is
dev?
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-29 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29 14:45 [RFC PATCH v3 2/5] net: dsa: bcm_sf2: cleanup resources in remove callback Neil Armstrong
2015-10-29 15:17 ` Andrew Lunn
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).