All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org,
	andrew@lunn.ch, f.fainelli@gmail.com,
	alexandre.belloni@bootlin.com, vladimir.oltean@nxp.com,
	UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-phy@lists.infradead.org, linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH net-next 09/12] net: lan966x: add the basic lan966x driver
Date: Mon, 20 Sep 2021 14:46:30 +0100	[thread overview]
Message-ID: <YUiQtrIodmyAZ476@shell.armlinux.org.uk> (raw)
In-Reply-To: <20210920095218.1108151-10-horatiu.vultur@microchip.com>

On Mon, Sep 20, 2021 at 11:52:15AM +0200, Horatiu Vultur wrote:
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> new file mode 100644
> index 000000000000..2984f510ae27
> --- /dev/null
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -0,0 +1,350 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include <asm/memory.h>
> +#include <linux/module.h>
> +#include <linux/if_bridge.h>
> +#include <linux/iopoll.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_net.h>
> +#include <linux/reset.h>
> +
> +#include "lan966x_main.h"
> +
> +#define READL_SLEEP_US			10
> +#define READL_TIMEOUT_US		100000000
> +
> +#define IO_RANGES 2
> +
> +static const struct of_device_id lan966x_match[] = {
> +	{ .compatible = "microchip,lan966x-switch" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, mchp_lan966x_match);
> +
> +struct lan966x_main_io_resource {
> +	enum lan966x_target id;
> +	phys_addr_t offset;
> +	int range;
> +};
> +
> +static const struct lan966x_main_io_resource lan966x_main_iomap[] =  {
> +	{ TARGET_CPU,                   0xc0000, 0 }, /* 0xe00c0000 */
> +	{ TARGET_ORG,                         0, 1 }, /* 0xe2000000 */
> +	{ TARGET_GCB,                    0x4000, 1 }, /* 0xe2004000 */
> +	{ TARGET_QS,                     0x8000, 1 }, /* 0xe2008000 */
> +	{ TARGET_CHIP_TOP,              0x10000, 1 }, /* 0xe2010000 */
> +	{ TARGET_REW,                   0x14000, 1 }, /* 0xe2014000 */
> +	{ TARGET_SYS,                   0x28000, 1 }, /* 0xe2028000 */
> +	{ TARGET_HSIO,                  0x2c000, 1 }, /* 0xe202c000 */
> +	{ TARGET_DEV,                   0x34000, 1 }, /* 0xe2034000 */
> +	{ TARGET_DEV +  1,              0x38000, 1 }, /* 0xe2038000 */
> +	{ TARGET_DEV +  2,              0x3c000, 1 }, /* 0xe203c000 */
> +	{ TARGET_DEV +  3,              0x40000, 1 }, /* 0xe2040000 */
> +	{ TARGET_DEV +  4,              0x44000, 1 }, /* 0xe2044000 */
> +	{ TARGET_DEV +  5,              0x48000, 1 }, /* 0xe2048000 */
> +	{ TARGET_DEV +  6,              0x4c000, 1 }, /* 0xe204c000 */
> +	{ TARGET_DEV +  7,              0x50000, 1 }, /* 0xe2050000 */
> +	{ TARGET_QSYS,                 0x100000, 1 }, /* 0xe2100000 */
> +	{ TARGET_AFI,                  0x120000, 1 }, /* 0xe2120000 */
> +	{ TARGET_ANA,                  0x140000, 1 }, /* 0xe2140000 */
> +};
> +
> +static int lan966x_create_targets(struct platform_device *pdev,
> +				  struct lan966x *lan966x)
> +{
> +	struct resource *iores[IO_RANGES];
> +	void __iomem *iomem[IO_RANGES];
> +	void __iomem *begin[IO_RANGES];
> +	int idx;
> +
> +	for (idx = 0; idx < IO_RANGES; idx++) {
> +		iores[idx] = platform_get_resource(pdev, IORESOURCE_MEM,
> +						   idx);
> +		iomem[idx] = devm_ioremap(&pdev->dev,
> +					  iores[idx]->start,
> +					  resource_size(iores[idx]));

This is buggy. If platform_get_resource() returns NULL, you will oops
the kernel.

In any case, this code will be ripe for janitor patching. Please
consider using devm_platform_ioremap_resource() now, before someone
converts your code to use this function.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org,
	andrew@lunn.ch, f.fainelli@gmail.com,
	alexandre.belloni@bootlin.com, vladimir.oltean@nxp.com,
	UNGLinuxDriver@microchip.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-phy@lists.infradead.org, linux-pm@vger.kernel.org
Subject: Re: [RFC PATCH net-next 09/12] net: lan966x: add the basic lan966x driver
Date: Mon, 20 Sep 2021 14:46:30 +0100	[thread overview]
Message-ID: <YUiQtrIodmyAZ476@shell.armlinux.org.uk> (raw)
In-Reply-To: <20210920095218.1108151-10-horatiu.vultur@microchip.com>

On Mon, Sep 20, 2021 at 11:52:15AM +0200, Horatiu Vultur wrote:
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> new file mode 100644
> index 000000000000..2984f510ae27
> --- /dev/null
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -0,0 +1,350 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include <asm/memory.h>
> +#include <linux/module.h>
> +#include <linux/if_bridge.h>
> +#include <linux/iopoll.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_net.h>
> +#include <linux/reset.h>
> +
> +#include "lan966x_main.h"
> +
> +#define READL_SLEEP_US			10
> +#define READL_TIMEOUT_US		100000000
> +
> +#define IO_RANGES 2
> +
> +static const struct of_device_id lan966x_match[] = {
> +	{ .compatible = "microchip,lan966x-switch" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, mchp_lan966x_match);
> +
> +struct lan966x_main_io_resource {
> +	enum lan966x_target id;
> +	phys_addr_t offset;
> +	int range;
> +};
> +
> +static const struct lan966x_main_io_resource lan966x_main_iomap[] =  {
> +	{ TARGET_CPU,                   0xc0000, 0 }, /* 0xe00c0000 */
> +	{ TARGET_ORG,                         0, 1 }, /* 0xe2000000 */
> +	{ TARGET_GCB,                    0x4000, 1 }, /* 0xe2004000 */
> +	{ TARGET_QS,                     0x8000, 1 }, /* 0xe2008000 */
> +	{ TARGET_CHIP_TOP,              0x10000, 1 }, /* 0xe2010000 */
> +	{ TARGET_REW,                   0x14000, 1 }, /* 0xe2014000 */
> +	{ TARGET_SYS,                   0x28000, 1 }, /* 0xe2028000 */
> +	{ TARGET_HSIO,                  0x2c000, 1 }, /* 0xe202c000 */
> +	{ TARGET_DEV,                   0x34000, 1 }, /* 0xe2034000 */
> +	{ TARGET_DEV +  1,              0x38000, 1 }, /* 0xe2038000 */
> +	{ TARGET_DEV +  2,              0x3c000, 1 }, /* 0xe203c000 */
> +	{ TARGET_DEV +  3,              0x40000, 1 }, /* 0xe2040000 */
> +	{ TARGET_DEV +  4,              0x44000, 1 }, /* 0xe2044000 */
> +	{ TARGET_DEV +  5,              0x48000, 1 }, /* 0xe2048000 */
> +	{ TARGET_DEV +  6,              0x4c000, 1 }, /* 0xe204c000 */
> +	{ TARGET_DEV +  7,              0x50000, 1 }, /* 0xe2050000 */
> +	{ TARGET_QSYS,                 0x100000, 1 }, /* 0xe2100000 */
> +	{ TARGET_AFI,                  0x120000, 1 }, /* 0xe2120000 */
> +	{ TARGET_ANA,                  0x140000, 1 }, /* 0xe2140000 */
> +};
> +
> +static int lan966x_create_targets(struct platform_device *pdev,
> +				  struct lan966x *lan966x)
> +{
> +	struct resource *iores[IO_RANGES];
> +	void __iomem *iomem[IO_RANGES];
> +	void __iomem *begin[IO_RANGES];
> +	int idx;
> +
> +	for (idx = 0; idx < IO_RANGES; idx++) {
> +		iores[idx] = platform_get_resource(pdev, IORESOURCE_MEM,
> +						   idx);
> +		iomem[idx] = devm_ioremap(&pdev->dev,
> +					  iores[idx]->start,
> +					  resource_size(iores[idx]));

This is buggy. If platform_get_resource() returns NULL, you will oops
the kernel.

In any case, this code will be ripe for janitor patching. Please
consider using devm_platform_ioremap_resource() now, before someone
converts your code to use this function.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2021-09-20 13:46 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20  9:52 [RFC PATCH net-next 00/12] Add lan966x driver Horatiu Vultur
2021-09-20  9:52 ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 01/12] net: mdio: mscc-miim: Fix the mdio controller Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 11:52   ` Andrew Lunn
2021-09-20 11:52     ` Andrew Lunn
2021-09-22  8:24     ` Horatiu Vultur
2021-09-22  8:24       ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 02/12] net: phy: mchp: Add support for LAN8804 PHY Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 10:00   ` Alexandre Belloni
2021-09-20 10:00     ` Alexandre Belloni
2021-09-20 11:59   ` Andrew Lunn
2021-09-20 11:59     ` Andrew Lunn
2021-09-22  8:35     ` Horatiu Vultur
2021-09-22  8:35       ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 03/12] phy: Add lan966x ethernet serdes PHY driver Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 13:42   ` Russell King (Oracle)
2021-09-20 13:42     ` Russell King (Oracle)
2021-09-22 10:04     ` Horatiu Vultur
2021-09-22 10:04       ` Horatiu Vultur
2021-09-23 12:44   ` Rob Herring
2021-09-23 12:44     ` Rob Herring
2021-09-20  9:52 ` [RFC PATCH net-next 04/12] dt-bindings: reset: Add lan966x switch reset bindings Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-23 12:49   ` Rob Herring
2021-09-23 12:49     ` Rob Herring
2021-09-20  9:52 ` [RFC PATCH net-next 05/12] reset: lan966x: Add switch reset driver Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 12:11   ` Andrew Lunn
2021-09-20 12:11     ` Andrew Lunn
2021-09-22  9:59     ` Horatiu Vultur
2021-09-22  9:59       ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 06/12] dt-bindings: reset: Add lan966x power reset bindings Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 07/12] power: reset: Add lan966x power reset driver Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 12:15   ` Andrew Lunn
2021-09-20 12:15     ` Andrew Lunn
2021-09-20  9:52 ` [RFC PATCH net-next 08/12] dt-bindings: net: lan966x: Add lan966x-switch bindings Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-23 12:53   ` Rob Herring
2021-09-23 12:53     ` Rob Herring
2021-09-20  9:52 ` [RFC PATCH net-next 09/12] net: lan966x: add the basic lan966x driver Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 13:46   ` Russell King (Oracle) [this message]
2021-09-20 13:46     ` Russell King (Oracle)
2021-09-20  9:52 ` [RFC PATCH net-next 10/12] net: lan966x: add port module support Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 13:54   ` Russell King (Oracle)
2021-09-20 13:54     ` Russell King (Oracle)
2021-09-23  8:02     ` Horatiu Vultur
2021-09-23  8:02       ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 11/12] net: lan966x: add mactable support Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20  9:52 ` [RFC PATCH net-next 12/12] net: lan966x: add ethtool configuration and statistics Horatiu Vultur
2021-09-20  9:52   ` Horatiu Vultur
2021-09-20 20:31   ` Jakub Kicinski
2021-09-20 20:31     ` Jakub Kicinski

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=YUiQtrIodmyAZ476@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vladimir.oltean@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.