Re: [PATCH V3 05/21] dax: Add dax_set_ops() for setting dax_operations at bind time

From: John Groves
Date: Thu Jan 08 2026 - 11:40:23 EST


On 26/01/08 12:06PM, Jonathan Cameron wrote:
> On Wed, 7 Jan 2026 09:33:14 -0600
> John Groves <John@xxxxxxxxxx> wrote:
>
> > From: John Groves <John@xxxxxxxxxx>
> >
> > The dax_device is created (in the non-pmem case) at hmem probe time via
> > devm_create_dev_dax(), before we know which driver (device_dax,
> > fsdev_dax, or kmem) will bind - by calling alloc_dax() with NULL ops,
> > drivers (i.e. fsdev_dax) that need specific dax_operations must set
> > them later.
> >
> > Add dax_set_ops() exported function so fsdev_dax can set its ops at
> > probe time and clear them on remove. device_dax doesn't need ops since
> > it uses the mmap fault path directly.
> >
> > Use cmpxchg() to atomically set ops only if currently NULL, returning
> > -EBUSY if ops are already set. This prevents accidental double-binding.
> > Clearing ops (NULL) always succeeds.
> >
> > Signed-off-by: John Groves <john@xxxxxxxxxx>
> Hi John
>
> This one runs into the fun mess of mixing devm and other calls.
> I'd advise you just don't do it because it makes code much harder
> to review and hits the 'smells bad' button.
>
> Jonathan

If I don't stink up something, I'm not trying hard enough :D

Next iteration will be full-devm.

[ ... ]

Thanks,
John