public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Brent Pappas <bpappas@pappasbrent.com>
Cc: rmfrfs@gmail.com, johan@kernel.org, elder@kernel.org,
	gregkh@linuxfoundation.org, greybus-dev@lists.linaro.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: gpio: Replace macro irq_data_to_gpio_chip with function
Date: Tue, 17 Jan 2023 11:51:27 +0300	[thread overview]
Message-ID: <Y8Zhj81ltR7HI7Uh@kadam> (raw)
In-Reply-To: <20230116184707.22302-1-bpappas@pappasbrent.com>

On Mon, Jan 16, 2023 at 01:47:06PM -0500, Brent Pappas wrote:
> Replace the macro irq_data_to_gpio_chip with a static inline function to comply
> with Linux coding style standards.
> 
> Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
> ---
>  drivers/staging/greybus/gpio.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
> index 8a7cf1d0e968..833162ceb385 100644
> --- a/drivers/staging/greybus/gpio.c
> +++ b/drivers/staging/greybus/gpio.c
> @@ -43,7 +43,11 @@ struct gb_gpio_controller {
>  };
>  #define gpio_chip_to_gb_gpio_controller(chip) \
>  	container_of(chip, struct gb_gpio_controller, chip)
> -#define irq_data_to_gpio_chip(d) (d->domain->host_data)
> +
> +static inline void *irq_data_to_gpio_chip(struct irq_data *d)

1) Don't make this a void pointer.  ->host_data is void but we want to
   return a struct gpio_chip * type so declare it as returning a
   gpio_chip struct pointer.  A big advantage of function over macros is
   the type checking.

2) Don't declare it as inline.  Modern compilers are smart and confident.
   They are smart enough to make it inline automatically.  And confident
   enough that they just ignore when people mark stuff as inline.  (We
   have an __always_inline macro for when the compiler is wrong.)

regards,
dan carpenter


      reply	other threads:[~2023-01-17  8:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 18:47 [PATCH] staging: greybus: gpio: Replace macro irq_data_to_gpio_chip with function Brent Pappas
2023-01-17  8:51 ` Dan Carpenter [this message]

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=Y8Zhj81ltR7HI7Uh@kadam \
    --to=error27@gmail.com \
    --cc=bpappas@pappasbrent.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=rmfrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox