mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] net: fec_imx: add regulator support
Date: Tue, 9 Jul 2019 11:58:49 +0200	[thread overview]
Message-ID: <20190709095849.xm767fc4obdkacfw@pengutronix.de> (raw)
In-Reply-To: <20190708072510.4169-2-o.rempel@pengutronix.de>

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@pengutronix.de>
> ---
>  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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-07-09  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08  7:25 [PATCH 1/2] arm: port imx28-evk to devicetree Oleksij Rempel
2019-07-08  7:25 ` [PATCH 2/2] net: fec_imx: add regulator support Oleksij Rempel
2019-07-09  9:58   ` Sascha Hauer [this message]
2019-07-09 10:15 ` [PATCH 1/2] arm: port imx28-evk to devicetree Sascha Hauer

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=20190709095849.xm767fc4obdkacfw@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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