From patchwork Mon Oct 19 11:58:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gong Qianyu X-Patchwork-Id: 532259 X-Patchwork-Delegate: yorksun@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 53FBA1402B0 for ; Mon, 19 Oct 2015 23:21:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C93B4B7D6; Mon, 19 Oct 2015 14:21:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ReK6mkJNM-n5; Mon, 19 Oct 2015 14:21:33 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1BCC94B752; Mon, 19 Oct 2015 14:21:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B8C64B6E2 for ; Mon, 19 Oct 2015 14:13:38 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uzkZvE8i4VJO for ; Mon, 19 Oct 2015 14:13:37 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0072.outbound.protection.outlook.com [207.46.100.72]) by theia.denx.de (Postfix) with ESMTPS id 093314B6ED for ; Mon, 19 Oct 2015 14:13:34 +0200 (CEST) Received: from BLUPR03CA008.namprd03.prod.outlook.com (10.255.124.25) by CY1PR0301MB1276.namprd03.prod.outlook.com (10.161.214.24) with Microsoft SMTP Server (TLS) id 15.1.300.14; Mon, 19 Oct 2015 11:59:12 +0000 Received: from BN1BFFO11FD026.protection.gbl (10.255.124.4) by BLUPR03CA008.outlook.office365.com (10.255.124.25) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Mon, 19 Oct 2015 11:59:11 +0000 Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=rhuath.am.freescale.net; lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=rhuath.am.freescale.net; Received-SPF: None (protection.outlook.com: rhuath.am.freescale.net does not designate permitted sender hosts) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD026.mail.protection.outlook.com (10.58.144.89) with Microsoft SMTP Server (TLS) id 15.1.300.4 via Frontend Transport; Mon, 19 Oct 2015 11:59:11 +0000 Received: from rhuath.am.freescale.net (rhuath.am.freescale.net [10.81.117.101]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t9JBxApJ020994; Mon, 19 Oct 2015 04:59:10 -0700 Received: by rhuath.am.freescale.net (Postfix, from userid 65020136) id 7142C2DEC1; Mon, 19 Oct 2015 06:59:10 -0500 (CDT) From: Gong Qianyu To: Date: Mon, 19 Oct 2015 06:58:57 -0500 Message-ID: <1445255949-25021-7-git-send-email-b52263@rhuath.am.freescale.net> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1445255949-25021-6-git-send-email-b52263@rhuath.am.freescale.net> References: <1445255949-25021-1-git-send-email-b52263@rhuath.am.freescale.net> <1445255949-25021-2-git-send-email-b52263@rhuath.am.freescale.net> <1445255949-25021-3-git-send-email-b52263@rhuath.am.freescale.net> <1445255949-25021-4-git-send-email-b52263@rhuath.am.freescale.net> <1445255949-25021-5-git-send-email-b52263@rhuath.am.freescale.net> <1445255949-25021-6-git-send-email-b52263@rhuath.am.freescale.net> X-EOPAttributedMessage: 0 X-Matching-Connectors: 130897295518084846; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD026; 1:shYRfNE7nolHYD4LW868EtYiSB6wAoe9yJZOi8tKL7Tm9scicBHJn7+c7887SnR9lPds3lBCUngrBZcXyHLze/NNM8mSzWy28zsGHQwpdyB+gtiXt7Ztchp03PEOTY67dpFbssx+t+7q/1geGOzSxVvDbCGkGVr4D44tm2se9yxjGnpVzwPaQe2bnTL5e0ddSSIMpkc9M/EfqLTZy7coCes5NHWx/lE6Im9g/Exc1zCnl13dB03koB4VdGQ8X42I7gW39NtfuRNrsA535w4u7wQRuvG7RAY/y/wWDmv180V1+o/xk4L8CCxLSduQXjb2ZppbC7K3NZtAPY7MVc5JT5YQEEjiJJrbPenfI2AlOJjhvfpqhKyX+2aYIit1Dq3QpI7qF8IoSXTNEZTStK8NpQ== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(5008740100001)(2351001)(229853001)(16796002)(90966002)(5001920100001)(48376002)(52956003)(50466002)(92566002)(86362001)(5003940100001)(97736004)(87936001)(103686003)(106466001)(6806005)(105586002)(101416001)(81156007)(76176999)(50986999)(11100500001)(5001960100002)(42186005)(19580405001)(19580395003)(2950100001)(45336002)(110136002)(93886004)(107886002)(33646002)(46102003)(64706001)(5007970100001)(47776003)(50226001)(189998001)(46386002)(42262002)(4001430100001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1276; H:tx30smr01.am.freescale.net; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:0; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1276; 2:fn5pPHirJiTbAHLQ8UCVe9V6c1CIIrDYQqkgCLTRVkniM8H9haglAjxp02WH1dlWmGP6BrPtCEHvhTdyjWK1sxUy0SquwA+nANhtcLbAk3tYqx+QU27mpCdDKbaWHdJhCNAn6zkJNXnxGCwiVJDIqMQMeINxmJnYaNahZbQKIH8=; 3:dGgyQBONGGWLay/GvyRhV97Sv5PIGtM6/Pxy4reMGSC5PIsnrdBuOa5OuNyzTXQSna24WimPzhiZLNcJgg+yUHKPZsBGKvJfyBi3KH/2lQ1UeCtvjPJSVegzwITw5j7UjG/vPH0IaGpwPJw73kOeVcTRtUtZ93oOqf9cSQbjiPLD7ngG+7i+ZVYaJcFCQlM+7nS59z/dt4Plww4iUSC2DsUITtg/zRVjdYuQDYyJQp4=; 25:M9YBeaF9QlCTh0yYWQgw2COJfa/ZlUBibp/hNbgttdD83mmfbRJYrc0LYMreqH41PeBjfuXJhG0/dWk8LoQk5W1ZpBEJH7BFvo1dvAUB3jJ5ATWW0WjhvBNYn+pv57VThrg+dws+YP0C8i84/k7SlvcQn43zZ+DKcBLdIofOiu5BD1WlfinknkfjCAbmzlSfLMw6yEiGUsgtBIUBiwGTuRrgAfyYodVqUBuIhuUbBcnjO/s1PWCvoSjIqrnSTL46/xyMYiMoTARs/Bc45/5lIQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1276; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001); SRVR:CY1PR0301MB1276; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1276; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1276; 4:QV3+uy0cr+qBOk4yhmRj5elerk7hmdjFSUyIoDLxZp/c45V1oQelWncJ0cqr8mHSiG3cizjC9p9DNJagrpye/Diz6W+tmDg9f+ul+UGWZtwnmxzu1jAhpxtVG0ytgt0eNjaak6SCKae24+6aeZtGuF60NdyDyTew0aYUkKxJ9yDsoPA9UVD7sacOrd5AyHCc3IV+szut04KrACBcNdtPHe0QZKxjIAEjRNSbjDLasaYCRxQlZwKzJW5C7lW5T4gAUrT+PPNWO3WPq160UqFyhb14lqmx6cyVRK/cwWyeXvOALeQBZxqzhw92eHwHk1bnkIdLMviJy+Q3/+e0rIYRn0AfS/gi2IK3tGrhJOzf4IQ= X-Forefront-PRVS: 07349BFAD2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1276; 23:foITnQC6u+xe9P3P+JdC9Tw+4ohcRrDVctRk00c?= =?us-ascii?Q?LQXanK0MRgkXYSi4axMHOuyi7KzVI9Yqs4fgx9mICezECDp8vPR2PC8rRQJc?= =?us-ascii?Q?qvyI70Ho0YHk60+TatDgfUbZX/5MyA1R0EaEvRsSMJJuTm0DR4nHVEL1N9UC?= =?us-ascii?Q?GMKtda4BzS0YtGQHJ4M9ylQb7C4MA79g9XCoeEfB2miczTJiHWZemqDSex+l?= =?us-ascii?Q?lO+PB+7dAE6OKWS0afxAh/+OqwEkhD5ROGKXdiJH0QaWSG9zgrnWydMpUXSU?= =?us-ascii?Q?L2H2R+93kTTVGCslIRZz41rU/AZbi3TPNIG6gKtv8gen7KN93HRFOuxm2SFd?= =?us-ascii?Q?8L5/yzak8lfvwAfHgnUCvwJq7e87cpMqmTA6Hm6A2qyyyRXecWJgX/IW+noo?= =?us-ascii?Q?o9sEcS6M4ys6VKDW0l9uLS6yZMQ0gPMuzKEghvUnvGawn7XbqDOoPPZ7UUag?= =?us-ascii?Q?DrJNVo+2Rib+ZHSk+blrCY37dwE0Ci/AoPGepjoU7Mu2828vGKMRIe8J9Jup?= =?us-ascii?Q?AkxXaDlykhT3E/D18/Hp3BIDp7/zNuahwlrGeeO4FDNHmdsTejeiQYMQHjRI?= =?us-ascii?Q?u0mxBTMhtBKnpcRUqV5e61gKZ7HZCBb6IjdcXEJueaOAfTqro5ZyLqM9mONO?= =?us-ascii?Q?pIHQOIfLtfF7zcXjfTnQHkAjUpElC76YsDAL+wmVZuNZIGM+sS1T3MUAxNYX?= =?us-ascii?Q?JX0C0oy4sDQ0TfKRDpf/CccjN48aY2few1+8i0SMg43CboOw1zrd9jDLBUH1?= =?us-ascii?Q?n5vPM+VdLiTDYjlJClsgdLPiSDVw+LnJVw446ph4mnENH6ibt+VkDJchmHwA?= =?us-ascii?Q?/KZNF07B8cmPZNvt0xW0Shq5v08Tn2wCrjLaPoaobNgWeCgiUpcCROItzv//?= =?us-ascii?Q?HKhMexYfJhc0y+Z8X2ZWtTa96ZwhK9E0Ib5Hrc8WcGvyD/4GEc7dX2TrKxF/?= =?us-ascii?Q?NGtxQVCWq3RADAMKlGAZElGh9HL8XvvrAuPALBggfS413UlfvmHksqPxSYn5?= =?us-ascii?Q?PI1m3DWBzd+Mue35K0zVVtQ6JukFB7PlTFHDFdiTq+QVmrJlxISOBBoEQ/JG?= =?us-ascii?Q?a/NuzHO0YNtgahFm9SCcRNwasCnliaY3jx0tfbGnK4QS9VcEEdsQC+8NzZyQ?= =?us-ascii?Q?Qzksuav5X+U4fo92PZ61tkqjgpiy3vC/Kr//M2L5hhzJotM9Had2SpIwDpOQ?= =?us-ascii?Q?ZI7WZFOR33wc8H+kXDegcHZvGWumTEYFd4jLjwxu4g8ZYoiDNq2a8bcxhHVH?= =?us-ascii?Q?SZtZHehm9zgssgrw61uU=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1276; 5:jAN6UWCp5zEDdrAhpZUl/UDhtwwwTJdfUWsSzUTaSS3Zxrt3KCo2L2jcscGOKbWTxzMEVmcyxbGwHecgrpqDotiko5pCtcsVbEEBI14e4WFh8ev33BVPnzUApqNQmWTlAf7HVn03NX26+UACfjVeMFjXfsah0FJClSskey0grUU=; 24:KtN+aXUh9HIQSYAuhSNu0VSa+j19vf1Ld8gkrYt+qzcTZgRHKKpGldftG4XUJyuoTkTIGuAgC75AaYJ0vOhVX0M5UvsuSIioRqvlJe7Osv4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2015 11:59:11.6212 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1276 X-Mailman-Approved-At: Mon, 19 Oct 2015 14:21:14 +0200 Cc: B07421@freescale.com, Gong Qianyu , alison.wang@freescale.com, B48286@freescale.com, Wenbin.Song@freescale.com Subject: [U-Boot] [Patch V6 06/18] net/fm: Make the return value logic consistent with convention X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" From: Hou Zhiqiang In convention, the '0' is a normal return value indicating there isn't an error. While some functions of FMan IM driver treat '0' as an error return value. Signed-off-by: Hou Zhiqiang Signed-off-by: Gong Qianyu --- V6: - No change. V5: - No change. V4: - No change. V3: - New patch. drivers/net/fm/eth.c | 60 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index 6451dce..d7d064b 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -211,7 +211,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) FM_PRAM_SIZE, FM_PRAM_ALIGN); if (!pram) { printf("%s: No muram for Rx global parameter\n", __func__); - return 0; + return -ENOMEM; } fm_eth->rx_pram = pram; @@ -232,14 +232,16 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) rx_bd_ring_base = malloc(sizeof(struct fm_port_bd) * RX_BD_RING_SIZE); if (!rx_bd_ring_base) - return 0; + return -ENOMEM; + memset(rx_bd_ring_base, 0, sizeof(struct fm_port_bd) * RX_BD_RING_SIZE); /* alloc Rx buffer from main memory */ rx_buf_pool = malloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE); if (!rx_buf_pool) - return 0; + return -ENOMEM; + memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE); debug("%s: rx_buf_pool = %p\n", __func__, rx_buf_pool); @@ -277,7 +279,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth) /* set IM parameter ram pointer to Rx Frame Queue ID */ out_be32(&bmi_rx_port->fmbm_rfqid, pram_page_offset); - return 1; + return 0; } static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth) @@ -296,7 +298,7 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth) FM_PRAM_SIZE, FM_PRAM_ALIGN); if (!pram) { printf("%s: No muram for Tx global parameter\n", __func__); - return 0; + return -ENOMEM; } fm_eth->tx_pram = pram; @@ -313,7 +315,8 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth) tx_bd_ring_base = malloc(sizeof(struct fm_port_bd) * TX_BD_RING_SIZE); if (!tx_bd_ring_base) - return 0; + return -ENOMEM; + memset(tx_bd_ring_base, 0, sizeof(struct fm_port_bd) * TX_BD_RING_SIZE); /* save it to fm_eth */ @@ -344,29 +347,35 @@ static int fm_eth_tx_port_parameter_init(struct fm_eth *fm_eth) /* set IM parameter ram pointer to Tx Confirmation Frame Queue ID */ out_be32(&bmi_tx_port->fmbm_tcfqid, pram_page_offset); - return 1; + return 0; } static int fm_eth_init(struct fm_eth *fm_eth) { + int ret; - if (!fm_eth_rx_port_parameter_init(fm_eth)) - return 0; + ret = fm_eth_rx_port_parameter_init(fm_eth); + if (ret) + return ret; - if (!fm_eth_tx_port_parameter_init(fm_eth)) - return 0; + ret = fm_eth_tx_port_parameter_init(fm_eth); + if (ret) + return ret; - return 1; + return 0; } static int fm_eth_startup(struct fm_eth *fm_eth) { struct fsl_enet_mac *mac; + int ret; + mac = fm_eth->mac; /* Rx/TxBDs, Rx/TxQDs, Rx buff and parameter ram init */ - if (!fm_eth_init(fm_eth)) - return 0; + ret = fm_eth_init(fm_eth); + if (ret) + return ret; /* setup the MAC controller */ mac->init_mac(mac); @@ -381,7 +390,7 @@ static int fm_eth_startup(struct fm_eth *fm_eth) /* init bmi tx port, IM mode and disable */ bmi_tx_port_init(fm_eth->tx_port); - return 1; + return 0; } static void fmc_tx_port_graceful_stop_enable(struct fm_eth *fm_eth) @@ -628,7 +637,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) /* alloc mac controller */ mac = malloc(sizeof(struct fsl_enet_mac)); if (!mac) - return 0; + return -ENOMEM; memset(mac, 0, sizeof(struct fsl_enet_mac)); /* save the mac to fm_eth struct */ @@ -643,7 +652,7 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) init_tgec(mac, base, phyregs, MAX_RXBUF_LEN); #endif - return 1; + return 0; } static int init_phy(struct eth_device *dev) @@ -696,17 +705,18 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) struct eth_device *dev; struct fm_eth *fm_eth; int i, num = info->num; + int ret; /* alloc eth device */ dev = (struct eth_device *)malloc(sizeof(struct eth_device)); if (!dev) - return 0; + return -ENOMEM; memset(dev, 0, sizeof(struct eth_device)); /* alloc the FMan ethernet private struct */ fm_eth = (struct fm_eth *)malloc(sizeof(struct fm_eth)); if (!fm_eth) - return 0; + return -ENOMEM; memset(fm_eth, 0, sizeof(struct fm_eth)); /* save off some things we need from the info struct */ @@ -721,8 +731,9 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) fm_eth->max_rx_len = MAX_RXBUF_LEN; /* init global mac structure */ - if (!fm_eth_init_mac(fm_eth, reg)) - return 0; + ret = fm_eth_init_mac(fm_eth, reg); + if (ret) + return ret; /* keep same as the manual, we call FMAN1, FMAN2, DTSEC1, DTSEC2, etc */ if (fm_eth->type == FM_ETH_1G_E) @@ -743,8 +754,9 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) fm_eth->enet_if = info->enet_if; /* startup the FM im */ - if (!fm_eth_startup(fm_eth)) - return 0; + ret = fm_eth_startup(fm_eth); + if (ret) + return ret; init_phy(dev); @@ -753,5 +765,5 @@ int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) dev->enetaddr[i] = 0; eth_register(dev); - return 1; + return 0; }