From: Arnd Bergmann <arnd@arndb.de>
To: kishon <kishon@ti.com>
Cc: rob@landley.net, tony@atomide.com, linux@arm.linux.org.uk,
eballetbo@gmail.com, javier@dowhile0.org, balbi@ti.com,
gregkh@linuxfoundation.org, akpm@linux-foundation.org,
mchehab@redhat.com, cesarb@cesarb.net, davem@davemloft.net,
santosh.shilimkar@ti.com, broonie@opensource.wolfsonmicro.com,
swarren@nvidia.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
linux-usb@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH v2 1/5] drivers: phy: add generic PHY framework
Date: Tue, 19 Feb 2013 14:28:42 +0000 [thread overview]
Message-ID: <201302191428.42407.arnd@arndb.de> (raw)
In-Reply-To: <51238485.1020408@ti.com>
On Tuesday 19 February 2013, kishon wrote:
> >> +
> >> + devname = dev_name(dev);
> >> + device_initialize(&phy->dev);
> >> + phy->desc = desc;
> >> + phy->dev.class = phy_class;
> >> + phy->dev.parent = dev;
> >> + phy->dev.bus = desc->bus;
> >> + ret = dev_set_name(&phy->dev, "%s", devname);
> >
> >
> > Passing a bus_type through the descriptor seems misplaced. What is this for?
>
> I thought if we are adding ethernet phys here (say drivers/phy/net), we
> can make phy_device_create() (currently in drivers/net/phy/phy_device.c)
> call phy_create with bus_type set to mdio_bus_type. Then we can have all
> the PHYs showing up in /sys/class/phy/ and ethernet can continue to use
> its own phy abstraction layer.
Hmm, that relies on the fact that mdio uses a 'bus_type' while the new phy
support uses a 'class', and it will break if we ever get to the point
where those two concepts are merged. I would rather not plan ahead here.
> > Why is this function not just:
> >
> > struct phy *phy_create(struct device *dev, const char *label, int type,
> > struct phy_ops *ops);
>
> since while calling the callback functions using ops, there wont be
> anyway to get back the device specific structure pointer.
>
> struct phy_dev {
> .
> .
> struct phy_descriptor desc;
> void __iomem *base;
> .
> .
> };
>
> static int phy_resume(struct phy_descriptor *desc)
> {
>
> //if we dont pass a member of phy_dev while *phy_create* we can't get
> back phy_dev from callback functions as used below.
> struct phy_dev *phy = desc_to_omapusb(desc);
>
> return 0;
> }
>
> static struct phy_ops ops = {
> .resume = phy_resume,
> .owner = THIS_MODULE,
> };
In other subsystems, that is what the device->private_data pointer is used
for, which you could also pass to phy_create, or set after calling that
function.
> > Passing a structure like you do here seems dangerous because when someone
> > decides to add members to the structure, existing code will not give a
> > build error but silently break.
>
> Not sure I understood this point. Care to explain?
Nevermind, when I wrote that sentence, I had not yet noticed that the
phy_descriptor is kept around. I was thinking that the structure was
only used to pass more arguments into phy_create.
Arnd
next prev parent reply other threads:[~2013-02-19 14:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 5:53 [PATCH v2 0/5] Generic PHY Framework Kishon Vijay Abraham I
2013-02-19 5:53 ` [PATCH v2 1/5] drivers: phy: add generic PHY framework Kishon Vijay Abraham I
2013-02-19 8:01 ` Felipe Balbi
2013-02-19 12:56 ` Arnd Bergmann
2013-02-19 13:56 ` kishon
2013-02-19 14:28 ` Arnd Bergmann [this message]
2013-02-23 22:44 ` Rob Landley
2013-02-25 6:41 ` kishon
2013-02-19 5:53 ` [PATCH v2 2/5] usb: phy: omap-usb2: use the new " Kishon Vijay Abraham I
2013-02-19 8:11 ` Felipe Balbi
2013-02-19 5:53 ` [PATCH v2 3/5] usb: otg: twl4030: " Kishon Vijay Abraham I
2013-02-19 5:53 ` [PATCH v2 4/5] ARM: OMAP: USB: Add phy binding information Kishon Vijay Abraham I
2013-02-19 5:53 ` [PATCH v2 5/5] usb: musb: omap2430: use the new generic PHY framework Kishon Vijay Abraham I
2013-02-19 10:44 ` [PATCH v2 0/5] Generic PHY Framework Arnd Bergmann
2013-02-19 11:28 ` kishon
2013-02-19 12:33 ` Arnd Bergmann
2013-02-19 13:12 ` Felipe Balbi
2013-02-19 14:34 ` Arnd Bergmann
2013-02-19 15:05 ` Felipe Balbi
2013-02-19 15:28 ` Arnd Bergmann
2013-02-19 15:47 ` Felipe Balbi
2013-02-19 16:07 ` Marc Kleine-Budde
2013-02-19 16:17 ` Felipe Balbi
2013-02-23 20:05 ` Rob Landley
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=201302191428.42407.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=balbi@ti.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=cesarb@cesarb.net \
--cc=davem@davemloft.net \
--cc=eballetbo@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=javier@dowhile0.org \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mchehab@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rob@landley.net \
--cc=santosh.shilimkar@ti.com \
--cc=swarren@nvidia.com \
--cc=tony@atomide.com \
/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