[U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr keywords are replaced with port_no. Also, in some places, this patch replaces in_le32 and out_le32 with clrbits_le32 and setbits_le32 to reduce the number of code lines and to assure that only intended bits of a register are changed. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ib5f7d94bd6a39b909bf7b70bb12e15156a7e45c9 --- drivers/net/vsc9953.c | 100 +- include/vsc9953.h | 47 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..720ae47 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -25,44 +25,44 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, @@ -148,21 +148,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -1; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt = NULL; dev-send = NULL; @@ -170,7 +170,7 @@ static int vsc9953_port_init(int port) if (init_phy(dev)) { free(dev); - return 1; + return -1; } return 0; @@ -255,8 +255,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], CONFIG_VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +CONFIG_VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, CONFIG_VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], @@ -312,25 +312,23 @@ void vsc9953_init(bd_t *bis) #ifdef CONFIG_VSC9953_CMD /* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_nr, u8 enabled) +static void vsc9953_port_status_set(int port_no, u8 enabled) { - u32 val; struct vsc9953_qsys_reg *l2qsys_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled == 0) + if (!vsc9953_l2sw.port[port_no].enabled) return; l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + VSC9953_QSYS_OFFSET); - val =
Re: [U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch
Please ignore this patch. I resent it. Sorry! Best regards, Codrin -Original Message- From: Codrin Ciubotariu [mailto:codrin.ciubota...@freescale.com] Sent: Thursday, June 11, 2015 6:07 PM To: u-boot@lists.denx.de Cc: Kushwaha Prabhakar-B32579; Sun York-R58495; joe.hershber...@ni.com; Ciubotariu Codrin Constantin-B43658 Subject: [PATCH 01/10] drivers/net/vsc9953: Cleanup patch ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/10] drivers/net/vsc9953: Cleanup patch
This patch groups some macros defined for registers and replaces some magic numbers from vsc9953 with macros. Also, port and port_nr keywords are replaced with port_no. Also, in some places, this patch replaces in_le32 and out_le32 with clrbits_le32 and setbits_le32 to reduce the number of code lines and to assure that only intended bits of a register are changed. Signed-off-by: Codrin Ciubotariu codrin.ciubota...@freescale.com Change-Id: Ib5f7d94bd6a39b909bf7b70bb12e15156a7e45c9 --- drivers/net/vsc9953.c | 100 +- include/vsc9953.h | 47 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c index fed7358..720ae47 100644 --- a/drivers/net/vsc9953.c +++ b/drivers/net/vsc9953.c @@ -25,44 +25,44 @@ static struct vsc9953_info vsc9953_l2sw = { .port[9] = VSC9953_PORT_INFO_INITIALIZER(9), }; -void vsc9953_port_info_set_mdio(int port, struct mii_dev *bus) +void vsc9953_port_info_set_mdio(int port_no, struct mii_dev *bus) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].bus = bus; + vsc9953_l2sw.port[port_no].bus = bus; } -void vsc9953_port_info_set_phy_address(int port, int address) +void vsc9953_port_info_set_phy_address(int port_no, int address) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].phyaddr = address; + vsc9953_l2sw.port[port_no].phyaddr = address; } -void vsc9953_port_info_set_phy_int(int port, phy_interface_t phy_int) +void vsc9953_port_info_set_phy_int(int port_no, phy_interface_t phy_int) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enet_if = phy_int; + vsc9953_l2sw.port[port_no].enet_if = phy_int; } -void vsc9953_port_enable(int port) +void vsc9953_port_enable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 1; + vsc9953_l2sw.port[port_no].enabled = 1; } -void vsc9953_port_disable(int port) +void vsc9953_port_disable(int port_no) { - if (!VSC9953_PORT_CHECK(port)) + if (!VSC9953_PORT_CHECK(port_no)) return; - vsc9953_l2sw.port[port].enabled = 0; + vsc9953_l2sw.port[port_no].enabled = 0; } static void vsc9953_mdio_write(struct vsc9953_mii_mng *phyregs, int port_addr, @@ -148,21 +148,21 @@ static int init_phy(struct eth_device *dev) return 0; } -static int vsc9953_port_init(int port) +static int vsc9953_port_init(int port_no) { struct eth_device *dev; /* Internal ports never have a PHY */ - if (VSC9953_INTERNAL_PORT_CHECK(port)) + if (VSC9953_INTERNAL_PORT_CHECK(port_no)) return 0; /* alloc eth device */ dev = (struct eth_device *)calloc(1, sizeof(struct eth_device)); if (!dev) - return 1; + return -1; - sprintf(dev-name, SW@PORT%d, port); - dev-priv = vsc9953_l2sw.port[port]; + sprintf(dev-name, SW@PORT%d, port_no); + dev-priv = vsc9953_l2sw.port[port_no]; dev-init = NULL; dev-halt = NULL; dev-send = NULL; @@ -170,7 +170,7 @@ static int vsc9953_port_init(int port) if (init_phy(dev)) { free(dev); - return 1; + return -1; } return 0; @@ -255,8 +255,8 @@ void vsc9953_init(bd_t *bis) out_le32(l2dev_gmii_reg-mac_cfg_status.mac_hdx_cfg, hdx_cfg); out_le32(l2sys_reg-sys.front_port_mode[i], CONFIG_VSC9953_FRONT_PORT_MODE); - out_le32(l2qsys_reg-sys.switch_port_mode[i], -CONFIG_VSC9953_PORT_ENA); + setbits_le32(l2qsys_reg-sys.switch_port_mode[i], +CONFIG_VSC9953_PORT_ENA); out_le32(l2dev_gmii_reg-mac_cfg_status.mac_maxlen_cfg, CONFIG_VSC9953_MAC_MAX_LEN); out_le32(l2sys_reg-pause_cfg.pause_cfg[i], @@ -312,25 +312,23 @@ void vsc9953_init(bd_t *bis) #ifdef CONFIG_VSC9953_CMD /* Enable/disable status of a VSC9953 port */ -static void vsc9953_port_status_set(int port_nr, u8 enabled) +static void vsc9953_port_status_set(int port_no, u8 enabled) { - u32 val; struct vsc9953_qsys_reg *l2qsys_reg; /* Administrative down */ - if (vsc9953_l2sw.port[port_nr].enabled == 0) + if (!vsc9953_l2sw.port[port_no].enabled) return; l2qsys_reg = (struct vsc9953_qsys_reg *)(VSC9953_OFFSET + VSC9953_QSYS_OFFSET); - val =