[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200414184346.GC637127@lunn.ch>
Date: Tue, 14 Apr 2020 20:43:46 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Robert Marko <robert.marko@...tura.hr>
Cc: f.fainelli@...il.com, hkallweit1@...il.com, linux@...linux.org.uk,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
agross@...nel.org, bjorn.andersson@...aro.org, robh+dt@...nel.org,
mark.rutland@....com, linux-arm-msm@...r.kernel.org,
devicetree@...r.kernel.org,
Christian Lamparter <chunkeey@...il.com>,
Luka Perkov <luka.perkov@...tura.hr>
Subject: Re: [PATCH v2 1/3] net: phy: mdio: add IPQ40xx MDIO driver
Hi Robert
This is looking better
> +#include <linux/delay.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/mutex.h>
I don't think you need this header. There are no mutexes here.
> +#include <linux/io.h>
> +#include <linux/of_address.h>
> +#include <linux/of_mdio.h>
> +#include <linux/phy.h>
> +#include <linux/platform_device.h>
> +
> +#define MDIO_CTRL_0_REG 0x40
> +#define MDIO_CTRL_1_REG 0x44
> +#define MDIO_CTRL_2_REG 0x48
> +#define MDIO_CTRL_3_REG 0x4c
> +#define MDIO_CTRL_4_REG 0x50
So your next version will hopefully have better names.
> +static int ipq40xx_mdio_wait_busy(struct mii_bus *bus)
> +{
> + struct ipq40xx_mdio_data *priv = bus->priv;
> + int i;
> +
> + for (i = 0; i < IPQ40XX_MDIO_RETRY; i++) {
> + unsigned int busy;
> +
> + busy = readl(priv->membase + MDIO_CTRL_4_REG) &
> + MDIO_CTRL_4_ACCESS_BUSY;
> + if (!busy)
> + return 0;
> +
> + /* BUSY might take to be cleard by 15~20 times of loop */
> + udelay(IPQ40XX_MDIO_DELAY);
> + }
> +
> + dev_err(bus->parent, "MDIO operation timed out\n");
> +
> + return -ETIMEDOUT;
> +}
You can probably make use of include/linux/iopoll.h
Andrew
Powered by blists - more mailing lists