lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y8Zhj81ltR7HI7Uh@kadam>
Date:   Tue, 17 Jan 2023 11:51:27 +0300
From:   Dan Carpenter <error27@...il.com>
To:     Brent Pappas <bpappas@...pasbrent.com>
Cc:     rmfrfs@...il.com, johan@...nel.org, elder@...nel.org,
        gregkh@...uxfoundation.org, greybus-dev@...ts.linaro.org,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: greybus: gpio: Replace macro
 irq_data_to_gpio_chip with function

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@...pasbrent.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ