Re: [PATCH v8 3/3] mmc: Add driver for LiteX's LiteSDCard interface

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

 



On Sat, Jan 8, 2022 at 4:32 AM Gabriel L. Somlo <gsomlo@xxxxxxxxx> wrote:
> On Fri, Jan 07, 2022 at 08:57:43PM -0500, Gabriel L. Somlo wrote:
> > On Sat, Jan 08, 2022 at 01:54:07AM +0200, Andy Shevchenko wrote:
> > > On Saturday, January 8, 2022, Gabriel Somlo <gsomlo@xxxxxxxxx> wrote:

...

> > >     +       mmc = mmc_alloc_host(sizeof(struct litex_mmc_host), &pdev->dev);
> > >
> > > Should be devm or you may not use devm at all. See hint in one of the previous
> > > messages in v7 discussion.
> >
> > And here I think I'm in trouble... :)
> >
> > None of the examples retrieved via
> >
> > `git log --no-merges --grep devm_add_action_or_reset`
> >
> > are from "drivers/mmc/host/*", and *all* of the mmc drivers there,
> > including the ones that make extensive use of devm_*, use
> > mmc_alloc_host(), and there doesn't appear to be a devm-ified version
> > of mmc_alloc_host() available! How do they all get away with it?
> >
> > I'm really confused now -- any additional clue(s) much appreciated!
>
> I found drivers/mmc/host/meson-mx-sdhc-mmc.c, which uses
> devm_add_action_or_reset() right after mmc_alloc_host() to enlist the
> subsequent call to mmc_free_host(), see here:
>
> https://github.com/torvalds/linux/blob/master/drivers/mmc/host/meson-mx-sdhc-mmc.c#L791
>
> This would mean that I no longer have to call mmc_free_host(), neither
> on probe()'s error path, nor during remove().
>
> Does that count as canonically correct, or am I still missing
> something?

Yes, this is one of the options you may use.

Since it will be a second (?) driver with the same idea, perhaps in
the future it would make sense to provide devm_mmc_alloc_host() or
analogue (in the latter it means more complex solution like the input
subsystem is using, see devm_input_... API implementations).

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux