History

backlight: backlight: Improve backlight_device documentation

Improve the documentation for backlight_device and adapt it to kernel-doc style. The updated documentation is more strict on how locking is used. With the update neither update_lock nor ops_lock may be used outside the backlight core. This restriction was introduced to keep the locking simple by keeping it in the core. It was verified that this documents the current state by renaming update_lock => bl_update_lock and ops_lock => bl_ops_lock. The rename did not reveal any uses outside the backlight core. The rename is NOT part of this patch.

Sam Ravnborg committed 6 years ago

Commit 6f10cd11 parent cabf1611 file · +49 −23Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/backlight.h+49−23
@@ -14,21 +14,6 @@ · 13 unmodified lines
1414 #include <linux/mutex.h>
1515 #include <linux/notifier.h>
1616
17−/* Notes on locking:
18− *
19− * backlight_device->ops_lock is an internal backlight lock protecting the
20− * ops pointer and no code outside the core should need to touch it.
21− *
22− * Access to update_status() is serialised by the update_lock mutex since
23− * most drivers seem to need this and historically get it wrong.
24− *
25− * Most drivers don't need locking on their get_brightness() method.
26− * If yours does, you need to implement it in the driver. You can use the
27− * update_lock mutex if appropriate.
28− *
29− * Any other use of the locks below is probably wrong.
30− */
31−
3217 enum backlight_update_reason {
3318 BACKLIGHT_UPDATE_HOTKEY,
3419 BACKLIGHT_UPDATE_SYSFS,
@@ -215,30 +200,71 @@ struct backlight_properties { · 180 unmodified lines
215200 enum backlight_scale scale;
216201 };
217202
203+/**
204+ * struct backlight_device - backlight device data
205+ *
206+ * This structure holds all data required by a backlight device.
207+ */
218208 struct backlight_device {
219− /* Backlight properties */
209+ /**
210+ * @props: Backlight properties
211+ */
220212 struct backlight_properties props;
221213
222− /* Serialise access to update_status method */
214+ /**
215+ * @update_lock: The lock used when calling the update_status() operation.
216+ *
217+ * update_lock is an internal backlight lock that serialise access
218+ * to the update_status() operation. The backlight core holds the update_lock
219+ * when calling the update_status() operation. The update_lock shall not
220+ * be used by backlight drivers.
221+ */
223222 struct mutex update_lock;
224223
225− /* This protects the 'ops' field. If 'ops' is NULL, the driver that
226− registered this device has been unloaded, and if class_get_devdata()
227− points to something in the body of that driver, it is also invalid. */
224+ /**
225+ * @ops_lock: The lock used around everything related to backlight_ops.
226+ *
227+ * ops_lock is an internal backlight lock that protects the ops pointer
228+ * and is used around all accesses to ops and when the operations are
229+ * invoked. The ops_lock shall not be used by backlight drivers.
230+ */
228231 struct mutex ops_lock;
232+
233+ /**
234+ * @ops: Pointer to the backlight operations.
235+ *
236+ * If ops is NULL, the driver that registered this device has been unloaded,
237+ * and if class_get_devdata() points to something in the body of that driver,
238+ * it is also invalid.
239+ */
229240 const struct backlight_ops *ops;
230241
231− /* The framebuffer notifier block */
242+ /**
243+ * @fb_notif: The framebuffer notifier block
244+ */
232245 struct notifier_block fb_notif;
233246
234− /* list entry of all registered backlight devices */
247+ /**
248+ * @entry: List entry of all registered backlight devices
249+ */
235250 struct list_head entry;
236251
252+ /**
253+ * @dev: Parent device.
254+ */
237255 struct device dev;
238256
239− /* Multiple framebuffers may share one backlight device */
257+ /**
258+ * @fb_bl_on: The state of individual fbdev's.
259+ *
260+ * Multiple fbdev's may share one backlight device. The fb_bl_on
261+ * records the state of the individual fbdev.
262+ */
240263 bool fb_bl_on[FB_MAX];
241264
265+ /**
266+ * @use_count: The number of uses of fb_bl_on.
267+ */
242268 int use_count;
243269 };
244270