Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53BF6C433FE for ; Wed, 13 Apr 2022 02:17:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36B5683DD2; Wed, 13 Apr 2022 04:16:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649816180; bh=QrC7/AjGj2Y0RVJ1lclinK6NRhSM9BpoZI9BhJUg3Jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=my3Qep8KwejXMgWSm/LlPCVqPUnjTn+2D7EJTOXBDkR1wKzwjUhQK1TPZUSDC30C8 qJeDQWj43BVa2t7omhcDJcRsg3K3ihs0ZkY7II6Kx+jTraHD+GHwLsz/8PGKjSJd62 WJMmu8hk8wZHibqdaePCAOm6wHT3sOhbSfURnRyfe6fRrR2WXveGee6YLJNscKW/xb 2gq4fcT3WACEASlZZ7N1ZgyqiO3DEA/IS4cOdCv/pNXAHODV2Yg3NGlzechvVWESZn 2BG4x3uZhU2sFwjl9PUIO3XHLxwsoh2WdDJLKRUz4hbNPWBhjbcERN3JqA8B5qgyPQ HYT16w+z6ujLA== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id D90EF83D7D; Wed, 13 Apr 2022 04:16:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649816161; bh=QrC7/AjGj2Y0RVJ1lclinK6NRhSM9BpoZI9BhJUg3Jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RxtKPRXeTaQe8Iqpgg7HM/9bifQaZDHSsDbRZK5pTIyR0OpH92ilFwziVpO+3OfdR P6795f2OYZLwUHNBtcSw6BsD0M0IqNLh+ccuOpbDM18eESGnttUE9V5QkRQLEo2EHn fMj2XDZysiS41ulF2yPQ8ibS6L9EoCG/e8vv84hpg6pS2zwQVWRwmDMo7HYrjKJl7y NLKZRAvmZhxifdEJBUpqF7PKeBEXMfNbZgcTSFYyhgqe+R1Pd/O+Z7qf7g4dpQARSt tbjjEd4VUVoC7ClOhuywERK/+Z0zhIbaOleJRFcifr9FZb9tCEFCZHEu32vE3a2UB3 vijGhVsL+2hxQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ramon Fried , Joe Hershberger Subject: [PATCH v2 08/17] net: dm9000: Reorder and staticize Date: Wed, 13 Apr 2022 04:15:30 +0200 Message-Id: <20220413021539.454331-8-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220413021539.454331-1-marex@denx.de> References: <20220413021539.454331-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Reorder the driver functions to get rid of forward declarations. Staticize whatever is possible. No functional change. Reviewed-by: Ramon Fried Signed-off-by: Marek Vasut Cc: Joe Hershberger Cc: Ramon Fried --- V2: Add RB from Ramon --- drivers/net/dm9000x.c | 122 +++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 67 deletions(-) diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index becf7aec828..85f3c079ec1 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -79,13 +79,6 @@ struct board_info { static struct board_info dm9000_info; -/* function declaration ------------------------------------- */ -static int dm9000_probe(void); -static u16 dm9000_phy_read(int); -static void dm9000_phy_write(int, u16); -static u8 dm9000_ior(int); -static void dm9000_iow(int reg, u8 value); - /* DM9000 network board routine ---------------------------- */ #ifndef CONFIG_DM9000_BYTE_SWAPPED #define dm9000_outb(d, r) writeb((d), (r)) @@ -205,11 +198,64 @@ static void dm9000_rx_status_8bit(u16 *rxstatus, u16 *rxlen) (dm9000_inb(DM9000_DATA) << 8)); } +/* + * Read a byte from I/O port + */ +static u8 dm9000_ior(int reg) +{ + dm9000_outb(reg, DM9000_IO); + return dm9000_inb(DM9000_DATA); +} + +/* + * Write a byte to I/O port + */ +static void dm9000_iow(int reg, u8 value) +{ + dm9000_outb(reg, DM9000_IO); + dm9000_outb(value, DM9000_DATA); +} + +/* + * Read a word from phyxcer + */ +static u16 dm9000_phy_read(int reg) +{ + u16 val; + + /* Fill the phyxcer register into REG_0C */ + dm9000_iow(DM9000_EPAR, DM9000_PHY | reg); + dm9000_iow(DM9000_EPCR, 0xc); /* Issue phyxcer read command */ + udelay(100); /* Wait read complete */ + dm9000_iow(DM9000_EPCR, 0x0); /* Clear phyxcer read command */ + val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL); + + /* The read data keeps on REG_0D & REG_0E */ + debug("%s(0x%x): 0x%x\n", __func__, reg, val); + return val; +} + +/* + * Write a word to phyxcer + */ +static void dm9000_phy_write(int reg, u16 value) +{ + /* Fill the phyxcer register into REG_0C */ + dm9000_iow(DM9000_EPAR, DM9000_PHY | reg); + + /* Fill the written data into REG_0D & REG_0E */ + dm9000_iow(DM9000_EPDRL, (value & 0xff)); + dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff)); + dm9000_iow(DM9000_EPCR, 0xa); /* Issue phyxcer write command */ + udelay(500); /* Wait write complete */ + dm9000_iow(DM9000_EPCR, 0x0); /* Clear phyxcer write command */ + debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value); +} + /* * Search DM9000 board, allocate space and register it */ -int -dm9000_probe(void) +static int dm9000_probe(void) { u32 id_val; @@ -543,64 +589,6 @@ static void dm9000_get_enetaddr(struct eth_device *dev) static void dm9000_get_enetaddr(struct eth_device *dev) {} #endif -/* - * Read a byte from I/O port - */ -static u8 -dm9000_ior(int reg) -{ - dm9000_outb(reg, DM9000_IO); - return dm9000_inb(DM9000_DATA); -} - -/* - * Write a byte to I/O port - */ -static void -dm9000_iow(int reg, u8 value) -{ - dm9000_outb(reg, DM9000_IO); - dm9000_outb(value, DM9000_DATA); -} - -/* - * Read a word from phyxcer - */ -static u16 -dm9000_phy_read(int reg) -{ - u16 val; - - /* Fill the phyxcer register into REG_0C */ - dm9000_iow(DM9000_EPAR, DM9000_PHY | reg); - dm9000_iow(DM9000_EPCR, 0xc); /* Issue phyxcer read command */ - udelay(100); /* Wait read complete */ - dm9000_iow(DM9000_EPCR, 0x0); /* Clear phyxcer read command */ - val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL); - - /* The read data keeps on REG_0D & REG_0E */ - debug("%s(0x%x): 0x%x\n", __func__, reg, val); - return val; -} - -/* - * Write a word to phyxcer - */ -static void -dm9000_phy_write(int reg, u16 value) -{ - /* Fill the phyxcer register into REG_0C */ - dm9000_iow(DM9000_EPAR, DM9000_PHY | reg); - - /* Fill the written data into REG_0D & REG_0E */ - dm9000_iow(DM9000_EPDRL, (value & 0xff)); - dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff)); - dm9000_iow(DM9000_EPCR, 0xa); /* Issue phyxcer write command */ - udelay(500); /* Wait write complete */ - dm9000_iow(DM9000_EPCR, 0x0); /* Clear phyxcer write command */ - debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value); -} - int dm9000_initialize(struct bd_info *bis) { struct eth_device *dev = &dm9000_info.netdev; -- 2.35.1