From patchwork Wed Dec 2 16:25:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 7748411 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA878BEEE1 for ; Wed, 2 Dec 2015 16:25:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 866FC205DF for ; Wed, 2 Dec 2015 16:25:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B84EE20503 for ; Wed, 2 Dec 2015 16:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750869AbbLBQZW (ORCPT ); Wed, 2 Dec 2015 11:25:22 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34528 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbbLBQZW (ORCPT ); Wed, 2 Dec 2015 11:25:22 -0500 Received: by wmvv187 with SMTP id v187so263182104wmv.1; Wed, 02 Dec 2015 08:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Suc1UtXvHb8QohjgVdMLChXOzgvzhtCZSmrs2p0xMDY=; b=PLdzPCTWkON3nn04Z/U9YOZ4auLVQsSuoMp9shViQU4Y7Uak+5LpgCNQ7qwCU4mch8 X198nmvyV1z4XEdqDRcujZ5d89iRS0t6MPsmwJArF8meRC6d0WAuh5aBORVudDs+2xb5 8+p3vzQyzfCONyP05Our5iDL7D8Nf1N5UKHUz5hKOy/qhawyvR4j//ZQgH3KdTeMXnwG 0lz197YrQIw2uIJK9JYgFjMWEOpyeb/JwWBfmJ1CMvw76L4CI/c815CCyR6WT41X/J9D UB6UmcR/3vtyGkUDMQ0RMAxApX92lJJuvbCtDetsFVDorzvsm8r922uEAgO2Y/uWnDgx yGYA== X-Received: by 10.28.61.4 with SMTP id k4mr7260376wma.34.1449073520725; Wed, 02 Dec 2015 08:25:20 -0800 (PST) Received: from localhost (port-973.pppoe.wtnet.de. [84.46.3.208]) by smtp.gmail.com with ESMTPSA id kb5sm3473801wjc.20.2015.12.02.08.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Dec 2015 08:25:20 -0800 (PST) From: Thierry Reding To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: sparcspkr - Use platform_register/unregister_drivers() Date: Wed, 2 Dec 2015 17:25:19 +0100 Message-Id: <1449073519-11768-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding These new helpers simplify implementing multi-driver modules and properly handle failure to register one driver by unregistering all previously registered drivers. Signed-off-by: Thierry Reding --- drivers/input/misc/sparcspkr.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index 6f997aa49183..4a5afc7fe96e 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c @@ -345,23 +345,19 @@ static struct platform_driver grover_beep_driver = { .shutdown = sparcspkr_shutdown, }; +static struct platform_driver * const drivers[] = { + &bbc_beep_driver, + &grover_beep_driver, +}; + static int __init sparcspkr_init(void) { - int err = platform_driver_register(&bbc_beep_driver); - - if (!err) { - err = platform_driver_register(&grover_beep_driver); - if (err) - platform_driver_unregister(&bbc_beep_driver); - } - - return err; + return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); } static void __exit sparcspkr_exit(void) { - platform_driver_unregister(&bbc_beep_driver); - platform_driver_unregister(&grover_beep_driver); + platform_unregister_drivers(drivers, ARRAY_SIZE(drivers)); } module_init(sparcspkr_init);