From a8b6be4aafea0c9e87cab6b82a2b1be9eea0294f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 22 Jan 2018 08:17:31 -0600 Subject: [PATCH] The existence of the network driver ioctl() method should depend on CONFIG_NETDEV_IOCTL rather than CONFIG_NETDEV_PHY_IOCTL. The former enables the method, the later enables a subset of possible driver IOCTLs. This change should be basically a no-operation. The affected ioctl methods only support those subset of driver IOCTLs selected by CONFIG_NETDEV_PHY_IOCTL and the network logic will tolerate a nul ioctl method. --- arch/arm/src/c5471/c5471_ethernet.c | 2 +- arch/arm/src/kinetis/kinetis_enet.c | 70 ++++----- arch/arm/src/lpc17xx/lpc17_ethernet.c | 2 +- arch/arm/src/lpc43xx/lpc43_ethernet.c | 16 +- arch/arm/src/lpc54xx/lpc54_ethernet.c | 4 + arch/arm/src/sam34/sam_emac.c | 138 +++++++++--------- arch/arm/src/sama5/sam_emaca.c | 138 +++++++++--------- arch/arm/src/sama5/sam_emacb.c | 134 ++++++++--------- arch/arm/src/sama5/sam_gmac.c | 132 +++++++++-------- arch/arm/src/samv7/sam_emac.c | 136 ++++++++--------- arch/arm/src/stm32/stm32_eth.c | 82 ++++++----- arch/arm/src/stm32f7/stm32_ethernet.c | 14 +- arch/arm/src/tiva/tm4c_ethernet.c | 80 +++++----- arch/hc/src/m9s12/m9s12_ethernet.c | 2 +- arch/mips/src/pic32mx/pic32mx-ethernet.c | 2 +- arch/mips/src/pic32mz/pic32mz-ethernet.c | 2 +- arch/misoc/src/common/misoc_net.c | 2 +- arch/z80/src/ez80/ez80_emac.c | 2 +- drivers/net/dm90x0.c | 2 +- drivers/net/enc28j60.c | 2 +- drivers/net/encx24j600.c | 2 +- drivers/net/ftmac100.c | 2 +- drivers/net/tun.c | 2 +- .../wireless/ieee802154/xbee/xbee_netdev.c | 2 +- .../wireless/spirit/drivers/spirit_netdev.c | 2 +- wireless/ieee802154/mac802154_netdev.c | 2 +- 26 files changed, 505 insertions(+), 469 deletions(-) diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c index b98fd6ecac..f38497a37e 100644 --- a/arch/arm/src/c5471/c5471_ethernet.c +++ b/arch/arm/src/c5471/c5471_ethernet.c @@ -2447,7 +2447,7 @@ void up_netinitialize(void) #endif g_c5471[0].c_dev.d_private = (void *)g_c5471; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ g_c5471[0].c_txpoll = wd_create(); /* Create periodic poll timer */ g_c5471[0].c_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c index 8f51cc6a7b..4a7e1ba7ca 100644 --- a/arch/arm/src/kinetis/kinetis_enet.c +++ b/arch/arm/src/kinetis/kinetis_enet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/kinetis/kinetis_enet.c * - * Copyright (C) 2011-2012, 2014-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014-2018 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt * David Sidrane * @@ -310,7 +310,7 @@ static int kinetis_addmac(struct net_driver_s *dev, static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int kinetis_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -1449,48 +1449,52 @@ static int kinetis_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int kinetis_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { - int ret; +#ifdef CONFIG_NETDEV_PHY_IOCTL FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)dev->d_private; +#endif + int ret; switch (cmd) - { - case SIOCGMIIPHY: /* Get MII PHY address */ { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; - } - break; +#ifdef CONFIG_NETDEV_PHY_IOCTL + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = kinetis_readmii(priv, req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = kinetis_readmii(priv, req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = - (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = kinetis_writemii(priv, req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = + (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = kinetis_writemii(priv, req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: kinetis_initmii @@ -2127,12 +2131,12 @@ int kinetis_netinitialize(int intf) priv->dev.d_addmac = kinetis_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = kinetis_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = kinetis_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_enet; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/lpc17xx/lpc17_ethernet.c b/arch/arm/src/lpc17xx/lpc17_ethernet.c index dd1c05d0d1..196b15bab8 100644 --- a/arch/arm/src/lpc17xx/lpc17_ethernet.c +++ b/arch/arm/src/lpc17xx/lpc17_ethernet.c @@ -3056,7 +3056,7 @@ static inline int lpc17_ethinitialize(int intf) priv->lp_irq = ??; /* Ethernet controller IRQ number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->lp_txpoll = wd_create(); /* Create periodic poll timer */ priv->lp_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/lpc43xx/lpc43_ethernet.c b/arch/arm/src/lpc43xx/lpc43_ethernet.c index f5a9cb1e58..e598178811 100644 --- a/arch/arm/src/lpc43xx/lpc43_ethernet.c +++ b/arch/arm/src/lpc43xx/lpc43_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43/lpc43_eth.c * - * Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -621,7 +621,7 @@ static int lpc43_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int lpc43_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2744,16 +2744,17 @@ static void lpc43_rxdescinit(FAR struct lpc43_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) FAR struct lpc43_ethmac_s *priv = (FAR struct lpc43_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { @@ -2791,6 +2792,7 @@ static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) ret = lpc43_phywrite(req->phy_id, req->reg_num, req->val_in); } break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ default: ret = -ENOTTY; @@ -2799,7 +2801,7 @@ static int lpc43_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: lpc43_phyintenable @@ -3823,12 +3825,12 @@ static inline int lpc43_ethinitialize(void) priv->dev.d_addmac = lpc43_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = lpc43_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = lpc43_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_lpc43ethmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmission */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/lpc54xx/lpc54_ethernet.c b/arch/arm/src/lpc54xx/lpc54_ethernet.c index d89317247d..dde91da5c1 100644 --- a/arch/arm/src/lpc54xx/lpc54_ethernet.c +++ b/arch/arm/src/lpc54xx/lpc54_ethernet.c @@ -2392,13 +2392,16 @@ static int lpc54_eth_rmmac(struct net_driver_s *dev, const uint8_t *mac) static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct lpc54_ethdriver_s *priv = (struct lpc54_ethdriver_s *)dev->d_private; +#endif int ret; /* Decode and dispatch the driver-specific IOCTL command */ switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL case SIOCGMIIPHY: /* Get MII PHY address */ { struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); @@ -2422,6 +2425,7 @@ static int lpc54_eth_ioctl(struct net_driver_s *dev, int cmd, ret = OK } break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ default: nerr("ERROR: Unrecognized IOCTL command: %d\n", command); diff --git a/arch/arm/src/sam34/sam_emac.c b/arch/arm/src/sam34/sam_emac.c index c45ea9f383..88d43258d5 100644 --- a/arch/arm/src/sam34/sam_emac.c +++ b/arch/arm/src/sam34/sam_emac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sam34/sam_emac.c * - * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAM34D3 Ethernet driver. @@ -408,7 +408,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2309,86 +2309,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; + + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + + /* Read from the requested register */ + + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; + + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + + /* Write to the requested register */ + + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; +#endif /* ifdef CONFIG_NETDEV_PHY_IOCTL */ + + default: + ret = -ENOTTY; + break; } - break; - - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - - /* Read from the requested register */ - - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; - - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - - /* Write to the requested register */ - - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; - - default: - ret = -ENOTTY; - break; - } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3630,7 +3634,7 @@ void up_netinitialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_emac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/sama5/sam_emaca.c b/arch/arm/src/sama5/sam_emaca.c index 1648cab525..3a011a5b7c 100644 --- a/arch/arm/src/sama5/sam_emaca.c +++ b/arch/arm/src/sama5/sam_emaca.c @@ -4,7 +4,7 @@ * 10/100 Base-T Ethernet driver for the SAMA5D3. Denoted as 'A' to * distinguish it from the SAMA5D4 EMAC driver. * - * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -413,7 +413,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2345,86 +2345,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; + + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + + /* Read from the requested register */ + + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; + + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR); + sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); + + /* Write to the requested register */ + + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ + + default: + ret = -ENOTTY; + break; } - break; - - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - - /* Read from the requested register */ - - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; - - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR); - sam_putreg(priv, SAM_EMAC_NCR, regval | EMAC_NCR_MPE); - - /* Write to the requested register */ - - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR, regval); - } - break; - - default: - ret = -ENOTTY; - break; - } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3672,7 +3676,7 @@ int sam_emac_initialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_emac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/sama5/sam_emacb.c b/arch/arm/src/sama5/sam_emacb.c index c9fb251aca..9f6f366e24 100644 --- a/arch/arm/src/sama5/sam_emacb.c +++ b/arch/arm/src/sama5/sam_emacb.c @@ -507,7 +507,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2715,79 +2715,83 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) #ifdef CONFIG_NETDEV_PHY_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ + { + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) - { - /* Enable PHY link up/down interrupts */ + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ - ret = sam_phyintenable(priv); + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; + + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + + /* Read from the requested register */ + + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; + + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + + /* Write to the requested register */ + + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ + + default: + ret = -ENOTTY; + break; } - break; - - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - - /* Read from the requested register */ - - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; - - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - - /* Write to the requested register */ - - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; - - default: - ret = -ENOTTY; - break; - } return ret; } @@ -4357,9 +4361,9 @@ int sam_emac_initialize(int intf) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) priv->phytype = phytype; /* Type of PHY on port */ #endif #endif diff --git a/arch/arm/src/sama5/sam_gmac.c b/arch/arm/src/sama5/sam_gmac.c index d909962190..d70a40c5a3 100644 --- a/arch/arm/src/sama5/sam_gmac.c +++ b/arch/arm/src/sama5/sam_gmac.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sama5/sam_gmac.c * - * Copyright (C) 2013-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -338,7 +338,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2300,82 +2300,86 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private; +#endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = sam_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; + + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + + /* Enable the management port */ + + sam_enablemdio(priv); + + /* Read from the requested register */ + + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + + /* Disable the management port */ + + sam_disablemdio(priv); + } + break; + + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + + /* Enable the management port */ + + sam_enablemdio(priv); + + /* Write to the requested register */ + + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + + /* Disable the management port */ + + sam_disablemdio(priv); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ + + default: + ret = -ENOTTY; + break; } - break; - - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - - /* Enable the management port */ - - sam_enablemdio(priv); - - /* Read from the requested register */ - - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - - /* Disable the management port */ - - sam_disablemdio(priv); - } - break; - - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - - /* Enable the management port */ - - sam_enablemdio(priv); - - /* Write to the requested register */ - - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - - /* Disable the management port */ - - sam_disablemdio(priv); - } - break; - - default: - ret = -ENOTTY; - break; - } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -3744,12 +3748,12 @@ int sam_gmac_initialize(void) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)&g_gmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); if (!priv->txpoll) diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index 3496331898..94c5956b2b 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -2,7 +2,7 @@ * arch/arm/src/samv7/sam_emac.c * 10/100 Base-T Ethernet driver for the SAMV71. * - * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * This logic derives from the SAMA5 Ethernet driver which, in turn, derived @@ -622,7 +622,7 @@ static int sam_addmac(struct net_driver_s *dev, const uint8_t *mac); static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -3196,86 +3196,90 @@ static int sam_rmmac(struct net_driver_s *dev, const uint8_t *mac) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int sam_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { +#ifdef CONFIG_NETDEV_PHY_IOCTL struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private; +#endif int ret; switch (cmd) - { + { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) - { - /* Enable PHY link up/down interrupts */ + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ - ret = sam_phyintenable(priv); + ret = sam_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = priv->phyaddr; - ret = OK; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = priv->phyaddr; + ret = OK; + } + break; + + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + + /* Read from the requested register */ + + ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; + + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + uint32_t regval; + + /* Enable management port */ + + regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); + + /* Write to the requested register */ + + ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); + + /* Disable management port (probably) */ + + sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ + + default: + ret = -ENOTTY; + break; } - break; - - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - - /* Read from the requested register */ - - ret = sam_phyread(priv, req->phy_id, req->reg_num, &req->val_out); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; - - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - uint32_t regval; - - /* Enable management port */ - - regval = sam_getreg(priv, SAM_EMAC_NCR_OFFSET); - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval | EMAC_NCR_MPE); - - /* Write to the requested register */ - - ret = sam_phywrite(priv, req->phy_id, req->reg_num, req->val_in); - - /* Disable management port (probably) */ - - sam_putreg(priv, SAM_EMAC_NCR_OFFSET, regval); - } - break; - - default: - ret = -ENOTTY; - break; - } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: sam_phydump @@ -5017,9 +5021,9 @@ int sam_emac_initialize(int intf) priv->dev.d_addmac = sam_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = sam_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = sam_ioctl; /* Support PHY ioctl() calls */ -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) priv->phytype = phytype; /* Type of PHY on port */ #endif #endif diff --git a/arch/arm/src/stm32/stm32_eth.c b/arch/arm/src/stm32/stm32_eth.c index 62e44a0ff2..0c2aac1311 100644 --- a/arch/arm/src/stm32/stm32_eth.c +++ b/arch/arm/src/stm32/stm32_eth.c @@ -721,7 +721,7 @@ static int stm32_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int stm32_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2847,62 +2847,64 @@ static void stm32_rxdescinit(FAR struct stm32_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) FAR struct stm32_ethmac_s *priv = (FAR struct stm32_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) - { -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_ARCH_PHY_INTERRUPT + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - ret = stm32_phyintenable(priv); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + ret = stm32_phyintenable(priv); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_STM32_PHYADDR; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = CONFIG_STM32_PHYADDR; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = stm32_phyread(req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: stm32_phyintenable @@ -4014,12 +4016,12 @@ int stm32_ethinitialize(int intf) priv->dev.d_addmac = stm32_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = stm32_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = stm32_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_stm32ethmac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/arm/src/stm32f7/stm32_ethernet.c b/arch/arm/src/stm32f7/stm32_ethernet.c index 8c0eddd847..d5337d8f48 100644 --- a/arch/arm/src/stm32f7/stm32_ethernet.c +++ b/arch/arm/src/stm32f7/stm32_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/stm32f7/stm32_ethernet.c * - * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -732,7 +732,7 @@ static int stm32_addmac(struct net_driver_s *dev, const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int stm32_rmmac(struct net_driver_s *dev, const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2958,16 +2958,17 @@ static void stm32_rxdescinit(struct stm32_ethmac_s *priv, * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { -#ifdef CONFIG_ARCH_PHY_INTERRUPT +#if defined(CONFIG_NETDEV_PHY_IOCTL) && defined(CONFIG_ARCH_PHY_INTERRUPT) struct stm32_ethmac_s *priv = (struct stm32_ethmac_s *)dev->d_private; #endif int ret; switch (cmd) { +#ifdef CONFIG_NETDEV_PHY_IOCTL #ifdef CONFIG_ARCH_PHY_INTERRUPT case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { @@ -3005,6 +3006,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) ret = stm32_phywrite(req->phy_id, req->reg_num, req->val_in); } break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ default: ret = -ENOTTY; @@ -3013,7 +3015,7 @@ static int stm32_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: stm32_phyintenable @@ -4095,7 +4097,7 @@ int stm32_ethinitialize(int intf) priv->dev.d_addmac = stm32_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = stm32_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = stm32_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_stm32ethmac; /* Used to recover private state from dev */ diff --git a/arch/arm/src/tiva/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c_ethernet.c index 3458db363c..be2dd12350 100644 --- a/arch/arm/src/tiva/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/tiva/tm4c_ethernet.c * - * Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015, 2017-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -733,7 +733,7 @@ static int tiva_addmac(struct net_driver_s *dev, FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP static int tiva_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac); #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int tiva_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif @@ -2860,59 +2860,61 @@ static void tiva_rxdescinit(FAR struct tiva_ethmac_s *priv) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL static int tiva_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg) { int ret; switch (cmd) - { -#ifdef CONFIG_TIVA_PHY_INTERRUPTS - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - - ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); - if (ret == OK) +#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_TIVA_PHY_INTERRUPTS + case SIOCMIINOTIFY: /* Set up for PHY event notifications */ { - /* Enable PHY link up/down interrupts */ + struct mii_iotcl_notify_s *req = (struct mii_iotcl_notify_s *)((uintptr_t)arg); - tiva_phy_intenable(true); + ret = phy_notify_subscribe(dev->d_ifname, req->pid, req->signo, req->arg); + if (ret == OK) + { + /* Enable PHY link up/down interrupts */ + + tiva_phy_intenable(true); + } } - } - break; + break; #endif - case SIOCGMIIPHY: /* Get MII PHY address */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - req->phy_id = CONFIG_TIVA_PHYADDR; - ret = OK; - } - break; + case SIOCGMIIPHY: /* Get MII PHY address */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + req->phy_id = CONFIG_TIVA_PHYADDR; + ret = OK; + } + break; - case SIOCGMIIREG: /* Get register from MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = tiva_phyread(req->phy_id, req->reg_num, &req->val_out); - } - break; + case SIOCGMIIREG: /* Get register from MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = tiva_phyread(req->phy_id, req->reg_num, &req->val_out); + } + break; - case SIOCSMIIREG: /* Set register in MII PHY */ - { - struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); - ret = tiva_phywrite(req->phy_id, req->reg_num, req->val_in); - } - break; + case SIOCSMIIREG: /* Set register in MII PHY */ + { + struct mii_ioctl_data_s *req = (struct mii_ioctl_data_s *)((uintptr_t)arg); + ret = tiva_phywrite(req->phy_id, req->reg_num, req->val_in); + } + break; +#endif /* CONFIG_NETDEV_PHY_IOCTL */ - default: - ret = -ENOTTY; - break; - } + default: + ret = -ENOTTY; + break; + } return ret; } -#endif /* CONFIG_NETDEV_PHY_IOCTL */ +#endif /* CONFIG_NETDEV_IOCTL */ /**************************************************************************** * Function: tiva_phy_intenable @@ -4040,7 +4042,7 @@ int tiva_ethinitialize(int intf) priv->dev.d_addmac = tiva_addmac; /* Add multicast MAC address */ priv->dev.d_rmmac = tiva_rmmac; /* Remove multicast MAC address */ #endif -#ifdef CONFIG_NETDEV_PHY_IOCTL +#ifdef CONFIG_NETDEV_IOCTL priv->dev.d_ioctl = tiva_ioctl; /* Support PHY ioctl() calls */ #endif priv->dev.d_private = (void *)g_tiva_ethmac; /* Used to recover private state from dev */ diff --git a/arch/hc/src/m9s12/m9s12_ethernet.c b/arch/hc/src/m9s12/m9s12_ethernet.c index 3b3fcf0d74..a56a267c91 100644 --- a/arch/hc/src/m9s12/m9s12_ethernet.c +++ b/arch/hc/src/m9s12/m9s12_ethernet.c @@ -772,7 +772,7 @@ int emac_initialize(int intf) #endif priv->d_dev.d_private = (void*)g_emac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->d_txpoll = wd_create(); /* Create periodic poll timer */ priv->d_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/mips/src/pic32mx/pic32mx-ethernet.c b/arch/mips/src/pic32mx/pic32mx-ethernet.c index f436b298b6..d772a8ba14 100644 --- a/arch/mips/src/pic32mx/pic32mx-ethernet.c +++ b/arch/mips/src/pic32mx/pic32mx-ethernet.c @@ -3348,7 +3348,7 @@ static inline int pic32mx_ethinitialize(int intf) priv->pd_irqsrc = ??; /* Ethernet controller IRQ source number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->pd_txpoll = wd_create(); /* Create periodic poll timer */ priv->pd_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/mips/src/pic32mz/pic32mz-ethernet.c b/arch/mips/src/pic32mz/pic32mz-ethernet.c index 5e1b2f5e04..046b2861e9 100644 --- a/arch/mips/src/pic32mz/pic32mz-ethernet.c +++ b/arch/mips/src/pic32mz/pic32mz-ethernet.c @@ -3384,7 +3384,7 @@ static inline int pic32mz_ethinitialize(int intf) priv->pd_irqsrc = ??; /* Ethernet controller IRQ source number */ #endif - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->pd_txpoll = wd_create(); /* Create periodic poll timer */ priv->pd_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/misoc/src/common/misoc_net.c b/arch/misoc/src/common/misoc_net.c index a7df365435..595cbbbcff 100644 --- a/arch/misoc/src/common/misoc_net.c +++ b/arch/misoc/src/common/misoc_net.c @@ -1172,7 +1172,7 @@ int misoc_net_initialize(int intf) #endif priv->misoc_net_dev.d_private = (FAR void *)g_misoc_net; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->misoc_net_txpoll = wd_create(); /* Create periodic poll timer */ priv->misoc_net_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c index 55896c08ff..7ef110f811 100644 --- a/arch/z80/src/ez80/ez80_emac.c +++ b/arch/z80/src/ez80/ez80_emac.c @@ -2537,7 +2537,7 @@ int up_netinitialize(void) #endif priv->dev.d_private = (FAR void*)&g_emac; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/dm90x0.c b/drivers/net/dm90x0.c index b6cfa6dfb7..c55c222a99 100644 --- a/drivers/net/dm90x0.c +++ b/drivers/net/dm90x0.c @@ -1948,7 +1948,7 @@ int dm9x_initialize(void) #endif g_dm9x[0].dm_dev.d_private = (FAR void *)g_dm9x; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ g_dm9x[0].dm_txpoll = wd_create(); /* Create periodic poll timer */ g_dm9x[0].dm_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 23c4c77067..9c45d4b115 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -2632,7 +2632,7 @@ int enc_initialize(FAR struct spi_dev_s *spi, #endif priv->dev.d_private = priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 5c2b590e2e..31732a0b68 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -2815,7 +2815,7 @@ int enc_initialize(FAR struct spi_dev_s *spi, #endif priv->dev.d_private = priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 9acc93d643..cb7749706f 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -1554,7 +1554,7 @@ int ftmac100_initialize(int intf) #endif priv->ft_dev.d_private = (FAR void *)g_ftmac100; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->ft_txpoll = wd_create(); /* Create periodic poll timer */ priv->ft_txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 6c5beeba5e..f397f847df 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -891,7 +891,7 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep, nxsem_setprotocol(&priv->read_wait_sem, SEM_PRIO_NONE); - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ diff --git a/drivers/wireless/ieee802154/xbee/xbee_netdev.c b/drivers/wireless/ieee802154/xbee/xbee_netdev.c index d408d21ec3..1c0c682057 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_netdev.c +++ b/drivers/wireless/ieee802154/xbee/xbee_netdev.c @@ -1392,7 +1392,7 @@ int xbee_netdev_register(XBEEHANDLE xbee) #endif dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->xd_mac = xbee; /* Save the MAC interface instance */ priv->xd_txpoll = wd_create(); /* Create periodic poll timer */ diff --git a/drivers/wireless/spirit/drivers/spirit_netdev.c b/drivers/wireless/spirit/drivers/spirit_netdev.c index 9e9b0655c0..e951f3fe0a 100644 --- a/drivers/wireless/spirit/drivers/spirit_netdev.c +++ b/drivers/wireless/spirit/drivers/spirit_netdev.c @@ -2812,7 +2812,7 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi, priv->lower = lower; - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->txpoll = wd_create(); /* Create periodic poll timer */ priv->txtimeout = wd_create(); /* Create TX timeout timer */ diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 953c37f26d..aa4abe8ab2 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -1400,7 +1400,7 @@ int mac802154netdev_register(MACHANDLE mac) #endif dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */ - /* Create a watchdog for timing polling for and timing of transmisstions */ + /* Create a watchdog for timing polling for and timing of transmissions */ priv->md_mac = mac; /* Save the MAC interface instance */ priv->md_txpoll = wd_create(); /* Create periodic poll timer */