File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -474,19 +474,25 @@ int v4l2_async_subdev_notifier_register(struct v4l2_subdev *sd,
474474}
475475EXPORT_SYMBOL (v4l2_async_subdev_notifier_register );
476476
477- void v4l2_async_notifier_unregister (struct v4l2_async_notifier * notifier )
477+ static void __v4l2_async_notifier_unregister (
478+ struct v4l2_async_notifier * notifier )
478479{
479- if (!notifier -> v4l2_dev && !notifier -> sd )
480+ if (!notifier || (! notifier -> v4l2_dev && !notifier -> sd ) )
480481 return ;
481482
482- mutex_lock (& list_lock );
483-
484483 v4l2_async_notifier_unbind_all_subdevs (notifier );
485484
486485 notifier -> sd = NULL ;
487486 notifier -> v4l2_dev = NULL ;
488487
489488 list_del (& notifier -> list );
489+ }
490+
491+ void v4l2_async_notifier_unregister (struct v4l2_async_notifier * notifier )
492+ {
493+ mutex_lock (& list_lock );
494+
495+ __v4l2_async_notifier_unregister (notifier );
490496
491497 mutex_unlock (& list_lock );
492498}
@@ -596,6 +602,11 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
596602{
597603 mutex_lock (& list_lock );
598604
605+ __v4l2_async_notifier_unregister (sd -> subdev_notifier );
606+ v4l2_async_notifier_cleanup (sd -> subdev_notifier );
607+ kfree (sd -> subdev_notifier );
608+ sd -> subdev_notifier = NULL ;
609+
599610 if (sd -> asd ) {
600611 struct v4l2_async_notifier * notifier = sd -> notifier ;
601612
Original file line number Diff line number Diff line change 2929
3030#include <media/v4l2-async.h>
3131#include <media/v4l2-fwnode.h>
32+ #include <media/v4l2-subdev.h>
3233
3334enum v4l2_fwnode_bus_type {
3435 V4L2_FWNODE_BUS_TYPE_GUESS = 0 ,
@@ -900,6 +901,46 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(
900901}
901902EXPORT_SYMBOL_GPL (v4l2_async_notifier_parse_fwnode_sensor_common );
902903
904+ int v4l2_async_register_subdev_sensor_common (struct v4l2_subdev * sd )
905+ {
906+ struct v4l2_async_notifier * notifier ;
907+ int ret ;
908+
909+ if (WARN_ON (!sd -> dev ))
910+ return - ENODEV ;
911+
912+ notifier = kzalloc (sizeof (* notifier ), GFP_KERNEL );
913+ if (!notifier )
914+ return - ENOMEM ;
915+
916+ ret = v4l2_async_notifier_parse_fwnode_sensor_common (sd -> dev ,
917+ notifier );
918+ if (ret < 0 )
919+ goto out_cleanup ;
920+
921+ ret = v4l2_async_subdev_notifier_register (sd , notifier );
922+ if (ret < 0 )
923+ goto out_cleanup ;
924+
925+ ret = v4l2_async_register_subdev (sd );
926+ if (ret < 0 )
927+ goto out_unregister ;
928+
929+ sd -> subdev_notifier = notifier ;
930+
931+ return 0 ;
932+
933+ out_unregister :
934+ v4l2_async_notifier_unregister (notifier );
935+
936+ out_cleanup :
937+ v4l2_async_notifier_cleanup (notifier );
938+ kfree (notifier );
939+
940+ return ret ;
941+ }
942+ EXPORT_SYMBOL_GPL (v4l2_async_register_subdev_sensor_common );
943+
903944MODULE_LICENSE ("GPL" );
904945MODULE_AUTHOR ("Sakari Ailus <sakari.ailus@linux.intel.com>" );
905946MODULE_AUTHOR ("Sylwester Nawrocki <s.nawrocki@samsung.com>" );
Original file line number Diff line number Diff line change @@ -173,6 +173,28 @@ void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier);
173173 */
174174int v4l2_async_register_subdev (struct v4l2_subdev * sd );
175175
176+ /**
177+ * v4l2_async_register_subdev_sensor_common - registers a sensor sub-device to
178+ * the asynchronous sub-device
179+ * framework and parse set up common
180+ * sensor related devices
181+ *
182+ * @sd: pointer to struct &v4l2_subdev
183+ *
184+ * This function is just like v4l2_async_register_subdev() with the exception
185+ * that calling it will also parse firmware interfaces for remote references
186+ * using v4l2_async_notifier_parse_fwnode_sensor_common() and registers the
187+ * async sub-devices. The sub-device is similarly unregistered by calling
188+ * v4l2_async_unregister_subdev().
189+ *
190+ * While registered, the subdev module is marked as in-use.
191+ *
192+ * An error is returned if the module is no longer loaded on any attempts
193+ * to register it.
194+ */
195+ int __must_check v4l2_async_register_subdev_sensor_common (
196+ struct v4l2_subdev * sd );
197+
176198/**
177199 * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous
178200 * subdevice framework
Original file line number Diff line number Diff line change @@ -793,6 +793,8 @@ struct v4l2_subdev_platform_data {
793793 * list.
794794 * @asd: Pointer to respective &struct v4l2_async_subdev.
795795 * @notifier: Pointer to the managing notifier.
796+ * @subdev_notifier: A sub-device notifier implicitly registered for the sub-
797+ * device using v4l2_device_register_sensor_subdev().
796798 * @pdata: common part of subdevice platform data
797799 *
798800 * Each instance of a subdev driver should create this struct, either
@@ -823,6 +825,7 @@ struct v4l2_subdev {
823825 struct list_head async_list ;
824826 struct v4l2_async_subdev * asd ;
825827 struct v4l2_async_notifier * notifier ;
828+ struct v4l2_async_notifier * subdev_notifier ;
826829 struct v4l2_subdev_platform_data * pdata ;
827830};
828831
You can’t perform that action at this time.
0 commit comments