On Sat, Jul 29, 2023 at 11:37 PM Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> wrote: > > Hello Bartosz, > > On Sat, Jul 29, 2023 at 04:09:40PM +0200, Bartosz Golaszewski wrote: > > Looks good to me (although I have my reservations about the concept of > > foo_alloc() for subsystems in the kernel...). > > Wolfram's EOSS talk[1] mentioned "__cleanup__ + kref as suggested by Bartosz? > Paradigm shift, probably looong way to go". I guess that's what you'd > prefer? Do you have a link for me to read about this? > For now I prefer the gpiolib model. One structure allocated and controlled by the driver (struct gpio_chip) which needs to live only as long as the device is bound to a driver and a second structure private to the subsystem, allocated and controlled by the subsystem (struct gpio_device) which also contains the referenced counted struct device and is only released by the device's release callback. IMO there shouldn't be any need for PWM drivers to dereference struct device held by struct pwm_chip. If anything - it should be passed to the drivers in subsystem callbacks. I may be wrong of course, I don't know this subsystem very well but it seems to follow a pattern that's pretty common in the kernel and causes ownership confusion. Bart > > How do you want this to go upstream? > > I haven't thought about that yet. I first will have to convince > Thierry that this is a good idea I guess. This version will not be > merged for sure. > > Best regards > Uwe > > [1] https://static.sched.com/hosted_files/eoss2023/e3/LifecycleIssues_WolframSang_2023.pdf > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | https://www.pengutronix.de/ |