Re: [PATCH 1/6] gpio: make the gpiochip a real device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

> You grab a reference to the chip->device when opening the node (in a
> later patch), but it is not used to manage the life time of struct
> gpio_chip.

OK I think the above approach should solve that?

Yours,
Linus Walleij
--
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



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux