Re: [PATCH 1/4] driver: core: introduce dev_add_sync_state()
From: Brian Masney
Date: Mon Jun 29 2026 - 11:45:52 EST
On Mon, Jun 29, 2026 at 12:11:18PM +0200, Konrad Dybcio wrote:
> On 6/26/26 6:32 PM, Brian Masney wrote:
> > We have cases where a device node represents a provider for multiple
> > types of resources, like clocks, power-domains, resets, etc. We
> > currently have dev_set_drv_sync_state() where a framework or driver
> > can set the sync_state callback for a device node, however it currently
> > only supports a single sync_state callback.
> >
> > The pmdomain subsystem currently sets up a sync_state callback in the
> > core framework, and the clk subsystem will setup it's own separate
> > sync_state callback in the core framework. These can collide with each
> > other on some types of devices that have multiple types of resources.
> > Additionally, some clk drivers already have their own separate
> > sync_state callback already defined.
> >
> > Let's introduce support for allowing drivers and frameworks to add their
> > own sync_state callback via a new function dev_add_sync_state() so that
> > multiple sync_state callbacks can coexist.
> >
> > Link: https://lore.kernel.org/linux-clk/CAPx+jO9JiV16ePLk59hTQzEMnA96Va6Ns4jqJbwyZ6oTT0AjXA@xxxxxxxxxxxxxx/
> > Signed-off-by: Brian Masney <bmasney@xxxxxxxxxx>
> > Assisted-by: Claude:claude-opus-4-6
> > ---
>
> [...]
>
> > +int dev_add_sync_state(struct device *dev,
> > + void (*fn)(struct device *dev))
> > +{
> > + struct sync_state_entry *entry;
> > +
> > + if (!dev || !dev->driver)
> > + return 0;
> > +
> > + list_for_each_entry(entry, &dev->sync_state_list, node)
> > + if (entry->fn == fn)
> > + return 0;
>
> Do we expect this to be a valid call, i.e. should we WARN_ON here?
That's a good point about adding a WARN_ON() here. I kept this logic
from when I converted from dev_set_drv_sync_state().
Brian