netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jeff Garzik <jeff@garzik.org>,
	netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	Anton Vorontsov <avorontsov@ru.mvista.com>,
	Andy Fleming <afleming@freescale.com>
Subject: Re: [PATCH][RESEND] PHY: Add the phy_device_release device method.
Date: Tue, 4 Dec 2007 08:38:47 +0100	[thread overview]
Message-ID: <20071204073847.GA881@avionic-tr-basi.adnet.avionic-design.de> (raw)
In-Reply-To: <20071203214440.78709615.akpm@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 2888 bytes --]

* Andrew Morton wrote:
> On Mon, 3 Dec 2007 09:35:11 +0100 Thierry Reding <thierry.reding@avionic-design.de> wrote:
> 
> > In cases where more than a single PHY is found on the MDIO bus, the kernel
> > will print a warning that this method is missing for each PHY device that
> > is not attached to a networking device.
> > 
> > Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
> > ---
> >  drivers/net/phy/mdio_bus.c |   19 ++++++++++++++++++-
> >  1 files changed, 18 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > index fc2f0e6..cb7fb47 100644
> > --- a/drivers/net/phy/mdio_bus.c
> > +++ b/drivers/net/phy/mdio_bus.c
> > @@ -36,6 +36,23 @@
> >  #include <asm/uaccess.h>
> >  
> >  /**
> > + * phy_device_release - free a phy_device structure when all users of it are
> > + * 	finished.
> > + *
> > + * @dev: device that's been disconnected
> > + *
> > + * Will be called only by the device core when all users of this phy_device
> > + * are done.
> > + */
> > +static void phy_device_release(struct device *dev)
> > +{
> > +	struct phy_device *phy;
> > +
> > +	phy = to_phy_device(dev);
> > +	kfree(phy);
> > +}
> > +
> > +/**
> >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> >   * @bus: target mii_bus
> >   *
> > @@ -83,6 +100,7 @@ int mdiobus_register(struct mii_bus *bus)
> >  		if (phydev) {
> >  			phydev->irq = bus->irq[i];
> >  
> > +			phydev->dev.release = phy_device_release;
> >  			phydev->dev.parent = bus->dev;
> >  			phydev->dev.bus = &mdio_bus_type;
> >  			snprintf(phydev->dev.bus_id, BUS_ID_SIZE, PHY_ID_FMT, bus->id, i);
> > @@ -112,7 +130,6 @@ void mdiobus_unregister(struct mii_bus *bus)
> >  	for (i = 0; i < PHY_MAX_ADDR; i++) {
> >  		if (bus->phy_map[i]) {
> >  			device_unregister(&bus->phy_map[i]->dev);
> > -			kfree(bus->phy_map[i]);
> >  		}
> >  	}
> >  }
> > 
> 
> I've been sitting on
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.24-rc3/2.6.24-rc3-mm2/broken-out/phy-implement-release-function.patch
> for a few weeks.  For some reason I have it in my "nacked netdev patches"
> section but I think that was a mistake and it has not (yet ;)) been nacked.
> 
> Anyway, Anton's patch looks somewhat different from yours.  Please compare
> notes.

FWIW, I like Anton's patch better, especially since it plugs a possible
memory leak. I'm not sure it's useful or necessary to export the
phy_device_free symbol, though.

The only other difference that I can see is that Anton's patch sets the
release function in a different place, when the device is created, whereas my
patch only sets it before registering the device. Both should be identical
since the release function won't be needed unless the device is registered.

Thierry


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-12-04  7:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071119.214215.207388094.davem@davemloft.net>
2007-12-01 22:02 ` Fw: [PATCH] Add the phy_device_release device method Jeff Garzik
2007-12-03  8:35   ` [PATCH][RESEND] PHY: " Thierry Reding
2007-12-04  5:44     ` Andrew Morton
2007-12-04  7:38       ` Thierry Reding [this message]
2007-12-04 13:17         ` Anton Vorontsov
2007-12-04 20:06           ` Jeff Garzik

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=20071204073847.GA881@avionic-tr-basi.adnet.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=afleming@freescale.com \
    --cc=akpm@linux-foundation.org \
    --cc=avorontsov@ru.mvista.com \
    --cc=davem@davemloft.net \
    --cc=jeff@garzik.org \
    --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 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).