On Tue, Nov 3, 2015 at 10:24 PM, Linus Walleij <linus.wall...@linaro.org> wrote:
> On Mon, Nov 2, 2015 at 11:31 AM, Johan Hovold <jo...@kernel.org> 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.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to