From patchwork Fri Dec 14 11:02:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 206390 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9E6A32C0090 for ; Fri, 14 Dec 2012 22:04:35 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756188Ab2LNLDA (ORCPT ); Fri, 14 Dec 2012 06:03:00 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:35023 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756167Ab2LNLC6 (ORCPT ); Fri, 14 Dec 2012 06:02:58 -0500 Received: by mail-la0-f46.google.com with SMTP id p5so2681081lag.19 for ; Fri, 14 Dec 2012 03:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=lvpg4LILYyWPfnUFHhXHpsV+mt94sYnnjtvfM0kZjYQ=; b=nRFOycGv7v/FaoaILxu6ueMT9EXWdlT4Uzj01B2upgQu/Uem5ro87AnX1D1DN7v4KT wvjFQ5lLth9r8Z9DRomhm5mXaAAXnU6L7USmRJ3xMNrxrP9t4DoampoZ9K7YwzQF0B4p jUGWzaCR+okSDxxRnqCbinhyr5JV4rhth1oNeJ0SBGF0DspDbjCVmYaqzNbdr0aQ35+y 6Y5YtHJDn2HXqOrpp5IRPI1jUs0FQrWQpxR2IBj986pkNuXPQPMeKVUbEVMo4vdkZR93 OEyj1KNobBB8Ma4D0Wqf019w77I8yC/v3KcKqmsA4hvHMTFpX1SToY20ANw5lL/XLvtK plgg== Received: by 10.112.46.70 with SMTP id t6mr2209185lbm.107.1355482976462; Fri, 14 Dec 2012 03:02:56 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id b3sm1761978lbl.0.2012.12.14.03.02.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 03:02:55 -0800 (PST) Subject: [PATCH 07/12] stmmac: fix platform driver unregistering To: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Cc: Giuseppe Cavallaro , netdev@vger.kernel.org Date: Fri, 14 Dec 2012 15:02:51 +0400 Message-ID: <20121214110251.11019.9914.stgit@zurg> In-Reply-To: <20121214110229.11019.63713.stgit@zurg> References: <20121214110229.11019.63713.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes platform device drivers unregistering and adds proper error handing on module loading. Signed-off-by: Konstantin Khlebnikov Cc: Giuseppe Cavallaro Cc: netdev@vger.kernel.org --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 6 +++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 22 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 023a4fb..b05df89 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -127,14 +127,14 @@ static inline int stmmac_register_platform(void) } static inline void stmmac_unregister_platform(void) { - platform_driver_register(&stmmac_pltfr_driver); + platform_driver_unregister(&stmmac_pltfr_driver); } #else static inline int stmmac_register_platform(void) { pr_debug("stmmac: do not register the platf driver\n"); - return -EINVAL; + return 0; } static inline void stmmac_unregister_platform(void) { @@ -162,7 +162,7 @@ static inline int stmmac_register_pci(void) { pr_debug("stmmac: do not register the PCI driver\n"); - return -EINVAL; + return 0; } static inline void stmmac_unregister_pci(void) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 542edbc..f07c061 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2194,18 +2194,20 @@ int stmmac_restore(struct net_device *ndev) */ static int __init stmmac_init(void) { - int err_plt = 0; - int err_pci = 0; - - err_plt = stmmac_register_platform(); - err_pci = stmmac_register_pci(); - - if ((err_pci) && (err_plt)) { - pr_err("stmmac: driver registration failed\n"); - return -EINVAL; - } + int ret; + ret = stmmac_register_platform(); + if (ret) + goto err; + ret = stmmac_register_pci(); + if (ret) + goto err_pci; return 0; +err_pci: + stmmac_unregister_platform(); +err: + pr_err("stmmac: driver registration failed\n"); + return ret; } static void __exit stmmac_exit(void)