diff mbox series

[v3] iio: light: bh1750: Resolve compiler warning and make code more readable

Message ID 20190913202413.3034-1-kw@linux.com (mailing list archive)
State New, archived
Headers show
Series [v3] iio: light: bh1750: Resolve compiler warning and make code more readable | expand

Commit Message

Krzysztof Wilczyński Sept. 13, 2019, 8:24 p.m. UTC
Separate the declaration of struct bh1750_chip_info from definition
of bh1750_chip_info_tbl[] in a single statement as it makes the code
hard to read, and with the extra newline it makes it look as if the
bh1750_chip_info_tbl[] had no explicit type.

This change also resolves the following compiler warning about the
unusual position of the static keyword that can be seen when building
with warnings enabled (W=1):

drivers/iio/light/bh1750.c:64:1: warning:
  ‘static’ is not at beginning of declaration [-Wold-style-declaration]

Related to commit 3a11fbb037a1 ("iio: light: add support for ROHM
BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors").

Signed-off-by: Krzysztof Wilczynski <kw@linux.com>
---
Changes in v3:
  Updated wording of the commit message as per the review feedback.

Changes in v2:
  Made definition of bh1750_chip_info_tbl separate from declaration
  as per the review feedback.  This also makes the code more readable.
  Updated wording of the subject and the commit message.

 drivers/iio/light/bh1750.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Sept. 15, 2019, 9:48 a.m. UTC | #1
On Fri, 13 Sep 2019 22:24:13 +0200
Krzysztof Wilczynski <kw@linux.com> wrote:

> Separate the declaration of struct bh1750_chip_info from definition
> of bh1750_chip_info_tbl[] in a single statement as it makes the code
> hard to read, and with the extra newline it makes it look as if the
> bh1750_chip_info_tbl[] had no explicit type.
> 
> This change also resolves the following compiler warning about the
> unusual position of the static keyword that can be seen when building
> with warnings enabled (W=1):
> 
> drivers/iio/light/bh1750.c:64:1: warning:
>   ‘static’ is not at beginning of declaration [-Wold-style-declaration]
> 
> Related to commit 3a11fbb037a1 ("iio: light: add support for ROHM
> BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensors").
> 
> Signed-off-by: Krzysztof Wilczynski <kw@linux.com>

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.  Added Uwe's Acked-by as well.

Sorry for the confusing advice I gave earlier, I managed to confuse
myself on what the original code said.

Jonathan

> ---
> Changes in v3:
>   Updated wording of the commit message as per the review feedback.
> 
> Changes in v2:
>   Made definition of bh1750_chip_info_tbl separate from declaration
>   as per the review feedback.  This also makes the code more readable.
>   Updated wording of the subject and the commit message.
> 
>  drivers/iio/light/bh1750.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
> index 28347df78cff..adb5ab9e3439 100644
> --- a/drivers/iio/light/bh1750.c
> +++ b/drivers/iio/light/bh1750.c
> @@ -59,9 +59,9 @@ struct bh1750_chip_info {
>  
>  	u16 int_time_low_mask;
>  	u16 int_time_high_mask;
> -}
> +};
>  
> -static const bh1750_chip_info_tbl[] = {
> +static const struct bh1750_chip_info bh1750_chip_info_tbl[] = {
>  	[BH1710] = { 140, 1022, 300, 400,  250000000, 2, 0x001F, 0x03E0 },
>  	[BH1721] = { 140, 1020, 300, 400,  250000000, 2, 0x0010, 0x03E0 },
>  	[BH1750] = { 31,  254,  69,  1740, 57500000,  1, 0x001F, 0x00E0 },
Krzysztof Wilczyński Sept. 15, 2019, 6:41 p.m. UTC | #2
Hello Jonathan,

[...]
> Applied to the togreg branch of iio.git and pushed out as testing
> for the autobuilders to play with it.  Added Uwe's Acked-by as well.

Thank you!

> Sorry for the confusing advice I gave earlier, I managed to confuse
> myself on what the original code said.

No problem. :)  Uwe suggested to me how to clean things up and word the
commit message more appropriately, thus a very good learning experience
for me.

Thank you again!

Krzysztof
diff mbox series

Patch

diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
index 28347df78cff..adb5ab9e3439 100644
--- a/drivers/iio/light/bh1750.c
+++ b/drivers/iio/light/bh1750.c
@@ -59,9 +59,9 @@  struct bh1750_chip_info {
 
 	u16 int_time_low_mask;
 	u16 int_time_high_mask;
-}
+};
 
-static const bh1750_chip_info_tbl[] = {
+static const struct bh1750_chip_info bh1750_chip_info_tbl[] = {
 	[BH1710] = { 140, 1022, 300, 400,  250000000, 2, 0x001F, 0x03E0 },
 	[BH1721] = { 140, 1020, 300, 400,  250000000, 2, 0x0010, 0x03E0 },
 	[BH1750] = { 31,  254,  69,  1740, 57500000,  1, 0x001F, 0x00E0 },