Subject: Re: [PATCH RFC V2 2/2] net: qualcomm: new Ethernet over SPI driver for QCA7000

From: Mark Rutland <[email-masked]>
Date: Tue, 1 Jul 2014 18:46:16 +0100

Hi,

On Tue, Jul 01, 2014 at 05:36:49PM +0100, Stefan Wahren wrote:
> This patch adds the Ethernet over SPI driver for the
> Qualcomm QCA7000 HomePlug GreenPHY.
> 
> Signed-off-by: Stefan Wahren <[email-masked]>
> ---
>  drivers/net/ethernet/Kconfig                |    1 +
>  drivers/net/ethernet/Makefile               |    1 +
>  drivers/net/ethernet/qualcomm/Kconfig       |   30 +
>  drivers/net/ethernet/qualcomm/Makefile      |    6 +
>  drivers/net/ethernet/qualcomm/qca_7k.c      |  149 ++++
>  drivers/net/ethernet/qualcomm/qca_7k.h      |   72 ++
>  drivers/net/ethernet/qualcomm/qca_debug.c   |  311 +++++++++
>  drivers/net/ethernet/qualcomm/qca_debug.h   |   34 +
>  drivers/net/ethernet/qualcomm/qca_framing.c |  155 +++++
>  drivers/net/ethernet/qualcomm/qca_framing.h |  134 ++++
>  drivers/net/ethernet/qualcomm/qca_spi.c     | 1001 +++++++++++++++++++++++++++
>  drivers/net/ethernet/qualcomm/qca_spi.h     |  114 +++
>  12 files changed, 2008 insertions(+)
>  create mode 100644 drivers/net/ethernet/qualcomm/Kconfig
>  create mode 100644 drivers/net/ethernet/qualcomm/Makefile
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_7k.c
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_7k.h
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_debug.c
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_debug.h
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_framing.c
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_framing.h
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_spi.c
>  create mode 100644 drivers/net/ethernet/qualcomm/qca_spi.h

[...]

> +       if (of_find_property(spi_device->dev.of_node,
> +               "qca,legacy-mode", NULL)) {
> +               legacy_mode = 1;
> +       }

Please use of_property_read bool for boolean properties. Here you can
have:

	legacy_mode = of_property_read_bool(spi_device->dev.of_node,
					    "qca,legacy-mode")

[...]

> +
> +       if (qcaspi_clkspeed == 0) {
> +               if (of_find_property(spi_device->dev.of_node,
> +                                       "spi-max-frequency", NULL)) {
> +                       qcaspi_clkspeed = spi_device->max_speed_hz;
> +               } else {
> +                       qcaspi_clkspeed = QCASPI_CLK_SPEED;
> +               }
> +       }

As far as I can see, of_register_spi_devices leaves
spi_device->max_speed_hz zeroed if there's no spi-max-speed property, so
here you could have:

	qcaspi_clkspeed = spi_device->max_speed_hz ?: QCASPI_CLK_SPEED;

Which avoids redundant DT parsing.

[...]

> +               memcpy(qca->net_dev->dev_addr, mac, ETH_ALEN);

I believe that it is preferred to write:

	ether_addr_copy(qca->net_dev->dev_addr, mac);

I believe checkpatch has a warning for this.

Thanks,
Mark.