Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755427AbdGKHbC (ORCPT ); Tue, 11 Jul 2017 03:31:02 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36617 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755291AbdGKHbA (ORCPT ); Tue, 11 Jul 2017 03:31:00 -0400 From: Joel Stanley To: Greg Kroah-Hartman Cc: Christopher Bostic , Jeremy Kerr , linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Subject: [PATCH] fsi: core: register with postcore_initcall Date: Tue, 11 Jul 2017 17:00:39 +0930 Message-Id: <20170711073039.20700-1-joel@jms.id.au> X-Mailer: git-send-email 2.13.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1767 Lines: 52 When testing an i2c driver that is a fsi bus driver, I saw the following oops: kernel BUG at drivers/base/driver.c:153! Internal error: Oops - BUG: 0 [#1] ARM [<8027cb1c>] (driver_register) from [<80344e88>] (fsi_driver_register+0x2c/0x38) [<80344e88>] (fsi_driver_register) from [<805f5ebc>] (fsi_i2c_driver_init+0x1c/0x24) [<805f5ebc>] (fsi_i2c_driver_init) from [<805d1f14>] (do_one_initcall+0xb4/0x170) [<805d1f14>] (do_one_initcall) from [<805d20f0>] (kernel_init_freeable+0x120/0x1dc) [<805d20f0>] (kernel_init_freeable) from [<8043f4a8>] (kernel_init+0x18/0x104) [<8043f4a8>] (kernel_init) from [<8000a5e8>] (ret_from_fork+0x14/0x2c) This is because the fsi bus had not been registered. This fix registers the bus with postcore_initcall instead, to ensure it is registered earlier on. When the fsi core is used as a module this should not be a problem as the fsi driver will depend on the fsi bus type symbol, and will therefore load the core before the driver. Fixes: 0508ad1fff11 ("drivers/fsi: Add empty fsi bus definitions") Signed-off-by: Joel Stanley --- drivers/fsi/fsi-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index a88df7a2b466..5966ecb72f37 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -889,17 +889,16 @@ struct bus_type fsi_bus_type = { }; EXPORT_SYMBOL_GPL(fsi_bus_type); -static int fsi_init(void) +static int __init fsi_init(void) { return bus_register(&fsi_bus_type); } +postcore_initcall(fsi_init); static void fsi_exit(void) { bus_unregister(&fsi_bus_type); } - -module_init(fsi_init); module_exit(fsi_exit); module_param(discard_errors, int, 0664); MODULE_LICENSE("GPL"); -- 2.13.2