On Thu, 7 May 2020 17:13:11 +0200 Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > Hi Boris, > > Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote on Thu, 7 May > 2020 14:11:03 +0200: > > > On Thu, 7 May 2020 13:00:33 +0200 > > Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote: > > > > > > > + > > > +static void anfc_chips_cleanup(struct arasan_nfc *nfc) > > > +{ > > > + struct anand *anand, *tmp; > > > + > > > + list_for_each_entry_safe(anand, tmp, &nfc->chips, node) { > > > + nand_release(&anand->chip); > > > > ret = mtd_device_unregister(nand_to_mtd(&anand->chip)); > > WARN_ON(ret); > > nand_cleanup(&anand->chip); > > > > Or maybe add this WARN_ON() to nand_release() so we don't have to ask > > people to use mtd_device_unregister() + nand_cleanup(). > > I don't get your point here? I'm not against adding a warn_on between > both functions but it's not related to this driver? We've asked people to not call nand_release() but instead call mtd_device_unregister()+nand_cleanup(), which is not done here. My point is, if even us can't get it right, maybe it's a sign we should instead patch nand_release() to do the right thing. > > > We really > > should fix that at some point (allocate nand_chip and mtd_info > > separately and leave a dummy mtd_info object with all hooks returning > > ENODEV when the unregister fails). > > Yes, we should fix that. > > > > > > + list_del(&anand->node); > > > + } > > > +} > > Thanks, > Miquèl