> On Sat, Sep 21, 2024 at 01:00:52PM +0000, Winkler, Tomas wrote: > > > On Thu, Sep 19, 2024 at 09:54:24AM +0000, Winkler, Tomas wrote: > > > > > On Mon, Sep 16, 2024 at 04:49:17PM +0300, Alexander Usyskin > wrote: > > > > Just do normal open coded allocations, the reference counting is just > > > obscure. > > > The kref here is for reason so we don't need to hunt the close open, I frankly > don't understand > > what is wrong with it, > > It's locking/refcounting stuff that looks nothing like any other SPI > controller driver. Even if it works it's obviously fragile since the > driver does surprising things which break assumptions that will be made > by people not looking at this specific driver, and causes people to have > to spend more effort figuring out what you're doing. If there is any > benefit to doing this then open coding it in one specific driver is > clearly not the right place to do it. > The reason for all this refcounting that the device itself is discrete card and the SPI memory backend can disappear at any moment leaving open connections dangling. Refcount ensures that object behind the MTD device will be freed only when the last user-space is disconnected. Is there any other model that can keep the object alive in this situation? - - Thanks, Sasha