aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authoreric miao <eric.miao@marvell.com>2008-04-30 03:52:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:31 -0400
commit92ac73c1e4b4e039162f5d3980c2da8192b28060 (patch)
tree207565d3a1ee07db3fb3ffc5358a7edc8154ddf6 /drivers
parentded245b67f0a412b75052a285a0b0d1798650a63 (diff)
pxafb: sanitize the usage of #ifdef .. processing pxafb parameters
So to get a better coding style and centralize the pxafb parameters handling code. Signed-off-by: eric miao <eric.miao@marvell.com> Cc: "Antonino A. Daplas" <adaplas@pol.net> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/pxafb.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 9c87a9c2566d..f1846c0de934 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -71,11 +71,6 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var,
71 struct pxafb_info *); 71 struct pxafb_info *);
72static void set_ctrlr_state(struct pxafb_info *fbi, u_int state); 72static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
73 73
74#ifdef CONFIG_FB_PXA_PARAMETERS
75#define PXAFB_OPTIONS_SIZE 256
76static char g_options[PXAFB_OPTIONS_SIZE] __devinitdata = "";
77#endif
78
79static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state) 74static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
80{ 75{
81 unsigned long flags; 76 unsigned long flags;
@@ -1316,6 +1311,32 @@ static int __init pxafb_parse_options(struct device *dev, char *options)
1316 } 1311 }
1317 return 0; 1312 return 0;
1318} 1313}
1314
1315static char g_options[256] __devinitdata = "";
1316
1317#ifndef CONFIG_MODULES
1318static int __devinit pxafb_setup_options(void)
1319{
1320 char *options = NULL;
1321
1322 if (fb_get_options("pxafb", &options))
1323 return -ENODEV;
1324
1325 if (options)
1326 strlcpy(g_options, options, sizeof(g_options));
1327
1328 return 0;
1329}
1330#else
1331#define pxafb_setup_options() (0)
1332
1333module_param_string(options, g_options, sizeof(g_options), 0);
1334MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)");
1335#endif
1336
1337#else
1338#define pxafb_parse_options(...) (0)
1339#define pxafb_setup_options() (0)
1319#endif 1340#endif
1320 1341
1321static int __init pxafb_probe(struct platform_device *dev) 1342static int __init pxafb_probe(struct platform_device *dev)
@@ -1332,11 +1353,9 @@ static int __init pxafb_probe(struct platform_device *dev)
1332 if (!inf) 1353 if (!inf)
1333 goto failed; 1354 goto failed;
1334 1355
1335#ifdef CONFIG_FB_PXA_PARAMETERS
1336 ret = pxafb_parse_options(&dev->dev, g_options); 1356 ret = pxafb_parse_options(&dev->dev, g_options);
1337 if (ret < 0) 1357 if (ret < 0)
1338 goto failed; 1358 goto failed;
1339#endif
1340 1359
1341#ifdef DEBUG_VAR 1360#ifdef DEBUG_VAR
1342 /* Check for various illegal bit-combinations. Currently only 1361 /* Check for various illegal bit-combinations. Currently only
@@ -1449,31 +1468,11 @@ static struct platform_driver pxafb_driver = {
1449 }, 1468 },
1450}; 1469};
1451 1470
1452#ifndef MODULE
1453static int __devinit pxafb_setup(char *options)
1454{
1455# ifdef CONFIG_FB_PXA_PARAMETERS
1456 if (options)
1457 strlcpy(g_options, options, sizeof(g_options));
1458# endif
1459 return 0;
1460}
1461#else
1462# ifdef CONFIG_FB_PXA_PARAMETERS
1463module_param_string(options, g_options, sizeof(g_options), 0);
1464MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)");
1465# endif
1466#endif
1467
1468static int __devinit pxafb_init(void) 1471static int __devinit pxafb_init(void)
1469{ 1472{
1470#ifndef MODULE 1473 if (pxafb_setup_options())
1471 char *option = NULL; 1474 return -EINVAL;
1472 1475
1473 if (fb_get_options("pxafb", &option))
1474 return -ENODEV;
1475 pxafb_setup(option);
1476#endif
1477 return platform_driver_register(&pxafb_driver); 1476 return platform_driver_register(&pxafb_driver);
1478} 1477}
1479 1478