Skip to content

Commit 2b5630e

Browse files
Saravana Kannanstorulf
authored andcommitted
driver core: Add dev_set_drv_sync_state()
This can be used by frameworks to set the sync_state() helper functions for drivers that don't already have them set. Signed-off-by: Saravana Kannan <saravanak@google.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Abel Vesa <abel.vesa@linaro.org> Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Colibri iMX8X Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20250701114733.636510-20-ulf.hansson@linaro.org
1 parent 3b7b8ac commit 2b5630e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/device.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,18 @@ static inline bool dev_has_sync_state(struct device *dev)
917917
return false;
918918
}
919919

920+
static inline int dev_set_drv_sync_state(struct device *dev,
921+
void (*fn)(struct device *dev))
922+
{
923+
if (!dev || !dev->driver)
924+
return 0;
925+
if (dev->driver->sync_state && dev->driver->sync_state != fn)
926+
return -EBUSY;
927+
if (!dev->driver->sync_state)
928+
dev->driver->sync_state = fn;
929+
return 0;
930+
}
931+
920932
static inline void dev_set_removable(struct device *dev,
921933
enum device_removable removable)
922934
{

0 commit comments

Comments
 (0)