On Wed, Nov 04, 2015 at 11:48:47AM +0100, Linus Walleij wrote: > On Tue, Nov 3, 2015 at 10:24 PM, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > > On Mon, Nov 2, 2015 at 11:31 AM, Johan Hovold <johan@xxxxxxxxxx> wrote: > >> On Thu, Oct 22, 2015 at 10:32:25AM +0200, Linus Walleij wrote: > > > >>> + * We memset the struct to zero to avoid reentrance issues. > >>> + */ > >>> + memset(&chip->device, 0, sizeof(chip->device)); > >> > >> This is an indication of a larger problem. > >> > >> First of all, you must never register the same device structure twice. > >> > >> And the larger problem is: With the current interface where a struct > >> gpio_chip is passed and registered, how would you prevent the device > >> from going away while in use? > > > > OK I see. What about the design pattern elsewhere to pass a > > gpiochip desc and have a new gpiochip_register() create the > > gpiochip and delete gpiochip_add()? > > > > That's the usual pattern in subsystems. > > Thinking about it maybe it's simplest to just make ->dev a pointer > and kzalloc() it at gpiochip_add(). > > That should solve this. You'd avoid ever reregistering the same struct device, but that would not solve the bigger life-time issue by itself. Johan -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html