From: Andrew Lunn <andrew@lunn.ch>
To: Bryan Whitehead <Bryan.Whitehead@microchip.com>
Cc: davem@davemloft.net, UNGLinuxDriver@microchip.com,
netdev@vger.kernel.org
Subject: Re: [PATCH v2 net-next 1/2] lan743x: Add main source files for new lan743x driver
Date: Thu, 22 Feb 2018 03:55:55 +0100 [thread overview]
Message-ID: <20180222025555.GA15024@lunn.ch> (raw)
In-Reply-To: <1519240015-10263-2-git-send-email-Bryan.Whitehead@microchip.com>
> +static void lan743x_intr_unregister_isr(struct lan743x_adapter *adapter,
> + int vector_index)
> +{
> + struct lan743x_vector *vector = &adapter->intr.vector_list
> + [vector_index];
> +
> + devm_free_irq(&adapter->pci.pdev->dev, vector->irq, vector);
Hu Bryan
The point of devm_ is that you don't need to free resources you have
allocated using devm_. The core will release them when the device is
removed.
In this case, you might want to ensure the hardware will not generate
any more interrupts, but you can leave the core to call free_irq().
Please look at all your devm_*free() like calls, and remove them if
they are not needed.
> +static void lan743x_mdiobus_cleanup(struct lan743x_adapter *adapter)
> +{
> + if (adapter->init_flags & LAN743X_INIT_FLAG_MDIOBUS_REGISTERED) {
> + mdiobus_unregister(adapter->mdiobus);
> + adapter->init_flags &= ~LAN743X_INIT_FLAG_MDIOBUS_REGISTERED;
> + }
> + if (adapter->init_flags & LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED) {
> + devm_mdiobus_free(&adapter->pci.pdev->dev, adapter->mdiobus);
> + adapter->mdiobus = NULL;
> + adapter->init_flags &= ~LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED;
> + }
> +}
So you can delete devm_mdiobus_free(). That probably means you can also remove
LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED.
> +
> +static void lan743x_full_cleanup(struct lan743x_adapter *adapter)
> +{
> + if (adapter->init_flags & LAN743X_INIT_FLAG_NETDEV_REGISTERED) {
> + unregister_netdev(adapter->netdev);
> + adapter->init_flags &= ~LAN743X_INIT_FLAG_NETDEV_REGISTERED;
> + }
> + lan743x_mdiobus_cleanup(adapter);
> + lan743x_hardware_cleanup(adapter);
> + if (adapter->init_flags & LAN743X_COMPONENT_FLAG_PCI) {
> + lan743x_pci_cleanup(adapter);
> + adapter->init_flags &= ~LAN743X_COMPONENT_FLAG_PCI;
> + }
> +
> + /* would have freed netdev here.
> + * but netdev was allocated with devm_alloc_etherdev.
> + * and devm_free_netdev is not accessible.
> + * so it is expected to be freed by the devm subsystem.
> + */
And this comment can go.
Andrew
next prev parent reply other threads:[~2018-02-22 2:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-21 19:06 [PATCH v2 net-next 0/2] lan743x: Add new lan743x driver Bryan Whitehead
2018-02-21 19:06 ` [PATCH v2 net-next 1/2] lan743x: Add main source files for " Bryan Whitehead
2018-02-22 2:55 ` Andrew Lunn [this message]
2018-02-22 21:31 ` Bryan.Whitehead
2018-02-22 21:43 ` Florian Fainelli
2018-02-22 21:45 ` Andrew Lunn
2018-02-22 21:47 ` Andrew Lunn
2018-02-22 22:10 ` Bryan.Whitehead
2018-02-22 18:02 ` [RFC PATCH] lan743x: lan743x_csr_read() can be static kbuild test robot
2018-02-22 18:02 ` [PATCH v2 net-next 1/2] lan743x: Add main source files for new lan743x driver kbuild test robot
2018-02-22 22:08 ` Florian Fainelli
2018-02-23 22:44 ` Bryan.Whitehead
2018-02-24 2:06 ` Andrew Lunn
2018-02-26 5:41 ` Bryan.Whitehead
2018-02-26 17:25 ` Andrew Lunn
2018-02-26 17:35 ` Bryan.Whitehead
2018-02-21 19:06 ` [PATCH v2 net-next 2/2] lan743x: Update MAINTAINERS to include " Bryan Whitehead
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=20180222025555.GA15024@lunn.ch \
--to=andrew@lunn.ch \
--cc=Bryan.Whitehead@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.