All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Cc: gregkh@linuxfoundation.org, realwakka@gmail.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: pi433: remove rf69_get_flag function resolving enum conflict
Date: Mon, 28 Feb 2022 09:32:38 +0300	[thread overview]
Message-ID: <20220228063238.GA2794@kadam> (raw)
In-Reply-To: <Yhla4a1Clpguoo2h@mail.google.com>

Looks good.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

On Sat, Feb 26, 2022 at 11:40:33AM +1300, Paulo Miguel Almeida wrote:
> The reason why rf69_get_flag() existed was to provide a high-level way
> to obtain values out of 1 (of 2) flags registers using bit masking. The
> idea was to map the possible flag values found in the data sheet like
> shown in page 70 of the RFM69HCW datasheet.
> 
> However, due to the fact that enums values in C must be unique, there
> was a naming conflict on 'fifo_not_empty' which is used by the
> tx_start_condition enum. So the author decided to create a 'fifo_empty'
> one which would negate the value that comes from the flag register as
> the solution to that conflict (which is very confusing).
> 
> this patch removes rf69_get_flag function which subsequently solves the
> enum redeclaration problem so kernel developers can follow the data
> sheet more easily.
> 
> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> ---
>  drivers/staging/pi433/pi433_if.c  |  8 +++---
>  drivers/staging/pi433/rf69.c      | 44 -------------------------------
>  drivers/staging/pi433/rf69.h      |  1 -
>  drivers/staging/pi433/rf69_enum.h | 20 --------------
>  4 files changed, 4 insertions(+), 69 deletions(-)

You don't really need to write a long commit message for a commit which
deletes 69 - 4 = 65 lines.  Just say "Remove pointless rf69_get_flag()
function and call rf69_read_reg() directly.  This cleanup removes 65
lines of code and it more obvious to read."

> 
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index 069255f023c8..3f3e863e6cc8 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -434,7 +434,7 @@ static int pi433_receive(void *data)
>  		return retval;
>  
>  	/* now check RSSI, if low wait for getting high (RSSI interrupt) */
> -	while (!rf69_get_flag(dev->spi, rssi_exceeded_threshold)) {
> +	while (!(rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI)) {
>  		/* allow tx to interrupt us while waiting for high RSSI */
>  		dev->interrupt_rx_allowed = true;
>  		wake_up_interruptible(&dev->tx_wait_queue);
> @@ -442,8 +442,8 @@ static int pi433_receive(void *data)
>  		/* wait for RSSI level to become high */
>  		dev_dbg(dev->dev, "rx: going to wait for high RSSI level\n");
>  		retval = wait_event_interruptible(dev->rx_wait_queue,
> -						  rf69_get_flag(dev->spi,
> -								rssi_exceeded_threshold));
> +						  rf69_read_reg(spi, REG_IRQFLAGS1)
> +						  & MASK_IRQFLAGS1_RSSI);

The & character should go on the first line.

						  rf69_read_reg(spi, REG_IRQFLAGS1) &
						  MASK_IRQFLAGS1_RSSI);

But that can be done in a follow on patch if you want.  Or you can
leave it as-is.

regards,
dan carpenter


  reply	other threads:[~2022-02-28  6:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 22:40 [PATCH] staging: pi433: remove rf69_get_flag function resolving enum conflict Paulo Miguel Almeida
2022-02-28  6:32 ` Dan Carpenter [this message]
2022-03-02  9:07   ` Paulo Miguel Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220228063238.GA2794@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=realwakka@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.