Re: [Outreachy kernel] [PATCH 1/7] staging: vt6655: Introduce `idx` temporary variable

From: Praveen Kumar
Date: Fri Oct 29 2021 - 10:47:53 EST


On 28-10-2021 16:05, Karolina Drobnik wrote:
> Add a local variable to store `MISCFIFO_SYNDATA_IDX` offset.
> This change helps in shortening the lines in `rf.c` that
> are deemed too long by checkpatch.pl.
>
> Signed-off-by: Karolina Drobnik <karolinadrobnik@xxxxxxxxx>
> ---
> drivers/staging/vt6655/rf.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c
> index bc4abe77db7b..f195dafb6e63 100644
> --- a/drivers/staging/vt6655/rf.c
> +++ b/drivers/staging/vt6655/rf.c
> @@ -681,6 +681,7 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char rf_type,
> {
> void __iomem *iobase = priv->port_offset;
> int i;

Why not to make *i* as unsigned short and get rid of all the type conversions below ?

> + unsigned short idx = MISCFIFO_SYNDATA_IDX;
> unsigned char init_count = 0;
> unsigned char sleep_count = 0;
>
> @@ -699,11 +700,11 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char rf_type,
> return false;
>
> for (i = 0; i < CB_AL2230_INIT_SEQ; i++)
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al2230_init_table[i]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al2230_init_table[i]);
>
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al2230_channel_table0[channel - 1]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al2230_channel_table0[channel - 1]);
> i++;
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al2230_channel_table1[channel - 1]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al2230_channel_table1[channel - 1]);
> break;
>
> /* Need to check, PLLON need to be low for channel setting */
> @@ -716,17 +717,17 @@ bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char rf_type,
>
> if (channel <= CB_MAX_CHANNEL_24G) {
> for (i = 0; i < CB_AL7230_INIT_SEQ; i++)
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al7230_init_table[i]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al7230_init_table[i]);
> } else {
> for (i = 0; i < CB_AL7230_INIT_SEQ; i++)
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al7230_init_table_a_mode[i]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al7230_init_table_a_mode[i]);
> }
>
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al7230_channel_table0[channel - 1]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al7230_channel_table0[channel - 1]);
> i++;
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al7230_channel_table1[channel - 1]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al7230_channel_table1[channel - 1]);
> i++;
> - MACvSetMISCFifo(priv, (unsigned short)(MISCFIFO_SYNDATA_IDX + i), al7230_channel_table2[channel - 1]);
> + MACvSetMISCFifo(priv, (unsigned short)(idx + i), al7230_channel_table2[channel - 1]);
> break;
>
> case RF_NOTHING:
>

Regards,

~Praveen.