From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vps0.lunn.ch ([185.16.172.187]:33607 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbeBVC4B (ORCPT ); Wed, 21 Feb 2018 21:56:01 -0500 Date: Thu, 22 Feb 2018 03:55:55 +0100 From: Andrew Lunn To: Bryan Whitehead 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 Message-ID: <20180222025555.GA15024@lunn.ch> References: <1519240015-10263-1-git-send-email-Bryan.Whitehead@microchip.com> <1519240015-10263-2-git-send-email-Bryan.Whitehead@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1519240015-10263-2-git-send-email-Bryan.Whitehead@microchip.com> Sender: netdev-owner@vger.kernel.org List-ID: > +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