On Wed, Dec 20, 2023 at 12:56 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > > (+PeterZ) > > On Wed, Dec 20, 2023 at 2:52 AM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > > Replace the wrapping functions that inhibit removal of the gpio_device > > with equivalent guard macros. > > > > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx> > (...) > > +DEFINE_CLASS(_read_sem_guard, > > + struct rw_semaphore *, > > + up_read(_T), > > + ({ > > + down_read(sem); > > + sem; > > + }), > > + struct rw_semaphore *sem); > > Isn't this so generic that it should be in <linux/cleanup.h>? > > Otherwise all the patches look good to me. > We already have this: DEFINE_GUARD(rwsem_read, struct rw_semaphore *, down_read(_T), up_read(_T)) DEFINE_GUARD(rwsem_write, struct rw_semaphore *, down_write(_T), up_write(_T)) DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T)) DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T)) This can surely be used here, right? Bart > Yours, > Linus Walleij