Re: [PATCH 2/2] Staging: dgnc: fixed code style issues, mainly line width issues.

From: Joe Perches
Date: Sat Apr 18 2015 - 21:28:38 EST


On Sun, 2015-04-19 at 02:04 +0200, Yorick Rommers wrote:
> A patch for dgnc_mgmt.c and dgnc_neo.c to fix some code style issues.

trivial notes:

Try breaking up the patches you send into more discrete
chucks that do just one thing, not mostly one thing
and some other things.

> diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
[]
> @@ -148,7 +148,9 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> di.info_bdstate = dgnc_Board[brd]->dpastatus;
> di.info_ioport = 0;
> di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
> - di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;

It may be better to use a temporary for brd like:

struct dgnc_board *bd = dgnc_Board[brd];

as is done a few other places.

> + di.info_physsize =
> + (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;

so this becomes
di.info->physsize = bd->membase - bd->membase_end;

though I wonder if this is a defect and size
should be bd->membase_end - bd->membase + 1

It doesn't need a cast as membase and membase_end
are ulong already.

It also seems this physsize variable isn't used.

> diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
[]
> @@ -79,7 +79,8 @@ struct board_ops dgnc_neo_ops = {
> .send_immediate_char = neo_send_immediate_char
> };
>
> -static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
> +static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08,
> +0x10, 0x20, 0x40, 0x80 };

That's less attractive then what's already there.
The generic kernel form for an array declaration would be:

static uint dgnc_offset_table[8] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
};

This also would be better as static const.

I stopped reading here.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/