On Tue, Feb 25, 2025 at 12:56:24PM +0100, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > We have existing macros for direction settings so we don't need to rely > on the magic value of 1 in the retval check. Use readable logic that > explicitly says we expect INPUT, OUTPUT or a negative errno and nothing > else in gpiochip_get_direction(). ... > ret = gc->get_direction(gc, offset); > - if (ret > 1) > + if (!(ret == GPIO_LINE_DIRECTION_OUT || > + ret == GPIO_LINE_DIRECTION_IN || ret < 0)) > ret = -EBADE; Wouldn't be better to write it as if (ret < 0) return ret; if (ret != GPIO_LINE_DIRECTION_OUT && ret != GPIO_LINE_DIRECTION_IN) ret = -EBADE; return ret; Otherwise LGTM, Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> after addressing the above. -- With Best Regards, Andy Shevchenko