diff mbox series

[v6,2/5] net: atheros: Add a check for OF_CONTROL

Message ID 20210725161347.457937-3-sjg@chromium.org
State Deferred
Delegated to: Tom Rini
Headers show
Series of-platdata: Avoid building libfdt | expand

Commit Message

Simon Glass July 25, 2021, 4:13 p.m. UTC
This phy cannot be used when OF_CONTROL is not enabled. A few boards
expect it to build, though, so add a runtime check for this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v6:
- Add new patch for atheros

 drivers/net/phy/atheros.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Ramon Fried July 27, 2021, 4:23 a.m. UTC | #1
On Sun, Jul 25, 2021 at 7:14 PM Simon Glass <sjg@chromium.org> wrote:
>
> This phy cannot be used when OF_CONTROL is not enabled. A few boards
> expect it to build, though, so add a runtime check for this case.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v6:
> - Add new patch for atheros
>
>  drivers/net/phy/atheros.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
> index f922fecd6b5..cc772f3060f 100644
> --- a/drivers/net/phy/atheros.c
> +++ b/drivers/net/phy/atheros.c
> @@ -7,6 +7,7 @@
>   * Copyright (c) 2019 Michael Walle <michael@walle.cc>
>   */
>  #include <common.h>
> +#include <log.h>
>  #include <phy.h>
>  #include <dm/device_compat.h>
>  #include <linux/bitfield.h>
> @@ -197,6 +198,16 @@ static int ar803x_of_init(struct phy_device *phydev)
>         u32 strength, freq, min_uV, max_uV;
>         int sel;
>
> +       /*
> +        * This driver requires OF_CONTROL but this is included on some boards
> +        * that don't support it in SPL. Return an error so the board vendor
> +        * can resolve this.
> +        */
> +       if (!CONFIG_IS_ENABLED(OF_CONTROL)) {
> +               log_err("atheros driver requires OF_CONTROL enabled");
> +               return -ENOSYS;
> +       }
> +
>         node = phy_get_ofnode(phydev);
>         if (!ofnode_valid(node))
>                 return -EINVAL;
> --
> 2.32.0.432.gabb21c7263-goog
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
index f922fecd6b5..cc772f3060f 100644
--- a/drivers/net/phy/atheros.c
+++ b/drivers/net/phy/atheros.c
@@ -7,6 +7,7 @@ 
  * Copyright (c) 2019 Michael Walle <michael@walle.cc>
  */
 #include <common.h>
+#include <log.h>
 #include <phy.h>
 #include <dm/device_compat.h>
 #include <linux/bitfield.h>
@@ -197,6 +198,16 @@  static int ar803x_of_init(struct phy_device *phydev)
 	u32 strength, freq, min_uV, max_uV;
 	int sel;
 
+	/*
+	 * This driver requires OF_CONTROL but this is included on some boards
+	 * that don't support it in SPL. Return an error so the board vendor
+	 * can resolve this.
+	 */
+	if (!CONFIG_IS_ENABLED(OF_CONTROL)) {
+		log_err("atheros driver requires OF_CONTROL enabled");
+		return -ENOSYS;
+	}
+
 	node = phy_get_ofnode(phydev);
 	if (!ofnode_valid(node))
 		return -EINVAL;