linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/mpc512x: remove unnecessary #if
@ 2013-10-11 17:32 Brian Norris
  2013-10-11 17:37 ` Brian Norris
  2013-10-11 17:37 ` [PATCH v2] " Brian Norris
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Norris @ 2013-10-11 17:32 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: Gerhard Sittig, Brian Norris, linuxppc-dev

Several functions are only ever referenced locally, so make them static.
Of those functions, many of them are protected by an #if. However, the
code which can compile fine in either case.

Now that (1) the unneeded code is marked 'static' and (2) the code is
only used under a C 'if (IS_ENABLED(CONFIG_FB_FSL_DIU))', the compiler
can automatically remove the unneeded code, and we don't need the #if or
the empty stub functions.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
Based off of Gerhard Sittig's patch:
  powerpc/mpc512x: silence build warning upon disabled DIU

Compile-tested with CONFIG_FB_FSL_DIU=n

 arch/powerpc/platforms/512x/mpc512x_shared.c | 19 ++++++-------------
 arch/powerpc/sysdev/fsl_soc.h                |  3 +--
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index 1a7b1d0..48e0718 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -60,8 +60,6 @@ void mpc512x_restart(char *cmd)
 		;
 }
 
-#if IS_ENABLED(CONFIG_FB_FSL_DIU)
-
 struct fsl_diu_shared_fb {
 	u8		gamma[0x300];	/* 32-bit aligned! */
 	struct diu_ad	ad0;		/* 32-bit aligned! */
@@ -71,7 +69,7 @@ struct fsl_diu_shared_fb {
 };
 
 #define DIU_DIV_MASK	0x000000ff
-void mpc512x_set_pixel_clock(unsigned int pixclock)
+static void mpc512x_set_pixel_clock(unsigned int pixclock)
 {
 	unsigned long bestval, bestfreq, speed, busfreq;
 	unsigned long minpixclock, maxpixclock, pixval;
@@ -164,7 +162,7 @@ void mpc512x_set_pixel_clock(unsigned int pixclock)
 	iounmap(ccm);
 }
 
-enum fsl_diu_monitor_port
+static enum fsl_diu_monitor_port
 mpc512x_valid_monitor_port(enum fsl_diu_monitor_port port)
 {
 	return FSL_DIU_PORT_DVI;
@@ -179,7 +177,7 @@ static inline void mpc512x_free_bootmem(struct page *page)
 	free_reserved_page(page);
 }
 
-void mpc512x_release_bootmem(void)
+static void mpc512x_release_bootmem(void)
 {
 	unsigned long addr = diu_shared_fb.fb_phys & PAGE_MASK;
 	unsigned long size = diu_shared_fb.fb_len;
@@ -205,7 +203,7 @@ void mpc512x_release_bootmem(void)
  * address range will be reserved in setup_arch() after bootmem
  * allocator is up.
  */
-void __init mpc512x_init_diu(void)
+static void __init mpc512x_init_diu(void)
 {
 	struct device_node *np;
 	struct diu __iomem *diu_reg;
@@ -274,7 +272,7 @@ out:
 	iounmap(diu_reg);
 }
 
-void __init mpc512x_setup_diu(void)
+static void __init mpc512x_setup_diu(void)
 {
 	int ret;
 
@@ -303,11 +301,6 @@ void __init mpc512x_setup_diu(void)
 	diu_ops.release_bootmem		= mpc512x_release_bootmem;
 }
 
-#else
-void __init mpc512x_setup_diu(void) { /* EMPTY */ }
-void __init mpc512x_init_diu(void) { /* EMPTY */ }
-#endif
-
 void __init mpc512x_init_IRQ(void)
 {
 	struct device_node *np;
@@ -340,7 +333,7 @@ static struct of_device_id __initdata of_bus_ids[] = {
 	{},
 };
 
-void __init mpc512x_declare_of_platform_devices(void)
+static void __init mpc512x_declare_of_platform_devices(void)
 {
 	if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
 		printk(KERN_ERR __FILE__ ": "
diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/fsl_soc.h
index c6d0073..f845ffd 100644
--- a/arch/powerpc/sysdev/fsl_soc.h
+++ b/arch/powerpc/sysdev/fsl_soc.h
@@ -21,8 +21,6 @@ struct device_node;
 
 extern void fsl_rstcr_restart(char *cmd);
 
-#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
-
 /* The different ports that the DIU can be connected to */
 enum fsl_diu_monitor_port {
 	FSL_DIU_PORT_DVI,	/* DVI */
@@ -42,6 +40,7 @@ struct platform_diu_data_ops {
 	void (*release_bootmem)(void);
 };
 
+#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 extern struct platform_diu_data_ops diu_ops;
 #endif
 
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/mpc512x: remove unnecessary #if
  2013-10-11 17:32 [PATCH] powerpc/mpc512x: remove unnecessary #if Brian Norris
@ 2013-10-11 17:37 ` Brian Norris
  2013-10-11 17:37 ` [PATCH v2] " Brian Norris
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Norris @ 2013-10-11 17:37 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: Gerhard Sittig, Brian Norris, linuxppc-dev

Hi,

I'm sorry, ignore this version. I left out a diff I meant to include.

On Fri, Oct 11, 2013 at 10:32 AM, Brian Norris
<computersforpeace@gmail.com> wrote:
> Several functions are only ever referenced locally, so make them static.
> Of those functions, many of them are protected by an #if. However, the
> code which can compile fine in either case.
>
> Now that (1) the unneeded code is marked 'static' and (2) the code is
> only used under a C 'if (IS_ENABLED(CONFIG_FB_FSL_DIU))', the compiler
> can automatically remove the unneeded code, and we don't need the #if or
> the empty stub functions.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> Based off of Gerhard Sittig's patch:
>   powerpc/mpc512x: silence build warning upon disabled DIU
>
> Compile-tested with CONFIG_FB_FSL_DIU=n

...

> @@ -42,6 +40,7 @@ struct platform_diu_data_ops {
>         void (*release_bootmem)(void);
>  };
>
> +#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
>  extern struct platform_diu_data_ops diu_ops;
>  #endif

The above hunk is incorrect. I will send v2.

Brian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] powerpc/mpc512x: remove unnecessary #if
  2013-10-11 17:32 [PATCH] powerpc/mpc512x: remove unnecessary #if Brian Norris
  2013-10-11 17:37 ` Brian Norris
@ 2013-10-11 17:37 ` Brian Norris
  2013-10-30 22:12   ` Anatolij Gustschin
  1 sibling, 1 reply; 4+ messages in thread
From: Brian Norris @ 2013-10-11 17:37 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: Gerhard Sittig, Brian Norris, linuxppc-dev

Several functions are only ever referenced locally, so make them static.
Of those functions, many of them are protected by an #if. However, the
code which can compile fine in either case.

Now that (1) the unneeded code is marked 'static' and (2) the code is
only used under a C 'if (IS_ENABLED(CONFIG_FB_FSL_DIU))', the compiler
can automatically remove the unneeded code, and we don't need the #if or
the empty stub functions.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
v2: left out a diff I was holding locally (to remove an #if/#endif
    completely). Sorry for the noise.

Based off of Gerhard Sittig's patch:
  powerpc/mpc512x: silence build warning upon disabled DIU

Compile-tested with CONFIG_FB_FSL_DIU=n

 arch/powerpc/platforms/512x/mpc512x_shared.c | 21 +++++++--------------
 arch/powerpc/sysdev/fsl_soc.h                |  3 ---
 2 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index 1a7b1d0..36b5652 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -60,8 +60,6 @@ void mpc512x_restart(char *cmd)
 		;
 }
 
-#if IS_ENABLED(CONFIG_FB_FSL_DIU)
-
 struct fsl_diu_shared_fb {
 	u8		gamma[0x300];	/* 32-bit aligned! */
 	struct diu_ad	ad0;		/* 32-bit aligned! */
@@ -71,7 +69,7 @@ struct fsl_diu_shared_fb {
 };
 
 #define DIU_DIV_MASK	0x000000ff
-void mpc512x_set_pixel_clock(unsigned int pixclock)
+static void mpc512x_set_pixel_clock(unsigned int pixclock)
 {
 	unsigned long bestval, bestfreq, speed, busfreq;
 	unsigned long minpixclock, maxpixclock, pixval;
@@ -164,7 +162,7 @@ void mpc512x_set_pixel_clock(unsigned int pixclock)
 	iounmap(ccm);
 }
 
-enum fsl_diu_monitor_port
+static enum fsl_diu_monitor_port
 mpc512x_valid_monitor_port(enum fsl_diu_monitor_port port)
 {
 	return FSL_DIU_PORT_DVI;
@@ -179,7 +177,7 @@ static inline void mpc512x_free_bootmem(struct page *page)
 	free_reserved_page(page);
 }
 
-void mpc512x_release_bootmem(void)
+static void mpc512x_release_bootmem(void)
 {
 	unsigned long addr = diu_shared_fb.fb_phys & PAGE_MASK;
 	unsigned long size = diu_shared_fb.fb_len;
@@ -205,7 +203,7 @@ void mpc512x_release_bootmem(void)
  * address range will be reserved in setup_arch() after bootmem
  * allocator is up.
  */
-void __init mpc512x_init_diu(void)
+static void __init mpc512x_init_diu(void)
 {
 	struct device_node *np;
 	struct diu __iomem *diu_reg;
@@ -274,7 +272,7 @@ out:
 	iounmap(diu_reg);
 }
 
-void __init mpc512x_setup_diu(void)
+static void __init mpc512x_setup_diu(void)
 {
 	int ret;
 
@@ -303,11 +301,6 @@ void __init mpc512x_setup_diu(void)
 	diu_ops.release_bootmem		= mpc512x_release_bootmem;
 }
 
-#else
-void __init mpc512x_setup_diu(void) { /* EMPTY */ }
-void __init mpc512x_init_diu(void) { /* EMPTY */ }
-#endif
-
 void __init mpc512x_init_IRQ(void)
 {
 	struct device_node *np;
@@ -340,7 +333,7 @@ static struct of_device_id __initdata of_bus_ids[] = {
 	{},
 };
 
-void __init mpc512x_declare_of_platform_devices(void)
+static void __init mpc512x_declare_of_platform_devices(void)
 {
 	if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
 		printk(KERN_ERR __FILE__ ": "
@@ -390,7 +383,7 @@ static unsigned int __init get_fifo_size(struct device_node *np,
 		    ((u32)(_base) + sizeof(struct mpc52xx_psc)))
 
 /* Init PSC FIFO space for TX and RX slices */
-void __init mpc512x_psc_fifo_init(void)
+static void __init mpc512x_psc_fifo_init(void)
 {
 	struct device_node *np;
 	void __iomem *psc;
diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/fsl_soc.h
index c6d0073..4c5a19e 100644
--- a/arch/powerpc/sysdev/fsl_soc.h
+++ b/arch/powerpc/sysdev/fsl_soc.h
@@ -21,8 +21,6 @@ struct device_node;
 
 extern void fsl_rstcr_restart(char *cmd);
 
-#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
-
 /* The different ports that the DIU can be connected to */
 enum fsl_diu_monitor_port {
 	FSL_DIU_PORT_DVI,	/* DVI */
@@ -43,7 +41,6 @@ struct platform_diu_data_ops {
 };
 
 extern struct platform_diu_data_ops diu_ops;
-#endif
 
 void fsl_hv_restart(char *cmd);
 void fsl_hv_halt(void);
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc/mpc512x: remove unnecessary #if
  2013-10-11 17:37 ` [PATCH v2] " Brian Norris
@ 2013-10-30 22:12   ` Anatolij Gustschin
  0 siblings, 0 replies; 4+ messages in thread
From: Anatolij Gustschin @ 2013-10-30 22:12 UTC (permalink / raw)
  To: Brian Norris; +Cc: Gerhard Sittig, linuxppc-dev

On Fri, 11 Oct 2013 10:37:38 -0700
Brian Norris <computersforpeace@gmail.com> wrote:

> Several functions are only ever referenced locally, so make them static.
> Of those functions, many of them are protected by an #if. However, the
> code which can compile fine in either case.
> 
> Now that (1) the unneeded code is marked 'static' and (2) the code is
> only used under a C 'if (IS_ENABLED(CONFIG_FB_FSL_DIU))', the compiler
> can automatically remove the unneeded code, and we don't need the #if or
> the empty stub functions.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> v2: left out a diff I was holding locally (to remove an #if/#endif
>     completely). Sorry for the noise.
> 
> Based off of Gerhard Sittig's patch:
>   powerpc/mpc512x: silence build warning upon disabled DIU
> 
> Compile-tested with CONFIG_FB_FSL_DIU=n
> 
>  arch/powerpc/platforms/512x/mpc512x_shared.c | 21 +++++++--------------
>  arch/powerpc/sysdev/fsl_soc.h                |  3 ---
>  2 files changed, 7 insertions(+), 17 deletions(-)

Applied, thanks!

Anatolij

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-30 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11 17:32 [PATCH] powerpc/mpc512x: remove unnecessary #if Brian Norris
2013-10-11 17:37 ` Brian Norris
2013-10-11 17:37 ` [PATCH v2] " Brian Norris
2013-10-30 22:12   ` Anatolij Gustschin

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).