Re: [PATCH][next] IB/hfi1: Use fallthrough pseudo-keyword

2020-07-08 Thread Leon Romanovsky
On Wed, Jul 08, 2020 at 01:28:35PM -0500, Gustavo A. R. Silva wrote:
> Hi Leon,
>
> On Wed, Jul 08, 2020 at 08:47:03AM +0300, Leon Romanovsky wrote:
> > On Tue, Jul 07, 2020 at 12:39:42PM -0500, Gustavo A. R. Silva wrote:
> > > Replace the existing /* fall through */ comments and its variants with
> > > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
> > > fall-through markings when it is the case.
> > >
> > > [1] 
> > > https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
> > >
> > > Signed-off-by: Gustavo A. R. Silva 
> > > ---
> > >  drivers/infiniband/hw/hfi1/chip.c |8 
> > >  drivers/infiniband/hw/hfi1/firmware.c |   16 
> > >  drivers/infiniband/hw/hfi1/mad.c  |9 -
> > >  drivers/infiniband/hw/hfi1/pio.c  |2 +-
> > >  drivers/infiniband/hw/hfi1/pio_copy.c |   12 ++--
> > >  drivers/infiniband/hw/hfi1/platform.c |   10 +-
> > >  drivers/infiniband/hw/hfi1/qp.c   |2 +-
> > >  drivers/infiniband/hw/hfi1/qsfp.c |4 ++--
> > >  drivers/infiniband/hw/hfi1/rc.c   |   25 -
> > >  drivers/infiniband/hw/hfi1/sdma.c |9 -
> > >  drivers/infiniband/hw/hfi1/tid_rdma.c |4 ++--
> > >  drivers/infiniband/hw/hfi1/uc.c   |8 
> > >  12 files changed, 45 insertions(+), 64 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/hw/hfi1/chip.c 
> > > b/drivers/infiniband/hw/hfi1/chip.c
> > > index 15f9c635f292..132f1df6f23b 100644
> > > --- a/drivers/infiniband/hw/hfi1/chip.c
> > > +++ b/drivers/infiniband/hw/hfi1/chip.c
> > > @@ -7320,7 +7320,7 @@ static u16 link_width_to_bits(struct hfi1_devdata 
> > > *dd, u16 width)
> > >   default:
> > >   dd_dev_info(dd, "%s: invalid width %d, using 4\n",
> > >   __func__, width);
> > > - /* fall through */
> > > + fallthrough;
> > >   case 4: return OPA_LINK_WIDTH_4X;
> >
> > "case ..:" after "default:" ???
> > IMHO, it should be written in more standard way.
> >
>
> I agree. However, that piece of code, and the other below, does not
> concern to this patch.

I'm not super excited about such half-baked solutions. Let's fix all at
once by pre-patch or post-patch to this change.

Thanks


Re: [PATCH][next] IB/hfi1: Use fallthrough pseudo-keyword

2020-07-08 Thread Gustavo A. R. Silva
Hi Leon,

On Wed, Jul 08, 2020 at 08:47:03AM +0300, Leon Romanovsky wrote:
> On Tue, Jul 07, 2020 at 12:39:42PM -0500, Gustavo A. R. Silva wrote:
> > Replace the existing /* fall through */ comments and its variants with
> > the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
> > fall-through markings when it is the case.
> >
> > [1] 
> > https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
> >
> > Signed-off-by: Gustavo A. R. Silva 
> > ---
> >  drivers/infiniband/hw/hfi1/chip.c |8 
> >  drivers/infiniband/hw/hfi1/firmware.c |   16 
> >  drivers/infiniband/hw/hfi1/mad.c  |9 -
> >  drivers/infiniband/hw/hfi1/pio.c  |2 +-
> >  drivers/infiniband/hw/hfi1/pio_copy.c |   12 ++--
> >  drivers/infiniband/hw/hfi1/platform.c |   10 +-
> >  drivers/infiniband/hw/hfi1/qp.c   |2 +-
> >  drivers/infiniband/hw/hfi1/qsfp.c |4 ++--
> >  drivers/infiniband/hw/hfi1/rc.c   |   25 -
> >  drivers/infiniband/hw/hfi1/sdma.c |9 -
> >  drivers/infiniband/hw/hfi1/tid_rdma.c |4 ++--
> >  drivers/infiniband/hw/hfi1/uc.c   |8 
> >  12 files changed, 45 insertions(+), 64 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/hfi1/chip.c 
> > b/drivers/infiniband/hw/hfi1/chip.c
> > index 15f9c635f292..132f1df6f23b 100644
> > --- a/drivers/infiniband/hw/hfi1/chip.c
> > +++ b/drivers/infiniband/hw/hfi1/chip.c
> > @@ -7320,7 +7320,7 @@ static u16 link_width_to_bits(struct hfi1_devdata 
> > *dd, u16 width)
> > default:
> > dd_dev_info(dd, "%s: invalid width %d, using 4\n",
> > __func__, width);
> > -   /* fall through */
> > +   fallthrough;
> > case 4: return OPA_LINK_WIDTH_4X;
> 
> "case ..:" after "default:" ???
> IMHO, it should be written in more standard way.
> 

I agree. However, that piece of code, and the other below, does not
concern to this patch.

I will address the rest of the comments and send v2.

Thanks!
--
Gustavo

> > }
> >  }
> > @@ -7380,7 +7380,7 @@ static void get_link_widths(struct hfi1_devdata *dd, 
> > u16 *tx_width,
> > dd_dev_err(dd,
> >"%s: unexpected max rate %d, using 25Gb\n",
> >__func__, (int)max_rate);
> > -   /* fall through */
> > +   fallthrough;
> > case 1:
> > dd->pport[0].link_speed_active = OPA_LINK_SPEED_25G;
> > break;
> > @@ -12882,7 +12882,7 @@ static u32 chip_to_opa_lstate(struct hfi1_devdata 
> > *dd, u32 chip_lstate)
> > dd_dev_err(dd,
> >"Unknown logical state 0x%x, reporting 
> > IB_PORT_DOWN\n",
> >chip_lstate);
> > -   /* fall through */
> > +   fallthrough;
> > case LSTATE_DOWN:
> > return IB_PORT_DOWN;
> > case LSTATE_INIT:
> > @@ -12901,7 +12901,7 @@ u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 
> > chip_pstate)
> > default:
> > dd_dev_err(dd, "Unexpected chip physical state of 0x%x\n",
> >chip_pstate);
> > -   /* fall through */
> > +   fallthrough;
> > case PLS_DISABLED:
> > return IB_PORTPHYSSTATE_DISABLED;
> > case PLS_OFFLINE:
> 
> same comment.
> 
> 
> > diff --git a/drivers/infiniband/hw/hfi1/firmware.c 
> > b/drivers/infiniband/hw/hfi1/firmware.c
> > index 2b57ba70ddd6..0e83d4b61e46 100644
> > --- a/drivers/infiniband/hw/hfi1/firmware.c
> > +++ b/drivers/infiniband/hw/hfi1/firmware.c
> > @@ -1868,11 +1868,8 @@ int parse_platform_config(struct hfi1_devdata *dd)
> > 2;
> > break;
> > case PLATFORM_CONFIG_RX_PRESET_TABLE:
> > -   /* fall through */
> > case PLATFORM_CONFIG_TX_PRESET_TABLE:
> > -   /* fall through */
> > case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
> > -   /* fall through */
> > case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
> > pcfgcache->config_tables[table_type].num_table =
> > table_length_dwords;
> > @@ -1890,15 +1887,10 @@ int parse_platform_config(struct hfi1_devdata *dd)
> > /* metadata table */
> > switch (table_type) {
> > case PLATFORM_CONFIG_SYSTEM_TABLE:
> > -   /* fall through */
> > case PLATFORM_CONFIG_PORT_TABLE:
> > -   /* fall through */
> > case PLATFORM_CONFIG_RX_PRESET_TABLE:
> > -   /* fall through */
> >

Re: [PATCH][next] IB/hfi1: Use fallthrough pseudo-keyword

2020-07-07 Thread Leon Romanovsky
On Tue, Jul 07, 2020 at 12:39:42PM -0500, Gustavo A. R. Silva wrote:
> Replace the existing /* fall through */ comments and its variants with
> the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
> fall-through markings when it is the case.
>
> [1] 
> https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through
>
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/infiniband/hw/hfi1/chip.c |8 
>  drivers/infiniband/hw/hfi1/firmware.c |   16 
>  drivers/infiniband/hw/hfi1/mad.c  |9 -
>  drivers/infiniband/hw/hfi1/pio.c  |2 +-
>  drivers/infiniband/hw/hfi1/pio_copy.c |   12 ++--
>  drivers/infiniband/hw/hfi1/platform.c |   10 +-
>  drivers/infiniband/hw/hfi1/qp.c   |2 +-
>  drivers/infiniband/hw/hfi1/qsfp.c |4 ++--
>  drivers/infiniband/hw/hfi1/rc.c   |   25 -
>  drivers/infiniband/hw/hfi1/sdma.c |9 -
>  drivers/infiniband/hw/hfi1/tid_rdma.c |4 ++--
>  drivers/infiniband/hw/hfi1/uc.c   |8 
>  12 files changed, 45 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hfi1/chip.c 
> b/drivers/infiniband/hw/hfi1/chip.c
> index 15f9c635f292..132f1df6f23b 100644
> --- a/drivers/infiniband/hw/hfi1/chip.c
> +++ b/drivers/infiniband/hw/hfi1/chip.c
> @@ -7320,7 +7320,7 @@ static u16 link_width_to_bits(struct hfi1_devdata *dd, 
> u16 width)
>   default:
>   dd_dev_info(dd, "%s: invalid width %d, using 4\n",
>   __func__, width);
> - /* fall through */
> + fallthrough;
>   case 4: return OPA_LINK_WIDTH_4X;

"case ..:" after "default:" ???
IMHO, it should be written in more standard way.

>   }
>  }
> @@ -7380,7 +7380,7 @@ static void get_link_widths(struct hfi1_devdata *dd, 
> u16 *tx_width,
>   dd_dev_err(dd,
>  "%s: unexpected max rate %d, using 25Gb\n",
>  __func__, (int)max_rate);
> - /* fall through */
> + fallthrough;
>   case 1:
>   dd->pport[0].link_speed_active = OPA_LINK_SPEED_25G;
>   break;
> @@ -12882,7 +12882,7 @@ static u32 chip_to_opa_lstate(struct hfi1_devdata 
> *dd, u32 chip_lstate)
>   dd_dev_err(dd,
>  "Unknown logical state 0x%x, reporting 
> IB_PORT_DOWN\n",
>  chip_lstate);
> - /* fall through */
> + fallthrough;
>   case LSTATE_DOWN:
>   return IB_PORT_DOWN;
>   case LSTATE_INIT:
> @@ -12901,7 +12901,7 @@ u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 
> chip_pstate)
>   default:
>   dd_dev_err(dd, "Unexpected chip physical state of 0x%x\n",
>  chip_pstate);
> - /* fall through */
> + fallthrough;
>   case PLS_DISABLED:
>   return IB_PORTPHYSSTATE_DISABLED;
>   case PLS_OFFLINE:

same comment.


> diff --git a/drivers/infiniband/hw/hfi1/firmware.c 
> b/drivers/infiniband/hw/hfi1/firmware.c
> index 2b57ba70ddd6..0e83d4b61e46 100644
> --- a/drivers/infiniband/hw/hfi1/firmware.c
> +++ b/drivers/infiniband/hw/hfi1/firmware.c
> @@ -1868,11 +1868,8 @@ int parse_platform_config(struct hfi1_devdata *dd)
>   2;
>   break;
>   case PLATFORM_CONFIG_RX_PRESET_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_TX_PRESET_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
>   pcfgcache->config_tables[table_type].num_table =
>   table_length_dwords;
> @@ -1890,15 +1887,10 @@ int parse_platform_config(struct hfi1_devdata *dd)
>   /* metadata table */
>   switch (table_type) {
>   case PLATFORM_CONFIG_SYSTEM_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_PORT_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_RX_PRESET_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_TX_PRESET_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
> - /* fall through */
>   case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
>   break;
>   default:
> 

[PATCH][next] IB/hfi1: Use fallthrough pseudo-keyword

2020-07-07 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] 
https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/infiniband/hw/hfi1/chip.c |8 
 drivers/infiniband/hw/hfi1/firmware.c |   16 
 drivers/infiniband/hw/hfi1/mad.c  |9 -
 drivers/infiniband/hw/hfi1/pio.c  |2 +-
 drivers/infiniband/hw/hfi1/pio_copy.c |   12 ++--
 drivers/infiniband/hw/hfi1/platform.c |   10 +-
 drivers/infiniband/hw/hfi1/qp.c   |2 +-
 drivers/infiniband/hw/hfi1/qsfp.c |4 ++--
 drivers/infiniband/hw/hfi1/rc.c   |   25 -
 drivers/infiniband/hw/hfi1/sdma.c |9 -
 drivers/infiniband/hw/hfi1/tid_rdma.c |4 ++--
 drivers/infiniband/hw/hfi1/uc.c   |8 
 12 files changed, 45 insertions(+), 64 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/chip.c 
b/drivers/infiniband/hw/hfi1/chip.c
index 15f9c635f292..132f1df6f23b 100644
--- a/drivers/infiniband/hw/hfi1/chip.c
+++ b/drivers/infiniband/hw/hfi1/chip.c
@@ -7320,7 +7320,7 @@ static u16 link_width_to_bits(struct hfi1_devdata *dd, 
u16 width)
default:
dd_dev_info(dd, "%s: invalid width %d, using 4\n",
__func__, width);
-   /* fall through */
+   fallthrough;
case 4: return OPA_LINK_WIDTH_4X;
}
 }
@@ -7380,7 +7380,7 @@ static void get_link_widths(struct hfi1_devdata *dd, u16 
*tx_width,
dd_dev_err(dd,
   "%s: unexpected max rate %d, using 25Gb\n",
   __func__, (int)max_rate);
-   /* fall through */
+   fallthrough;
case 1:
dd->pport[0].link_speed_active = OPA_LINK_SPEED_25G;
break;
@@ -12882,7 +12882,7 @@ static u32 chip_to_opa_lstate(struct hfi1_devdata *dd, 
u32 chip_lstate)
dd_dev_err(dd,
   "Unknown logical state 0x%x, reporting 
IB_PORT_DOWN\n",
   chip_lstate);
-   /* fall through */
+   fallthrough;
case LSTATE_DOWN:
return IB_PORT_DOWN;
case LSTATE_INIT:
@@ -12901,7 +12901,7 @@ u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 
chip_pstate)
default:
dd_dev_err(dd, "Unexpected chip physical state of 0x%x\n",
   chip_pstate);
-   /* fall through */
+   fallthrough;
case PLS_DISABLED:
return IB_PORTPHYSSTATE_DISABLED;
case PLS_OFFLINE:
diff --git a/drivers/infiniband/hw/hfi1/firmware.c 
b/drivers/infiniband/hw/hfi1/firmware.c
index 2b57ba70ddd6..0e83d4b61e46 100644
--- a/drivers/infiniband/hw/hfi1/firmware.c
+++ b/drivers/infiniband/hw/hfi1/firmware.c
@@ -1868,11 +1868,8 @@ int parse_platform_config(struct hfi1_devdata *dd)
2;
break;
case PLATFORM_CONFIG_RX_PRESET_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_TX_PRESET_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
pcfgcache->config_tables[table_type].num_table =
table_length_dwords;
@@ -1890,15 +1887,10 @@ int parse_platform_config(struct hfi1_devdata *dd)
/* metadata table */
switch (table_type) {
case PLATFORM_CONFIG_SYSTEM_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_PORT_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_RX_PRESET_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_TX_PRESET_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_QSFP_ATTEN_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE:
break;
default:
@@ -2027,15 +2019,10 @@ static int get_platform_fw_field_metadata(struct 
hfi1_devdata *dd, int table,
 
switch (table) {
case PLATFORM_CONFIG_SYSTEM_TABLE:
-   /* fall through */
case PLATFORM_CONFIG_PORT_TABLE:
-