From patchwork Tue Apr 8 07:15:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 3947851 Return-Path: X-Original-To: patchwork-linux-sh@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 459B9BFF02 for ; Tue, 8 Apr 2014 07:15:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35E4420266 for ; Tue, 8 Apr 2014 07:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C7CA2012D for ; Tue, 8 Apr 2014 07:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756370AbaDHHP0 (ORCPT ); Tue, 8 Apr 2014 03:15:26 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:62316 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbaDHHPW (ORCPT ); Tue, 8 Apr 2014 03:15:22 -0400 Received: by mail-pd0-f180.google.com with SMTP id v10so611463pde.39 for ; Tue, 08 Apr 2014 00:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:subject:user-agent:to:cc:mime-version :content-type; bh=j23pKytbL29/zvRKSpn0ZFhofpOZGFYoQOxeN3huO20=; b=c6HC8r8WhBHUADzyMW0txa9ZWQYhGsGM6+KWTJXIgzL2Y9/YwhdFGbdrvHgv+HruR+ 77V8YIX1VbcnoLS9xh4Py+KnLHAeoVwAEORfKuwR8vkTDPrxcNTLEeh9sQNuGydEFzW8 2ZMnqbMcxzQEVy4BKZh+KRgQuhDYyobhIl4ryHxvPcg+N1HFPchiKEWViobdInemlQFf +KDUP1MxhQihJ5PpFBAV/RtBQoOEoADhApuDI07u1j4UbZQex6p34akJ/9vpOutjxGsQ QQZGsgAaqK/eVFBfv5gIMoUd/GTfpwkJGQ7PRtSXm9aD7gWmwvmkhT+RAcTRfxzfRQKJ SREA== X-Received: by 10.66.162.74 with SMTP id xy10mr2644966pab.4.1396941322234; Tue, 08 Apr 2014 00:15:22 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id fg12sm5958163pac.28.2014.04.08.00.15.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 08 Apr 2014 00:15:21 -0700 (PDT) Date: Tue, 08 Apr 2014 00:15:21 -0700 (PDT) Message-ID: <87txa4thq0.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto Subject: [PATCH][RFC] ARM: shmobile: lager: move res/data into init function User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Simon Cc: Magnus , linux-sh@vger.kernel.org, Kuninori Morimoto , Kuninori Morimoto MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Kuninori Morimoto platform_device_register_xxx() uses kmemdup() for res / data. This means we can move these codes into init function if it was defined. Signed-off-by: Kuninori Morimoto --- >> Simon, Magnus This is not exciting patch, but cleanup code. This is focusing to lager only at this point. Actually, I would like to create board_add_xxx() function for all devices, on all board-xxx.c / setup-xxx.c Because, board-xxx.c has many global variable, but, almost all are copied by kmemdup() and removed by __init. It will be more readable if these are inside board_add_xxx() function. Yes, not exciting... arch/arm/mach-shmobile/board-lager.c | 144 +++++++++++++++++----------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index f0104bf..78625ff 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -116,17 +116,17 @@ static const struct rcar_du_platform_data lager_du_pdata __initconst = { .num_encoders = ARRAY_SIZE(lager_du_encoders), }; -static const struct resource du_resources[] __initconst = { - DEFINE_RES_MEM(0xfeb00000, 0x70000), - DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"), - DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"), - DEFINE_RES_IRQ(gic_spi(256)), - DEFINE_RES_IRQ(gic_spi(268)), - DEFINE_RES_IRQ(gic_spi(269)), -}; - static void __init lager_add_du_device(void) { + struct resource du_resources[] = { + DEFINE_RES_MEM(0xfeb00000, 0x70000), + DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"), + DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"), + DEFINE_RES_IRQ(gic_spi(256)), + DEFINE_RES_IRQ(gic_spi(268)), + DEFINE_RES_IRQ(gic_spi(269)), + }; + struct platform_device_info info = { .name = "rcar-du-r8a7790", .id = -1, @@ -341,18 +341,18 @@ static const struct resource qspi_resources[] __initconst = { }; /* VIN */ -static const struct resource vin_resources[] __initconst = { - /* VIN0 */ - DEFINE_RES_MEM(0xe6ef0000, 0x1000), - DEFINE_RES_IRQ(gic_spi(188)), - /* VIN1 */ - DEFINE_RES_MEM(0xe6ef1000, 0x1000), - DEFINE_RES_IRQ(gic_spi(189)), -}; - static void __init lager_add_vin_device(unsigned idx, struct rcar_vin_platform_data *pdata) { + struct resource vin_resources[] = { + /* VIN0 */ + DEFINE_RES_MEM(0xe6ef0000, 0x1000), + DEFINE_RES_IRQ(gic_spi(188)), + /* VIN1 */ + DEFINE_RES_MEM(0xe6ef1000, 0x1000), + DEFINE_RES_IRQ(gic_spi(189)), + }; + struct platform_device_info vin_info = { .parent = &platform_bus, .name = "r8a7790-vin", @@ -559,13 +559,6 @@ static struct i2c_board_info i2c2_devices[] = { }; /* Sound */ -static struct resource rsnd_resources[] __initdata = { - [RSND_GEN2_SCU] = DEFINE_RES_MEM(0xec500000, 0x1000), - [RSND_GEN2_ADG] = DEFINE_RES_MEM(0xec5a0000, 0x100), - [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000), - [RSND_GEN2_SSI] = DEFINE_RES_MEM(0xec541000, 0x1280), -}; - static struct rsnd_ssi_platform_info rsnd_ssi[] = { RSND_SSI_SET(0, 0, gic_spi(370), RSND_SSI_PLAY), RSND_SSI_SET(0, 0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), @@ -583,25 +576,32 @@ static struct rcar_snd_info rsnd_info = { .scu_info_nr = ARRAY_SIZE(rsnd_scu), }; -static struct asoc_simple_card_info rsnd_card_info = { - .name = "AK4643", - .card = "SSI01-AK4643", - .codec = "ak4642-codec.2-0012", - .platform = "rcar_sound", - .daifmt = SND_SOC_DAIFMT_LEFT_J, - .cpu_dai = { - .name = "rcar_sound", - .fmt = SND_SOC_DAIFMT_CBS_CFS, - }, - .codec_dai = { - .name = "ak4642-hifi", - .fmt = SND_SOC_DAIFMT_CBM_CFM, - .sysclk = 11289600, - }, -}; - static void __init lager_add_rsnd_device(void) { + struct resource rsnd_resources[] = { + [RSND_GEN2_SCU] = DEFINE_RES_MEM(0xec500000, 0x1000), + [RSND_GEN2_ADG] = DEFINE_RES_MEM(0xec5a0000, 0x100), + [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000), + [RSND_GEN2_SSI] = DEFINE_RES_MEM(0xec541000, 0x1280), + }; + + struct asoc_simple_card_info rsnd_card_info = { + .name = "AK4643", + .card = "SSI01-AK4643", + .codec = "ak4642-codec.2-0012", + .platform = "rcar_sound", + .daifmt = SND_SOC_DAIFMT_LEFT_J, + .cpu_dai = { + .name = "rcar_sound", + .fmt = SND_SOC_DAIFMT_CBS_CFS, + }, + .codec_dai = { + .name = "ak4642-hifi", + .fmt = SND_SOC_DAIFMT_CBM_CFM, + .sysclk = 11289600, + }, + }; + struct platform_device_info cardinfo = { .parent = &platform_bus, .name = "asoc-simple-card", @@ -651,44 +651,44 @@ static struct resource sdhi2_resources[] __initdata = { }; /* Internal PCI1 */ -static const struct resource pci1_resources[] __initconst = { - DEFINE_RES_MEM(0xee0b0000, 0x10000), /* CFG */ - DEFINE_RES_MEM(0xee0a0000, 0x10000), /* MEM */ - DEFINE_RES_IRQ(gic_spi(112)), -}; - -static const struct platform_device_info pci1_info __initconst = { - .parent = &platform_bus, - .name = "pci-rcar-gen2", - .id = 1, - .res = pci1_resources, - .num_res = ARRAY_SIZE(pci1_resources), - .dma_mask = DMA_BIT_MASK(32), -}; - static void __init lager_add_usb1_device(void) { + struct resource pci1_resources[] = { + DEFINE_RES_MEM(0xee0b0000, 0x10000), /* CFG */ + DEFINE_RES_MEM(0xee0a0000, 0x10000), /* MEM */ + DEFINE_RES_IRQ(gic_spi(112)), + }; + + struct platform_device_info pci1_info = { + .parent = &platform_bus, + .name = "pci-rcar-gen2", + .id = 1, + .res = pci1_resources, + .num_res = ARRAY_SIZE(pci1_resources), + .dma_mask = DMA_BIT_MASK(32), + }; + platform_device_register_full(&pci1_info); } /* Internal PCI2 */ -static const struct resource pci2_resources[] __initconst = { - DEFINE_RES_MEM(0xee0d0000, 0x10000), /* CFG */ - DEFINE_RES_MEM(0xee0c0000, 0x10000), /* MEM */ - DEFINE_RES_IRQ(gic_spi(113)), -}; - -static const struct platform_device_info pci2_info __initconst = { - .parent = &platform_bus, - .name = "pci-rcar-gen2", - .id = 2, - .res = pci2_resources, - .num_res = ARRAY_SIZE(pci2_resources), - .dma_mask = DMA_BIT_MASK(32), -}; - static void __init lager_add_usb2_device(void) { + struct resource pci2_resources[] = { + DEFINE_RES_MEM(0xee0d0000, 0x10000), /* CFG */ + DEFINE_RES_MEM(0xee0c0000, 0x10000), /* MEM */ + DEFINE_RES_IRQ(gic_spi(113)), + }; + + struct platform_device_info pci2_info = { + .parent = &platform_bus, + .name = "pci-rcar-gen2", + .id = 2, + .res = pci2_resources, + .num_res = ARRAY_SIZE(pci2_resources), + .dma_mask = DMA_BIT_MASK(32), + }; + platform_device_register_full(&pci2_info); }