From patchwork Thu Aug 8 17:00:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Dunn X-Patchwork-Id: 2841316 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9AE03BF546 for ; Thu, 8 Aug 2013 17:02:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FF6A2025A for ; Thu, 8 Aug 2013 17:02:09 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DECD520257 for ; Thu, 8 Aug 2013 17:02:07 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7TbB-0002LM-Pn; Thu, 08 Aug 2013 17:02:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Tb9-0003b6-Jo; Thu, 08 Aug 2013 17:02:03 +0000 Received: from smtp.newsguy.com ([74.209.136.69]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V7Tb6-0003Yj-Ai for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2013 17:02:01 +0000 Received: from localhost.localdomain (40.sub-70-199-128.myvzw.com [70.199.128.40]) by smtp.newsguy.com (8.14.3/8.14.3) with ESMTP id r78H0bvV022207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Aug 2013 10:00:38 -0700 (PDT) (envelope-from mikedunn@newsguy.com) From: Mike Dunn To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: pxa: make pwm driver module_platform_driver Date: Thu, 8 Aug 2013 10:00:37 -0700 Message-Id: <1375981237-7167-1-git-send-email-mikedunn@newsguy.com> X-Mailer: git-send-email 1.8.1.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130808_130200_485028_02710128 X-CRM114-Status: GOOD ( 12.20 ) X-Spam-Score: -1.9 (-) Cc: Marek Vasut , linux-pwm@vger.kernel.org, Mike Dunn , Thierry Reding , Haojian Zhuang , Chao Xie , Eric Miao , H Hartley Sweeten , Robert Jarzmik X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Commit 76abbdde2d95a3807d0dc6bf9f84d03d0dbd4f3d pwm: Add sysfs interface causes a kernel oops due to a null pointer dereference on pxa platforms. This happens because the class added by the patch is registered in a subsys_initcall (initcall4), but the pxa pwm driver is registered in arch_initcall (initcall3). If the class is not registered before the driver probe function runs, the oops occurs in device_add() when the uninitialized pointers in struct class are dereferenced. I don't see a reason that the driver must be an arch_initcall, so this patch makes it a regular module_platform_driver (initcall6), preventing the oops. Signed-off-by: Mike Dunn Acked-by: Robert Jarzmik Acked-by: Marek Vasut --- drivers/pwm/pwm-pxa.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index dc97175..a4d2164 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -182,16 +182,6 @@ static struct platform_driver pwm_driver = { .id_table = pwm_id_table, }; -static int __init pwm_init(void) -{ - return platform_driver_register(&pwm_driver); -} -arch_initcall(pwm_init); - -static void __exit pwm_exit(void) -{ - platform_driver_unregister(&pwm_driver); -} -module_exit(pwm_exit); +module_platform_driver(pwm_driver); MODULE_LICENSE("GPL v2");