From: f.fainelli@gmail.com (Florian Fainelli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 7/9] net: mvmdio: add xmdio support
Date: Wed, 7 Jun 2017 08:48:06 -0700 [thread overview]
Message-ID: <e423ea96-12df-6a19-ce94-149ace2e2272@gmail.com> (raw)
In-Reply-To: <20170607083810.30922-8-antoine.tenart@free-electrons.com>
On 06/07/2017 01:38 AM, Antoine Tenart wrote:
> This patch adds the xMDIO interface support in the mvmdio driver. This
> interface is used in Ethernet controllers on Marvell 370, 7k and 8k (as
> of now). The xSMI interface supported by this driver complies with the
> IEEE 802.3 clause 45 (while the SMI interface complies with the clause
> 22). The xSMI interface is used by 10GbE devices.
>
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
> + if (of_device_is_compatible(np, "marvell,orion-mdio")) {
> + ops->is_done = smi_is_done;
> + ops->is_read_valid = smi_is_read_valid;
> + ops->start_read = smi_start_read_op;
> + ops->read = smi_read_op;
> + ops->write = smi_write_op;
> +
> + dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> + dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> + } else if (of_device_is_compatible(np, "marvell,xmdio")) {
> + ops->is_done = xsmi_is_done;
> + ops->is_read_valid = xsmi_is_read_valid;
> + ops->start_read = xsmi_start_read_op;
> + ops->read = xsmi_read_op;
> + ops->write = xsmi_write_op;
> +
> + dev->poll_interval_min = MVMDIO_XSMI_POLL_INTERVAL_MIN;
> + dev->poll_interval_max = MVMDIO_XSMI_POLL_INTERVAL_MAX;
> + } else {
> + return -EINVAL;
> + }
Instead of doing this, you could have the ops structure declared e.g: a
static global variables in the driver and reference them from the
of_device_id .data field, something like:
static struct orion_mdio_ops mdio_ops = {
...
};
static struct orion_mdio_data mdio_data = {
.ops = &mdio_ops,
.poll_intervall_min = ...,
.poll_interfave_max = ...,
};
static struct orion_mdio_ops xmdio_ops = {
...
};
static strcut orion_mdio_data xmdio_ data = {
};
and then reference those using of_id->data in the probe function
> +
> + dev->ops = ops;
> + return 0;
> +}
> +
> static int orion_mdio_probe(struct platform_device *pdev)
> {
> struct resource *r;
> struct mii_bus *bus;
> struct orion_mdio_dev *dev;
> - struct orion_mdio_ops *ops;
> int i, ret;
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -278,18 +367,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
>
> mutex_init(&dev->lock);
>
> - ops = devm_kzalloc(&pdev->dev, sizeof(*ops), GFP_KERNEL);
> - if (!ops)
> - return -ENOMEM;
> -
> - dev->poll_interval_min = MVMDIO_SMI_POLL_INTERVAL_MIN;
> - dev->poll_interval_max = MVMDIO_SMI_POLL_INTERVAL_MAX;
> - ops->is_done = orion_mdio_smi_is_done;
> - ops->is_read_valid = orion_mdio_smi_is_read_valid;
> - ops->start_read = orion_mdio_start_read_op;
> - ops->read = orion_mdio_read_op;
> - ops->write = orion_mdio_write_op;
> - dev->ops = ops;
> + ret = orion_mdio_populate_ops(pdev, dev);
> + if (ret)
> + return ret;
>
> if (pdev->dev.of_node)
> ret = of_mdiobus_register(bus, pdev->dev.of_node);
> @@ -340,6 +420,7 @@ static int orion_mdio_remove(struct platform_device *pdev)
>
> static const struct of_device_id orion_mdio_match[] = {
> { .compatible = "marvell,orion-mdio" },
and do .data = &mdio_data
> + { .compatible = "marvell,xmdio" },
and .data = &xmdio_data
> { }
> };
> MODULE_DEVICE_TABLE(of, orion_mdio_match);
>
--
Florian
next prev parent reply other threads:[~2017-06-07 15:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 8:38 [PATCH 0/9] net: mvmdio: add xSMI support Antoine Tenart
2017-06-07 8:38 ` [PATCH 1/9] net: mvmdio: reorder headers alphabetically Antoine Tenart
2017-06-07 19:24 ` Florian Fainelli
2017-06-07 8:38 ` [PATCH 2/9] net: mvmdio: use tabs for defines Antoine Tenart
2017-06-07 19:24 ` Florian Fainelli
2017-06-07 8:38 ` [PATCH 3/9] net: mvmdio: use GENMASK for masks Antoine Tenart
2017-06-07 19:24 ` Florian Fainelli
2017-06-07 8:38 ` [PATCH 4/9] net: mvmdio: move the read valid check into its own function Antoine Tenart
2017-06-07 10:00 ` Sergei Shtylyov
2017-06-07 14:43 ` Antoine Tenart
2017-06-07 8:38 ` [PATCH 5/9] net: mvmdio: introduce an ops structure Antoine Tenart
2017-06-07 19:28 ` Florian Fainelli
2017-06-07 8:38 ` [PATCH 6/9] net: mvmdio: put the poll intervals in the private structure Antoine Tenart
2017-06-07 19:25 ` Florian Fainelli
2017-06-07 8:38 ` [PATCH 7/9] net: mvmdio: add xmdio support Antoine Tenart
2017-06-07 12:12 ` Andrew Lunn
2017-06-07 14:42 ` Antoine Tenart
2017-06-07 15:48 ` Florian Fainelli [this message]
2017-06-07 15:56 ` Russell King - ARM Linux
2017-06-07 16:13 ` Antoine Tenart
2017-06-07 8:38 ` [PATCH 8/9] dt-bindings: orion-mdio: document the new xmdio compatible Antoine Tenart
2017-06-07 8:38 ` [PATCH 9/9] arm64: marvell: dts: add xmdio nodes for 7k/8k Antoine Tenart
2017-06-07 8:43 ` Gregory CLEMENT
2017-06-07 19:09 ` David Miller
2017-06-08 8:45 ` Antoine Tenart
2017-06-08 8:51 ` Antoine Tenart
2017-06-08 8:55 ` Gregory CLEMENT
2017-06-08 9:03 ` 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=e423ea96-12df-6a19-ce94-149ace2e2272@gmail.com \
--to=f.fainelli@gmail.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;
as well as URLs for NNTP newsgroup(s).