video: fbdev: pvr2fb: add COMPILE_TEST support
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Fri, 7 Jun 2019 12:38:07 +0000 (14:38 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Fri, 7 Jun 2019 12:38:07 +0000 (14:38 +0200)
Add COMPILE_TEST support to pvr2fb driver for better compile
testing coverage.

While at it:

- mark pvr2fb_interrupt() and pvr2fb_common_init() with
  __maybe_unused tag (to silence build warnings when
  !SH_DREAMCAST)

- convert mmio_base in struct pvr2fb_par to 'void __iomem *'
  from 'unsigned long' (needed to silence build warnings on
  ARM).

- split pvr2_get_param() on pvr2_get_param_name() and
  pvr2_get_param_val() (needed to silence build warnings on
  x86).

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
drivers/video/fbdev/Kconfig
drivers/video/fbdev/pvr2fb.c

index e18d9a4441127bbcc2e87dd6fead229c7363e026..d95995b9ed6cf51fd8724104ed2b9a82239bd341 100644 (file)
@@ -809,7 +809,8 @@ config FB_XVR1000
 
 config FB_PVR2
        tristate "NEC PowerVR 2 display support"
-       depends on FB && SH_DREAMCAST
+       depends on FB && HAS_IOMEM
+       depends on SH_DREAMCAST || COMPILE_TEST
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
index cddd33d14981aba8e0f6ab5bcd13aab6687f907f..a13fddfce6aa06cf3d5f0c753f2b3efaf6489074 100644 (file)
@@ -139,7 +139,7 @@ static struct pvr2fb_par {
        unsigned char is_doublescan;    /* Are scanlines output twice? (doublescan) */
        unsigned char is_lowres;        /* Is horizontal pixel-doubling enabled? */
 
-       unsigned long mmio_base;        /* MMIO base */
+       void __iomem *mmio_base;        /* MMIO base */
        u32 palette[16];
 } *currentpar;
 
@@ -325,9 +325,9 @@ static int pvr2fb_setcolreg(unsigned int regno, unsigned int red,
  * anything if the cable type has been overidden (via "cable:XX").
  */
 
-#define PCTRA 0xff80002c
-#define PDTRA 0xff800030
-#define VOUTC 0xa0702c00
+#define PCTRA ((void __iomem *)0xff80002c)
+#define PDTRA ((void __iomem *)0xff800030)
+#define VOUTC ((void __iomem *)0xa0702c00)
 
 static int pvr2_init_cable(void)
 {
@@ -619,7 +619,7 @@ static void pvr2_do_blank(void)
        is_blanked = do_blank > 0 ? do_blank : 0;
 }
 
-static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id)
+static irqreturn_t __maybe_unused pvr2fb_interrupt(int irq, void *dev_id)
 {
        struct fb_info *info = dev_id;
 
@@ -722,23 +722,30 @@ static struct fb_ops pvr2fb_ops = {
        .fb_imageblit   = cfb_imageblit,
 };
 
-static int pvr2_get_param(const struct pvr2_params *p, const char *s, int val,
-                         int size)
+static int pvr2_get_param_val(const struct pvr2_params *p, const char *s,
+                             int size)
 {
        int i;
 
-       for (i = 0 ; i < size ; i++ ) {
-               if (s != NULL) {
-                       if (!strncasecmp(p[i].name, s, strlen(s)))
-                               return p[i].val;
-               } else {
-                       if (p[i].val == val)
-                               return (int)p[i].name;
-               }
+       for (i = 0; i < size; i++) {
+               if (!strncasecmp(p[i].name, s, strlen(s)))
+                       return p[i].val;
        }
        return -1;
 }
 
+static char *pvr2_get_param_name(const struct pvr2_params *p, int val,
+                         int size)
+{
+       int i;
+
+       for (i = 0; i < size; i++) {
+               if (p[i].val == val)
+                       return p[i].name;
+       }
+       return NULL;
+}
+
 /**
  * pvr2fb_common_init
  *
@@ -757,7 +764,7 @@ static int pvr2_get_param(const struct pvr2_params *p, const char *s, int val,
  * in for flexibility anyways. Who knows, maybe someone has tv-out on a
  * PCI-based version of these things ;-)
  */
-static int pvr2fb_common_init(void)
+static int __maybe_unused pvr2fb_common_init(void)
 {
        struct pvr2fb_par *par = currentpar;
        unsigned long modememused, rev;
@@ -770,8 +777,8 @@ static int pvr2fb_common_init(void)
                goto out_err;
        }
 
-       par->mmio_base = (unsigned long)ioremap_nocache(pvr2_fix.mmio_start,
-                                                       pvr2_fix.mmio_len);
+       par->mmio_base = ioremap_nocache(pvr2_fix.mmio_start,
+                                        pvr2_fix.mmio_len);
        if (!par->mmio_base) {
                printk(KERN_ERR "pvr2fb: Failed to remap mmio space\n");
                goto out_err;
@@ -819,8 +826,8 @@ static int pvr2fb_common_init(void)
                fb_info->var.xres, fb_info->var.yres,
                fb_info->var.bits_per_pixel,
                get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel),
-               (char *)pvr2_get_param(cables, NULL, cable_type, 3),
-               (char *)pvr2_get_param(outputs, NULL, video_output, 3));
+               pvr2_get_param_name(cables, cable_type, 3),
+               pvr2_get_param_name(outputs, video_output, 3));
 
 #ifdef CONFIG_SH_STORE_QUEUES
        fb_notice(fb_info, "registering with SQ API\n");
@@ -838,7 +845,7 @@ out_err:
        if (fb_info->screen_base)
                iounmap(fb_info->screen_base);
        if (par->mmio_base)
-               iounmap((void *)par->mmio_base);
+               iounmap(par->mmio_base);
 
        return -ENXIO;
 }
@@ -905,8 +912,8 @@ static void __exit pvr2fb_dc_exit(void)
                fb_info->screen_base = NULL;
        }
        if (currentpar->mmio_base) {
-               iounmap((void *)currentpar->mmio_base);
-               currentpar->mmio_base = 0;
+               iounmap(currentpar->mmio_base);
+               currentpar->mmio_base = NULL;
        }
 
        free_irq(HW_EVENT_VSYNC, fb_info);
@@ -955,8 +962,8 @@ static void pvr2fb_pci_remove(struct pci_dev *pdev)
                fb_info->screen_base = NULL;
        }
        if (currentpar->mmio_base) {
-               iounmap((void *)currentpar->mmio_base);
-               currentpar->mmio_base = 0;
+               iounmap(currentpar->mmio_base);
+               currentpar->mmio_base = NULL;
        }
 
        pci_release_regions(pdev);
@@ -1027,9 +1034,9 @@ static int __init pvr2fb_setup(char *options)
        }
 
        if (*cable_arg)
-               cable_type = pvr2_get_param(cables, cable_arg, 0, 3);
+               cable_type = pvr2_get_param_val(cables, cable_arg, 3);
        if (*output_arg)
-               video_output = pvr2_get_param(outputs, output_arg, 0, 3);
+               video_output = pvr2_get_param_val(outputs, output_arg, 3);
 
        return 0;
 }