Re: [PATCH v2 1/2] media: ir-kbd-i2c: convert to i2c_new_dummy_device()

From: Sean Young
Date: Sat Aug 03 2019 - 22:57:45 EST


On Sat, Aug 03, 2019 at 01:17:49PM -0300, Mauro Carvalho Chehab wrote:
> Em Tue, 30 Jul 2019 19:55:54 +0200
> Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> escreveu:
>
> > Convert this driver to use the new i2c_new_dummy_device() call and bail
> > out if the dummy device cannot be registered to make failure more
> > visible to the user.
> >
>
> Please don't do that.
>
> At first glance, devm_* sounds a good idea, but we had enough issues
> using it on media system.
>
> I don't mind mind much if some SoC specific would use it, but doing
> it on generic drivers is a very bad idea. We have removed almost all
> devm_* calls from the media system.
>
> The problem with devm is that it the de-allocation routines aren't
> called during device unbind. They happen a way later, only when the
> device itself is physically removed, or the driver is removed.

Yes, good point.

> That caused lots of headaches to debug memory lifetime issues on
> media.

Indeed this becomes much more complex. Explicit freeing is much better.


Thanks,
Sean