All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Marc Zyngier <marc.zyngier@arm.com>,
	linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 1/4] bitmap: define a cleanup function for bitmaps
Date: Tue, 12 Sep 2023 06:43:15 -0700	[thread overview]
Message-ID: <ZQBq81QRFVOMBmnB@yury-ThinkPad> (raw)
In-Reply-To: <20230912085541.13682-2-brgl@bgdev.pl>

On Tue, Sep 12, 2023 at 10:55:38AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Add support for autopointers for bitmaps allocated with bitmap_alloc()
> et al.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  include/linux/bitmap.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index 03644237e1ef..ba8c0d733842 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -6,6 +6,7 @@
>  
>  #include <linux/align.h>
>  #include <linux/bitops.h>
> +#include <linux/cleanup.h>
>  #include <linux/find.h>
>  #include <linux/limits.h>
>  #include <linux/string.h>
> @@ -125,6 +126,8 @@ unsigned long *bitmap_alloc_node(unsigned int nbits, gfp_t flags, int node);
>  unsigned long *bitmap_zalloc_node(unsigned int nbits, gfp_t flags, int node);
>  void bitmap_free(const unsigned long *bitmap);
>  
> +DEFINE_FREE(bitmap, unsigned long *, bitmap_free(_T))

So now it doesn't do weird  "if (_T) bitmap_free(_T)". Have you got any
feedback from Peter for that?

My point is that if the above is correct, all the following
declarations need to be revisited:

yury:linux$ git grep DEFINE_FREE|grep if
include/linux/cleanup.h:25: * DEFINE_FREE(kfree, void *, if (_T) kfree(_T))
include/linux/device.h:1058:DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
include/linux/device.h:1228:DEFINE_FREE(put_device, struct device *, if (_T) put_device(_T))
include/linux/mutex.h:224:DEFINE_FREE(mutex, struct mutex *, if (_T) mutex_unlock(_T))
include/linux/rwsem.h:208:DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T))
include/linux/rwsem.h:209:DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T))
include/linux/sched/task.h:164:DEFINE_FREE(put_task, struct task_struct *, if (_T) put_task_struct(_T))
include/linux/slab.h:231:DEFINE_FREE(kfree, void *, if (_T) kfree(_T))

For the patch:
Acked-by: Yury Norov <yury.norov@gmail.com>

  parent reply	other threads:[~2023-09-12 13:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  8:55 [PATCH 0/4] genirq/irq_sim: misc updates Bartosz Golaszewski
2023-09-12  8:55 ` [PATCH 1/4] bitmap: define a cleanup function for bitmaps Bartosz Golaszewski
2023-09-12  9:36   ` Andy Shevchenko
2023-09-12 13:43   ` Yury Norov [this message]
2023-09-12 14:28     ` Bartosz Golaszewski
2023-09-12  8:55 ` [PATCH 2/4] genirq/irq_sim: remove unused field from struct irq_sim_irq_ctx Bartosz Golaszewski
2023-09-12  8:55 ` [PATCH 3/4] genirq/irq_sim: order headers alphabetically Bartosz Golaszewski
2023-09-12  8:55 ` [PATCH 4/4] genirq/irq_sim: shrink code by using cleanup helpers Bartosz Golaszewski
2023-09-12 13:36 ` [PATCH 0/4] genirq/irq_sim: misc updates Yury Norov
2023-09-12 14:33   ` Bartosz Golaszewski

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=ZQBq81QRFVOMBmnB@yury-ThinkPad \
    --to=yury.norov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=marc.zyngier@arm.com \
    --cc=tglx@linutronix.de \
    /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.