Commit d1ae418e authored by Tobias Klauser's avatar Tobias Klauser Committed by Linus Torvalds
Browse files

[PATCH] drivers/video: Use ARRAY_SIZE macro



Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of ARRAY_SIZE.  Some coding style and trailing whitespaces are
also fixed.

Compile-tested where possible (some are other arch or BROKEN)

Signed-off-by: default avatarTobias Klauser <tklauser@nuerscht.ch>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b0c87978
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1308,7 +1308,7 @@ static int __init acornfb_probe(struct platform_device *dev)
	/*
	 * Try to select a suitable default mode
	 */
	for (i = 0; i < sizeof(modedb) / sizeof(*modedb); i++) {
	for (i = 0; i < ARRAY_SIZE(modedb); i++) {
		unsigned long hs;

		hs = modedb[i].refresh *
@@ -1391,7 +1391,7 @@ static int __init acornfb_probe(struct platform_device *dev)
	 */
	do {
		rc = fb_find_mode(&fb_info.var, &fb_info, NULL, modedb,
				 sizeof(modedb) / sizeof(*modedb),
				 ARRAY_SIZE(modedb),
				 &acornfb_default_mode, DEFAULT_BPP);
		/*
		 * If we found an exact match, all ok.
@@ -1408,7 +1408,7 @@ static int __init acornfb_probe(struct platform_device *dev)
			break;

		rc = fb_find_mode(&fb_info.var, &fb_info, NULL, modedb,
				 sizeof(modedb) / sizeof(*modedb),
				 ARRAY_SIZE(modedb),
				 &acornfb_default_mode, DEFAULT_BPP);
		if (rc)
			break;
+6 −8
Original line number Diff line number Diff line
@@ -353,8 +353,6 @@ struct chips_init_reg {
	unsigned char data;
};

#define N_ELTS(x)	(sizeof(x) / sizeof(x[0]))

static struct chips_init_reg chips_init_sr[] =
{
	{0x00, 0x03},		/* Reset register */
@@ -460,22 +458,22 @@ static void __devinit chips_hw_init(struct fb_info *p)
{
	int i;

	for (i = 0; i < N_ELTS(chips_init_xr); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_xr); ++i)
		write_xr(chips_init_xr[i].addr, chips_init_xr[i].data);
	write_xr(0x81, 0x12);
	write_xr(0x82, 0x08);
	write_xr(0x20, 0x00);
	for (i = 0; i < N_ELTS(chips_init_sr); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_sr); ++i)
		write_sr(chips_init_sr[i].addr, chips_init_sr[i].data);
	for (i = 0; i < N_ELTS(chips_init_gr); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_gr); ++i)
		write_gr(chips_init_gr[i].addr, chips_init_gr[i].data);
	for (i = 0; i < N_ELTS(chips_init_ar); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_ar); ++i)
		write_ar(chips_init_ar[i].addr, chips_init_ar[i].data);
	/* Enable video output in attribute index register */
	writeb(0x20, mmio_base + 0x780);
	for (i = 0; i < N_ELTS(chips_init_cr); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_cr); ++i)
		write_cr(chips_init_cr[i].addr, chips_init_cr[i].data);
	for (i = 0; i < N_ELTS(chips_init_fr); ++i)
	for (i = 0; i < ARRAY_SIZE(chips_init_fr); ++i)
		write_fr(chips_init_fr[i].addr, chips_init_fr[i].data);
}

+2 −2
Original line number Diff line number Diff line
@@ -1727,7 +1727,7 @@ static int __init aty128_init(struct pci_dev *pdev, const struct pci_device_id *
	video_card[9] = ent->device & 0xFF;

	/* range check to make sure */
	if (ent->driver_data < (sizeof(r128_family)/sizeof(char *)))
	if (ent->driver_data < ARRAY_SIZE(r128_family))
	    strncat(video_card, r128_family[ent->driver_data], sizeof(video_card));

	printk(KERN_INFO "aty128fb: %s [chip rev 0x%x] ", video_card, chip_rev);
+4 −4
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ static int __devinit correct_chipset(struct atyfb_par *par)
	const char *name;
	int i;

	for (i = sizeof(aty_chips) / sizeof(*aty_chips) - 1; i >= 0; i--)
	for (i = ARRAY_SIZE(aty_chips) - 1; i >= 0; i--)
		if (par->pci_id == aty_chips[i].pci_id)
			break;

@@ -2168,10 +2168,10 @@ static void __init aty_calc_mem_refresh(struct atyfb_par *par, int xclk)

	if (IS_XL(par->pci_id) || IS_MOBILITY(par->pci_id)) {
		refresh_tbl = ragexl_tbl;
		size = sizeof(ragexl_tbl)/sizeof(int);
		size = ARRAY_SIZE(ragexl_tbl);
	} else {
		refresh_tbl = ragepro_tbl;
		size = sizeof(ragepro_tbl)/sizeof(int);
		size = ARRAY_SIZE(ragepro_tbl);
	}

	for (i=0; i < size; i++) {
@@ -3399,7 +3399,7 @@ static int __devinit atyfb_pci_probe(struct pci_dev *pdev, const struct pci_devi
	struct atyfb_par *par;
	int i, rc = -ENOMEM;

	for (i = sizeof(aty_chips) / sizeof(*aty_chips) - 1; i >= 0; i--)
	for (i = ARRAY_SIZE(aty_chips); i >= 0; i--)
		if (pdev->device == aty_chips[i].pci_id)
			break;

+1 −2
Original line number Diff line number Diff line
@@ -149,8 +149,7 @@ static int aty_var_to_pll_514(const struct fb_info *info, u32 vclk_per,
	};
	int i;

	for (i = 0; i < sizeof(RGB514_clocks) / sizeof(*RGB514_clocks);
	     i++)
	for (i = 0; i < ARRAY_SIZE(RGB514_clocks); i++)
		if (vclk_per <= RGB514_clocks[i].limit) {
			pll->ibm514.m = RGB514_clocks[i].m;
			pll->ibm514.n = RGB514_clocks[i].n;
Loading