Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

[PATCH] drivers/char: Use ARRAY_SIZE macro



Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove
duplicates of ARRAY_SIZE.

Signed-off-by: default avatarTobias Klauser <tklauser@nuerscht.ch>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3c6bee1d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout);

static struct serial_state rs_table[1];

#define NR_PORTS	(sizeof(rs_table)/sizeof(struct serial_state))
#define NR_PORTS ARRAY_SIZE(rs_table)

/*
 * tmp_buf is used as a temporary buffer by serial_write.  We need to
+1 −1
Original line number Diff line number Diff line
@@ -723,7 +723,7 @@ static unsigned int cy_isa_addresses[] = {
        0xDE000,
        0,0,0,0,0,0,0,0
};
#define NR_ISA_ADDRS (sizeof(cy_isa_addresses)/sizeof(unsigned char*))
#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses)

#ifdef MODULE
static long maddr[NR_CARDS] = { 0, };
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ static inline void print_state(struct hvsi_struct *hp)
	};
	const char *name = state_names[hp->state];

	if (hp->state > (sizeof(state_names)/sizeof(char*)))
	if (hp->state > ARRAY_SIZE(state_names))
		name = "UNKNOWN";

	pr_debug("hvsi%i: state = %s\n", hp->index, name);
+8 −11
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ static stlconf_t stli_brdconf[] = {
	/*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/
};

static int	stli_nrbrds = sizeof(stli_brdconf) / sizeof(stlconf_t);
static int	stli_nrbrds = ARRAY_SIZE(stli_brdconf);

/*
 *	There is some experimental EISA board detection code in this driver.
@@ -406,7 +406,7 @@ static unsigned long stli_eisamemprobeaddrs[] = {
	0xff000000, 0xff010000, 0xff020000, 0xff030000,
};

static int	stli_eisamempsize = sizeof(stli_eisamemprobeaddrs) / sizeof(unsigned long);
static int	stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);

/*
 *	Define the Stallion PCI vendor and device IDs.
@@ -899,15 +899,13 @@ static void stli_argbrds(void)
{
	stlconf_t	conf;
	stlibrd_t	*brdp;
	int		nrargs, i;
	int		i;

#ifdef DEBUG
	printk("stli_argbrds()\n");
#endif

	nrargs = sizeof(stli_brdsp) / sizeof(char **);

	for (i = stli_nrbrds; (i < nrargs); i++) {
	for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
		memset(&conf, 0, sizeof(conf));
		if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
			continue;
@@ -967,7 +965,7 @@ static unsigned long stli_atol(char *str)
static int stli_parsebrd(stlconf_t *confp, char **argp)
{
	char	*sp;
	int	nrbrdnames, i;
	int	i;

#ifdef DEBUG
	printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
@@ -979,14 +977,13 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
	for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
		*sp = TOLOWER(*sp);

	nrbrdnames = sizeof(stli_brdstr) / sizeof(stlibrdtype_t);
	for (i = 0; (i < nrbrdnames); i++) {
	for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) {
		if (strcmp(stli_brdstr[i].name, argp[0]) == 0)
			break;
	}
	if (i >= nrbrdnames) {
	if (i == ARRAY_SIZE(stli_brdstr)) {
		printk("STALLION: unknown board name, %s?\n", argp[0]);
		return(0);
		return 0;
	}

	confp->brdtype = stli_brdstr[i].type;
+1 −1
Original line number Diff line number Diff line
@@ -448,7 +448,7 @@ static int __init moxa_init(void)
#ifdef CONFIG_PCI
	{
		struct pci_dev *p = NULL;
		int n = (sizeof(moxa_pcibrds) / sizeof(moxa_pcibrds[0])) - 1;
		int n = ARRAY_SIZE(moxa_pcibrds) - 1;
		i = 0;
		while (i < n) {
			while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
Loading