Re: [PATCH 2/2] net: fec_imx: add regulator support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 08, 2019 at 09:25:10AM +0200, Oleksij Rempel wrote:
> at least imx28-evk need it to work with devicetree
> 
> Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
> ---
>  drivers/net/fec_imx.c | 20 ++++++++++++++++++++
>  drivers/net/fec_imx.h |  1 +
>  2 files changed, 21 insertions(+)
> 
> diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
> index 38a29fc83e..10422d2e2d 100644
> --- a/drivers/net/fec_imx.c
> +++ b/drivers/net/fec_imx.c
> @@ -19,6 +19,7 @@
>  #include <linux/err.h>
>  #include <of_net.h>
>  #include <of_gpio.h>
> +#include <regulator.h>
>  #include <gpio.h>
>  #include <linux/iopoll.h>
>  
> @@ -776,6 +777,22 @@ static int fec_probe(struct device_d *dev)
>  	}
>  	fec->regs = IOMEM(iores->start);
>  
> +	fec->reg_phy = regulator_get(dev, "phy");
> +	if (!IS_ERR(fec->reg_phy)) {
> +		ret = regulator_enable(fec->reg_phy);
> +		if (ret) {
> +			dev_err(dev,
> +				"Failed to enable phy regulator: %d\n", ret);
> +			goto disable_clk;
> +		}
> +	} else {
> +		if (PTR_ERR(fec->reg_phy) == -EPROBE_DEFER) {
> +			ret = -EPROBE_DEFER;
> +			goto disable_clk;
> +		}
> +		fec->reg_phy = NULL;
> +	}

NULL is a valid regulator, you can call regulator_enable() on it. With
this the code can be simplified a bit.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux