On Mon, May 9, 2016 at 9:13 AM, Dirk Behme <dirk.behme@xxxxxxxxxxxx> wrote: > --- /dev/null > +++ b/drivers/misc/boot-mode-reg/core.c > @@ -0,0 +1,78 @@ > +/** > + * boot_mode_reg_get() - retrieve boot mode register value > + * @mode: implementation-dependent boot mode register value > + * > + * Retrieves the boot mode register value previously registered > + * using boot_mode_reg_set(). > + * > + * return: 0 on success > + */ > +int boot_mode_reg_get(u32 *mode) > +{ > + int err = -ENOENT; > + > + mutex_lock(&boot_mode_mutex); > + if (!boot_mode_is_set) > + goto err; > + *mode = boot_mode; > + err = 0; > +err: The goto and label can easily be avoided by inverting the if condition: if (boot_mode_is_set) { *mode = boot_mode; err = 0; } > + mutex_unlock(&boot_mode_mutex); > + return err; > +} > +EXPORT_SYMBOL_GPL(boot_mode_reg_get); > + > +/** > + * boot_mode_reg_set() - record boot mode register value > + * @mode: implementation-dependent boot mode register value > + * > + * Records the boot mode register value which may subsequently > + * be retrieved using boot_mode_reg_get(). > + * > + * return: 0 on success > + */ > +int boot_mode_reg_set(u32 mode) > +{ > + int err = -EBUSY; > + > + mutex_lock(&boot_mode_mutex); > + if (boot_mode_is_set && boot_mode != mode) > + goto err; > + boot_mode = mode; > + boot_mode_is_set = true; > + err = 0; > +err: Convert goto and label to inverted if. > + mutex_unlock(&boot_mode_mutex); > + return err; > +} > +EXPORT_SYMBOL_GPL(boot_mode_reg_set); Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds