aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel F. Dickinson <cshored@thecshore.com>2018-07-26 02:57:37 -0400
committerJohn Crispin <john@phrozen.org>2018-07-30 10:43:36 +0200
commit7a3e133751870a3431e2430386a77a002eb24117 (patch)
tree7b445be66114f8d8ab291d6130f1d952ade4ea26
parent0b9f4e880807e3cfd22d12b929202e1edcdc577c (diff)
downloadupstream-7a3e133751870a3431e2430386a77a002eb24117.tar.gz
upstream-7a3e133751870a3431e2430386a77a002eb24117.tar.bz2
upstream-7a3e133751870a3431e2430386a77a002eb24117.zip
ar71xx: ag71xx: Prevent kernel oops for board def
The driver is written in such a way that with a board defintion that connects a fixed phy, mdio, and switch in a certain way, a kernel oops could result because of lack of previously probed mdio bus. This commit allows for easier debugging in this case by casting the correct blame with serial console messages. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
-rw-r--r--target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
index 1683fce882..58db559ecf 100644
--- a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
+++ b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_phy.c
@@ -76,10 +76,24 @@ void ag71xx_phy_stop(struct ag71xx *ag)
static int ag71xx_phy_connect_fixed(struct ag71xx *ag)
{
- struct device *dev = &ag->pdev->dev;
+ struct platform_device *pdev = ag->pdev;
+ struct device *dev = NULL;
struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag);
int ret = 0;
+ if (!pdev)
+ return -ENODEV;
+
+ dev = &pdev->dev;
+
+ if (!dev)
+ return -ENODEV;
+
+ if (!ag->phy_dev) {
+ pr_err("Missing PHY for %s", dev_name(dev));
+ return -ENODEV;
+ }
+
/* use fixed settings */
switch (pdata->speed) {
case SPEED_10: