* [PATCH] ARM: imx: use IS_ENABLED() instead of checking for built-in or module
@ 2016-08-29 9:32 Javier Martinez Canillas
2016-09-06 6:42 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2016-08-29 9:32 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Javier Martinez Canillas,
Fabio Estevam, Sascha Hauer, linux-arm-kernel, Russell King,
Shawn Guo
From: Javier Martinez Canillas <javier@osg.samsung.com>
The IS_ENABLED() macro checks if a Kconfig symbol has been enabled either
built-in or as a module, use that macro instead of open coding the same.
Using the macro makes the code more readable by helping abstract away some
of the Kconfig built-in and module enable details.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
---
arch/arm/mach-imx/mach-kzm_arm11_01.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-imx/mach-kzm_arm11_01.c b/arch/arm/mach-imx/mach-kzm_arm11_01.c
index 31df4361996f..e277d9c230e5 100644
--- a/arch/arm/mach-imx/mach-kzm_arm11_01.c
+++ b/arch/arm/mach-imx/mach-kzm_arm11_01.c
@@ -63,7 +63,7 @@
*/
#define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)
-#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
+#if IS_ENABLED(CONFIG_SERIAL_8250)
/*
* KZM-ARM11-01 has an external UART on FPGA
*/
@@ -141,7 +141,7 @@ static inline int kzm_init_ext_uart(void)
/*
* SMSC LAN9118
*/
-#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
+#if IS_ENABLED(CONFIG_SMSC911X)
static struct smsc911x_platform_config kzm_smsc9118_config = {
.phy_interface = PHY_INTERFACE_MODE_MII,
.irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
@@ -201,7 +201,7 @@ static inline int kzm_init_smsc9118(void)
}
#endif
-#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
+#if IS_ENABLED(CONFIG_SERIAL_IMX)
static const struct imxuart_platform_data uart_pdata __initconst = {
.flags = IMXUART_HAVE_RTSCTS,
};
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: imx: use IS_ENABLED() instead of checking for built-in or module
2016-08-29 9:32 [PATCH] ARM: imx: use IS_ENABLED() instead of checking for built-in or module Javier Martinez Canillas
@ 2016-09-06 6:42 ` Uwe Kleine-König
2016-09-07 8:33 ` Javier Martinez Canillas
0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2016-09-06 6:42 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, Russell King, Javier Martinez Canillas,
Sascha Hauer, Fabio Estevam, Shawn Guo, linux-arm-kernel
Hello Javier,
On Mon, Aug 29, 2016 at 11:32:11AM +0200, Javier Martinez Canillas wrote:
> From: Javier Martinez Canillas <javier@osg.samsung.com>
>
> The IS_ENABLED() macro checks if a Kconfig symbol has been enabled either
> built-in or as a module, use that macro instead of open coding the same.
>
> Using the macro makes the code more readable by helping abstract away some
> of the Kconfig built-in and module enable details.
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
The following patch should do the same (untested though) and the source
looks still better:
diff --git a/arch/arm/mach-imx/mach-kzm_arm11_01.c b/arch/arm/mach-imx/mach-kzm_arm11_01.c
index 31df4361996f..48f794dbf293 100644
--- a/arch/arm/mach-imx/mach-kzm_arm11_01.c
+++ b/arch/arm/mach-imx/mach-kzm_arm11_01.c
@@ -63,7 +63,6 @@
*/
#define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)
-#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
/*
* KZM-ARM11-01 has an external UART on FPGA
*/
@@ -106,37 +105,35 @@ static struct platform_device serial_device = {
static int __init kzm_init_ext_uart(void)
{
- u8 tmp;
-
- /*
- * GPIO 1-1: external UART interrupt line
- */
- mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
- gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
- gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
-
- /*
- * Unmask UART interrupt
- */
- tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
- tmp |= 0x2;
- __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
-
- serial_platform_data[0].irq =
- gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
- serial8250_resources[1].start =
- gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
- serial8250_resources[1].end =
- gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
-
- return platform_device_register(&serial_device);
+ if (IS_ENABLED(CONFIG_SERIAL_8250)) {
+ u8 tmp;
+
+ /*
+ * GPIO 1-1: external UART interrupt line
+ */
+ mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
+ gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
+ gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
+
+ /*
+ * Unmask UART interrupt
+ */
+ tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
+ tmp |= 0x2;
+ __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
+
+ serial_platform_data[0].irq =
+ gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
+ serial8250_resources[1].start =
+ gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
+ serial8250_resources[1].end =
+ gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
+
+ return platform_device_register(&serial_device);
+ } else {
+ return 0;
+ }
}
-#else
-static inline int kzm_init_ext_uart(void)
-{
- return 0;
-}
-#endif
/*
* SMSC LAN9118
@@ -178,44 +175,39 @@ static struct regulator_consumer_supply dummy_supplies[] = {
static int __init kzm_init_smsc9118(void)
{
- /*
- * GPIO 1-2: SMSC9118 interrupt line
- */
- mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
- gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
- gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
-
- regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
-
- kzm_smsc9118_resources[1].start =
- gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
- kzm_smsc9118_resources[1].end =
- gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
-
- return platform_device_register(&kzm_smsc9118_device);
+ if (IS_ENABLED(CONFIG_SMSC911X)) {
+ /*
+ * GPIO 1-2: SMSC9118 interrupt line
+ */
+ mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
+ gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
+ gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
+
+ regulator_register_fixed(0, dummy_supplies,
+ ARRAY_SIZE(dummy_supplies));
+
+ kzm_smsc9118_resources[1].start =
+ gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
+ kzm_smsc9118_resources[1].end =
+ gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
+
+ return platform_device_register(&kzm_smsc9118_device);
+ } else {
+ return 0;
+ }
}
-#else
-static inline int kzm_init_smsc9118(void)
-{
- return 0;
-}
-#endif
-#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
static const struct imxuart_platform_data uart_pdata __initconst = {
.flags = IMXUART_HAVE_RTSCTS,
};
static void __init kzm_init_imx_uart(void)
{
- imx31_add_imx_uart0(&uart_pdata);
- imx31_add_imx_uart1(&uart_pdata);
-}
-#else
-static inline void kzm_init_imx_uart(void)
-{
+ if (IS_ENABLED(CONFIG_SERIAL_IMX)) {
+ imx31_add_imx_uart0(&uart_pdata);
+ imx31_add_imx_uart1(&uart_pdata);
+ }
}
-#endif
static int kzm_pins[] __initdata = {
MX31_PIN_CTS1__CTS1,
Having said that, just dropping the #ifdefs and registering the devices
even without the matching driver is fine for me, too.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ARM: imx: use IS_ENABLED() instead of checking for built-in or module
2016-09-06 6:42 ` Uwe Kleine-König
@ 2016-09-07 8:33 ` Javier Martinez Canillas
0 siblings, 0 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2016-09-07 8:33 UTC (permalink / raw)
To: Uwe Kleine-König, Javier Martinez Canillas
Cc: linux-kernel, Russell King, Sascha Hauer, Fabio Estevam,
Shawn Guo, linux-arm-kernel
Hello Uwe,
Thanks for your feedback.
On 09/06/2016 08:42 AM, Uwe Kleine-König wrote:
> Hello Javier,
>
> On Mon, Aug 29, 2016 at 11:32:11AM +0200, Javier Martinez Canillas wrote:
>> From: Javier Martinez Canillas <javier@osg.samsung.com>
>>
>> The IS_ENABLED() macro checks if a Kconfig symbol has been enabled either
>> built-in or as a module, use that macro instead of open coding the same.
>>
>> Using the macro makes the code more readable by helping abstract away some
>> of the Kconfig built-in and module enable details.
>>
>> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
>> Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
>
> The following patch should do the same (untested though) and the source
> looks still better:
>
Yes, your patch looks good to me. But is doing two things at once (using the
IS_ENABLED macro and getting rid of the stub functions / ifdefery) so I would
split it in two different patches.
In any case, $SUBJECT was picked by Shawn already so you could post the other
change on top of it if you want.
> diff --git a/arch/arm/mach-imx/mach-kzm_arm11_01.c b/arch/arm/mach-imx/mach-kzm_arm11_01.c
> index 31df4361996f..48f794dbf293 100644
> --- a/arch/arm/mach-imx/mach-kzm_arm11_01.c
> +++ b/arch/arm/mach-imx/mach-kzm_arm11_01.c
> @@ -63,7 +63,6 @@
> */
> #define KZM_ARM11_16550 (MX31_CS4_BASE_ADDR + 0x1050)
>
> -#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
> /*
> * KZM-ARM11-01 has an external UART on FPGA
> */
> @@ -106,37 +105,35 @@ static struct platform_device serial_device = {
>
> static int __init kzm_init_ext_uart(void)
> {
> - u8 tmp;
> -
> - /*
> - * GPIO 1-1: external UART interrupt line
> - */
> - mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
> - gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
> - gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> -
> - /*
> - * Unmask UART interrupt
> - */
> - tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
> - tmp |= 0x2;
> - __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
> -
> - serial_platform_data[0].irq =
> - gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> - serial8250_resources[1].start =
> - gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> - serial8250_resources[1].end =
> - gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> -
> - return platform_device_register(&serial_device);
> + if (IS_ENABLED(CONFIG_SERIAL_8250)) {
> + u8 tmp;
> +
> + /*
> + * GPIO 1-1: external UART interrupt line
> + */
> + mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO));
> + gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1), "ext-uart-int");
> + gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> +
> + /*
> + * Unmask UART interrupt
> + */
> + tmp = __raw_readb(KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
> + tmp |= 0x2;
> + __raw_writeb(tmp, KZM_ARM11_IO_ADDRESS(KZM_ARM11_CTL1));
> +
> + serial_platform_data[0].irq =
> + gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> + serial8250_resources[1].start =
> + gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> + serial8250_resources[1].end =
> + gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_1));
> +
> + return platform_device_register(&serial_device);
> + } else {
> + return 0;
> + }
> }
> -#else
> -static inline int kzm_init_ext_uart(void)
> -{
> - return 0;
> -}
> -#endif
>
> /*
> * SMSC LAN9118
> @@ -178,44 +175,39 @@ static struct regulator_consumer_supply dummy_supplies[] = {
>
> static int __init kzm_init_smsc9118(void)
> {
> - /*
> - * GPIO 1-2: SMSC9118 interrupt line
> - */
> - mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
> - gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
> - gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> -
> - regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
> -
> - kzm_smsc9118_resources[1].start =
> - gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> - kzm_smsc9118_resources[1].end =
> - gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> -
> - return platform_device_register(&kzm_smsc9118_device);
> + if (IS_ENABLED(CONFIG_SMSC911X)) {
> + /*
> + * GPIO 1-2: SMSC9118 interrupt line
> + */
> + mxc_iomux_mode(IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO));
> + gpio_request(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2), "smsc9118-int");
> + gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> +
> + regulator_register_fixed(0, dummy_supplies,
> + ARRAY_SIZE(dummy_supplies));
> +
> + kzm_smsc9118_resources[1].start =
> + gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> + kzm_smsc9118_resources[1].end =
> + gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_2));
> +
> + return platform_device_register(&kzm_smsc9118_device);
> + } else {
> + return 0;
> + }
> }
> -#else
> -static inline int kzm_init_smsc9118(void)
> -{
> - return 0;
> -}
> -#endif
>
> -#if defined(CONFIG_SERIAL_IMX) || defined(CONFIG_SERIAL_IMX_MODULE)
> static const struct imxuart_platform_data uart_pdata __initconst = {
> .flags = IMXUART_HAVE_RTSCTS,
> };
>
> static void __init kzm_init_imx_uart(void)
> {
> - imx31_add_imx_uart0(&uart_pdata);
> - imx31_add_imx_uart1(&uart_pdata);
> -}
> -#else
> -static inline void kzm_init_imx_uart(void)
> -{
> + if (IS_ENABLED(CONFIG_SERIAL_IMX)) {
> + imx31_add_imx_uart0(&uart_pdata);
> + imx31_add_imx_uart1(&uart_pdata);
> + }
> }
> -#endif
>
> static int kzm_pins[] __initdata = {
> MX31_PIN_CTS1__CTS1,
>
> Having said that, just dropping the #ifdefs and registering the devices
> even without the matching driver is fine for me, too.
>
> Best regards
> Uwe
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-07 8:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-29 9:32 [PATCH] ARM: imx: use IS_ENABLED() instead of checking for built-in or module Javier Martinez Canillas
2016-09-06 6:42 ` Uwe Kleine-König
2016-09-07 8:33 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).