From: antoine.tenart@free-electrons.com (Antoine Tenart)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 7/9] net: mvmdio: add xmdio xsmi support
Date: Mon, 12 Jun 2017 13:54:35 +0200 [thread overview]
Message-ID: <20170612115435.GC22312@kwain> (raw)
In-Reply-To: <20170612101739.GA4902@n2100.armlinux.org.uk>
Hi Russell,
On Mon, Jun 12, 2017 at 11:17:39AM +0100, Russell King - ARM Linux wrote:
> On Mon, Jun 12, 2017 at 11:57:43AM +0200, Antoine Tenart wrote:
> > +static const struct orion_mdio_ops *orion_mdio_get_ops(struct orion_mdio_dev *dev,
> > + int regnum)
> > +{
> > + if (dev->bus_type == BUS_TYPE_XSMI && (regnum & MII_ADDR_C45))
> > + return &orion_mdio_xsmi_ops;
> > + else if (dev->bus_type == BUS_TYPE_SMI)
> > + return &orion_mdio_smi_ops;
> > +
> > + return ERR_PTR(-EOPNOTSUPP);
> > +}
>
> Oh, this is where you're doing it - I'm not sure having this complexity
> is really necessary - there is no dynamic choice between the two. This
> seems to be way over-engineered.
You're right, there is no dynamic choice between the two. The advantage
is the logic of the read/write operations are not duplicated.
> You might as well make the SMI operations fail if MII_ADDR_C45 is set,
> and the XSMI operations fail if MII_ADDR_C45 is not set.
This check is already done for xSMI operations. But this should also be
the case for SMI ones, you're right.
> 1. the mdio read/write functions implement their own locking.
>
> At the MDIO level, there is already locking in the form of a per-bus
> lock "bus->mdio_lock" which will be taken whenever either of these
> functions is called. So the driver's "dev->lock" is redundant.
OK, that's a good rework to add in the series.
> 2. with the redundant locking removed, orion_mdio_write() becomes a
> call to orion_mdio_wait_ready() followed by a call to dev->ops->write.
> It seems that orion_mdio_wait_ready() could be a library function
> shared between a SMI version of orion_mdio_write() and a XSMI version.
>
> 3. the same is really true of orion_mdio_read(), although that function
> is a little more complex in itself, the result would actually end up
> being simpler.
I'm not completely convinced as the read and write functions end up
being duplicated. One for SMI operations and one for xSMI. But I don't
really care, if you think this is better let's go for it.
Should I add your first patch in my series and squash the second one in
patch 7/9? (I'll also remove the bus_type member from the private
struct, as well as the one line it's used in the probe).
Thanks!
Antoine
--
Antoine T?nart, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170612/9488ca0c/attachment.sig>
next prev parent reply other threads:[~2017-06-12 11:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-12 9:57 [PATCH v3 0/9] net: mvmdio: add xMDIO xSMI support Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 1/9] net: mvmdio: reorder headers alphabetically Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 2/9] net: mvmdio: use tabs for defines Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 3/9] net: mvmdio: use GENMASK for masks Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 4/9] net: mvmdio: move the read valid check into its own function Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 5/9] net: mvmdio: introduce an ops structure Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 6/9] net: mvmdio: put the poll intervals in the " Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 7/9] net: mvmdio: add xmdio xsmi support Antoine Tenart
2017-06-12 10:07 ` Russell King - ARM Linux
2017-06-12 10:17 ` Russell King - ARM Linux
2017-06-12 10:41 ` Russell King - ARM Linux
2017-06-12 10:42 ` Russell King - ARM Linux
2017-06-12 10:42 ` Russell King - ARM Linux
2017-06-12 11:54 ` Antoine Tenart [this message]
2017-06-12 9:57 ` [PATCH v3 8/9] dt-bindings: orion-mdio: document the new xmdio compatible Antoine Tenart
2017-06-12 9:57 ` [PATCH v3 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k Antoine Tenart
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=20170612115435.GC22312@kwain \
--to=antoine.tenart@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.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