Commit 817daf14 authored by eric miao's avatar eric miao Committed by Linus Torvalds

pxafb: un-nest pxafb_parse_options() to cleanup the coding style issue

pxafb_parse_options() has very long lines exceeding far beyond 80 characters,
which makes the function looks bad.  Un-nest it into smaller functions and use
a temporary string for only what has been overridden instead of the whole
dev_info() message to reduce the line a bit more.
Signed-off-by: default avatareric miao <eric.miao@marvell.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 592e7bf8
...@@ -1211,19 +1211,10 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev) ...@@ -1211,19 +1211,10 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
} }
#ifdef CONFIG_FB_PXA_PARAMETERS #ifdef CONFIG_FB_PXA_PARAMETERS
static int __init pxafb_parse_options(struct device *dev, char *options) static int parse_opt_mode(struct device *dev, const char *this_opt)
{ {
struct pxafb_mach_info *inf = dev->platform_data; struct pxafb_mach_info *inf = dev->platform_data;
char *this_opt;
if (!options || !*options)
return 0;
dev_dbg(dev, "options are \"%s\"\n", options ? options : "null");
/* could be made table driven or similar?... */
while ((this_opt = strsep(&options, ",")) != NULL) {
if (!strncmp(this_opt, "mode:", 5)) {
const char *name = this_opt+5; const char *name = this_opt+5;
unsigned int namelen = strlen(name); unsigned int namelen = strlen(name);
int res_specified = 0, bpp_specified = 0; int res_specified = 0, bpp_specified = 0;
...@@ -1257,7 +1248,7 @@ static int __init pxafb_parse_options(struct device *dev, char *options) ...@@ -1257,7 +1248,7 @@ static int __init pxafb_parse_options(struct device *dev, char *options)
xres = simple_strtoul(name, NULL, 0); xres = simple_strtoul(name, NULL, 0);
res_specified = 1; res_specified = 1;
} }
done: done:
if (res_specified) { if (res_specified) {
dev_info(dev, "overriding resolution: %dx%d\n", xres, yres); dev_info(dev, "overriding resolution: %dx%d\n", xres, yres);
inf->modes[0].xres = xres; inf->modes[0].yres = yres; inf->modes[0].xres = xres; inf->modes[0].yres = yres;
...@@ -1274,66 +1265,80 @@ static int __init pxafb_parse_options(struct device *dev, char *options) ...@@ -1274,66 +1265,80 @@ static int __init pxafb_parse_options(struct device *dev, char *options)
break; break;
default: default:
dev_err(dev, "Depth %d is not valid\n", bpp); dev_err(dev, "Depth %d is not valid\n", bpp);
return -EINVAL;
} }
return 0;
}
static int parse_opt(struct device *dev, char *this_opt)
{
struct pxafb_mach_info *inf = dev->platform_data;
struct pxafb_mode_info *mode = &inf->modes[0];
char s[64];
s[0] = '\0';
if (!strncmp(this_opt, "mode:", 5)) {
return parse_opt_mode(dev, this_opt);
} else if (!strncmp(this_opt, "pixclock:", 9)) { } else if (!strncmp(this_opt, "pixclock:", 9)) {
inf->modes[0].pixclock = simple_strtoul(this_opt+9, NULL, 0); mode->pixclock = simple_strtoul(this_opt+9, NULL, 0);
dev_info(dev, "override pixclock: %ld\n", inf->modes[0].pixclock); sprintf(s, "pixclock: %ld\n", mode->pixclock);
} else if (!strncmp(this_opt, "left:", 5)) { } else if (!strncmp(this_opt, "left:", 5)) {
inf->modes[0].left_margin = simple_strtoul(this_opt+5, NULL, 0); mode->left_margin = simple_strtoul(this_opt+5, NULL, 0);
dev_info(dev, "override left: %u\n", inf->modes[0].left_margin); sprintf(s, "left: %u\n", mode->left_margin);
} else if (!strncmp(this_opt, "right:", 6)) { } else if (!strncmp(this_opt, "right:", 6)) {
inf->modes[0].right_margin = simple_strtoul(this_opt+6, NULL, 0); mode->right_margin = simple_strtoul(this_opt+6, NULL, 0);
dev_info(dev, "override right: %u\n", inf->modes[0].right_margin); sprintf(s, "right: %u\n", mode->right_margin);
} else if (!strncmp(this_opt, "upper:", 6)) { } else if (!strncmp(this_opt, "upper:", 6)) {
inf->modes[0].upper_margin = simple_strtoul(this_opt+6, NULL, 0); mode->upper_margin = simple_strtoul(this_opt+6, NULL, 0);
dev_info(dev, "override upper: %u\n", inf->modes[0].upper_margin); sprintf(s, "upper: %u\n", mode->upper_margin);
} else if (!strncmp(this_opt, "lower:", 6)) { } else if (!strncmp(this_opt, "lower:", 6)) {
inf->modes[0].lower_margin = simple_strtoul(this_opt+6, NULL, 0); mode->lower_margin = simple_strtoul(this_opt+6, NULL, 0);
dev_info(dev, "override lower: %u\n", inf->modes[0].lower_margin); sprintf(s, "lower: %u\n", mode->lower_margin);
} else if (!strncmp(this_opt, "hsynclen:", 9)) { } else if (!strncmp(this_opt, "hsynclen:", 9)) {
inf->modes[0].hsync_len = simple_strtoul(this_opt+9, NULL, 0); mode->hsync_len = simple_strtoul(this_opt+9, NULL, 0);
dev_info(dev, "override hsynclen: %u\n", inf->modes[0].hsync_len); sprintf(s, "hsynclen: %u\n", mode->hsync_len);
} else if (!strncmp(this_opt, "vsynclen:", 9)) { } else if (!strncmp(this_opt, "vsynclen:", 9)) {
inf->modes[0].vsync_len = simple_strtoul(this_opt+9, NULL, 0); mode->vsync_len = simple_strtoul(this_opt+9, NULL, 0);
dev_info(dev, "override vsynclen: %u\n", inf->modes[0].vsync_len); sprintf(s, "vsynclen: %u\n", mode->vsync_len);
} else if (!strncmp(this_opt, "hsync:", 6)) { } else if (!strncmp(this_opt, "hsync:", 6)) {
if (simple_strtoul(this_opt+6, NULL, 0) == 0) { if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
dev_info(dev, "override hsync: Active Low\n"); sprintf(s, "hsync: Active Low\n");
inf->modes[0].sync &= ~FB_SYNC_HOR_HIGH_ACT; mode->sync &= ~FB_SYNC_HOR_HIGH_ACT;
} else { } else {
dev_info(dev, "override hsync: Active High\n"); sprintf(s, "hsync: Active High\n");
inf->modes[0].sync |= FB_SYNC_HOR_HIGH_ACT; mode->sync |= FB_SYNC_HOR_HIGH_ACT;
} }
} else if (!strncmp(this_opt, "vsync:", 6)) { } else if (!strncmp(this_opt, "vsync:", 6)) {
if (simple_strtoul(this_opt+6, NULL, 0) == 0) { if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
dev_info(dev, "override vsync: Active Low\n"); sprintf(s, "vsync: Active Low\n");
inf->modes[0].sync &= ~FB_SYNC_VERT_HIGH_ACT; mode->sync &= ~FB_SYNC_VERT_HIGH_ACT;
} else { } else {
dev_info(dev, "override vsync: Active High\n"); sprintf(s, "vsync: Active High\n");
inf->modes[0].sync |= FB_SYNC_VERT_HIGH_ACT; mode->sync |= FB_SYNC_VERT_HIGH_ACT;
} }
} else if (!strncmp(this_opt, "dpc:", 4)) { } else if (!strncmp(this_opt, "dpc:", 4)) {
if (simple_strtoul(this_opt+4, NULL, 0) == 0) { if (simple_strtoul(this_opt+4, NULL, 0) == 0) {
dev_info(dev, "override double pixel clock: false\n"); sprintf(s, "double pixel clock: false\n");
inf->lccr3 &= ~LCCR3_DPC; inf->lccr3 &= ~LCCR3_DPC;
} else { } else {
dev_info(dev, "override double pixel clock: true\n"); sprintf(s, "double pixel clock: true\n");
inf->lccr3 |= LCCR3_DPC; inf->lccr3 |= LCCR3_DPC;
} }
} else if (!strncmp(this_opt, "outputen:", 9)) { } else if (!strncmp(this_opt, "outputen:", 9)) {
if (simple_strtoul(this_opt+9, NULL, 0) == 0) { if (simple_strtoul(this_opt+9, NULL, 0) == 0) {
dev_info(dev, "override output enable: active low\n"); sprintf(s, "output enable: active low\n");
inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnL; inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnL;
} else { } else {
dev_info(dev, "override output enable: active high\n"); sprintf(s, "output enable: active high\n");
inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnH; inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnH;
} }
} else if (!strncmp(this_opt, "pixclockpol:", 12)) { } else if (!strncmp(this_opt, "pixclockpol:", 12)) {
if (simple_strtoul(this_opt+12, NULL, 0) == 0) { if (simple_strtoul(this_opt+12, NULL, 0) == 0) {
dev_info(dev, "override pixel clock polarity: falling edge\n"); sprintf(s, "pixel clock polarity: falling edge\n");
inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixFlEdg; inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixFlEdg;
} else { } else {
dev_info(dev, "override pixel clock polarity: rising edge\n"); sprintf(s, "pixel clock polarity: rising edge\n");
inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixRsEdg; inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixRsEdg;
} }
} else if (!strncmp(this_opt, "color", 5)) { } else if (!strncmp(this_opt, "color", 5)) {
...@@ -1356,9 +1361,30 @@ static int __init pxafb_parse_options(struct device *dev, char *options) ...@@ -1356,9 +1361,30 @@ static int __init pxafb_parse_options(struct device *dev, char *options)
dev_err(dev, "unknown option: %s\n", this_opt); dev_err(dev, "unknown option: %s\n", this_opt);
return -EINVAL; return -EINVAL;
} }
}
if (s[0] != '\0')
dev_info(dev, "override %s", s);
return 0; return 0;
}
static int __init pxafb_parse_options(struct device *dev, char *options)
{
char *this_opt;
int ret;
if (!options || !*options)
return 0;
dev_dbg(dev, "options are \"%s\"\n", options ? options : "null");
/* could be made table driven or similar?... */
while ((this_opt = strsep(&options, ",")) != NULL) {
ret = parse_opt(dev, this_opt);
if (ret)
return ret;
}
return 0;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment