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

Unified · Split

include/linux/backlight.h+49−23
@@ -14,21 +14,6 @@ · 13 unmodified lines
14#include <linux/mutex.h>14#include <linux/mutex.h>
15#include <linux/notifier.h>15#include <linux/notifier.h>
16 16
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
32enum backlight_update_reason {17enum backlight_update_reason {
33 BACKLIGHT_UPDATE_HOTKEY,18 BACKLIGHT_UPDATE_HOTKEY,
34 BACKLIGHT_UPDATE_SYSFS,19 BACKLIGHT_UPDATE_SYSFS,
@@ -215,30 +200,71 @@ struct backlight_properties { · 180 unmodified lines
215 enum backlight_scale scale;200 enum backlight_scale scale;
216};201};
217 202
203/**
204 * struct backlight_device - backlight device data
205 *
206 * This structure holds all data required by a backlight device.
207 */
218struct backlight_device {208struct backlight_device {
219 /* Backlight properties */209 /**
210 * @props: Backlight properties
211 */
220 struct backlight_properties props;212 struct backlight_properties props;
221 213
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 */
223 struct mutex update_lock;222 struct mutex update_lock;
224 223
225 /* This protects the 'ops' field. If 'ops' is NULL, the driver that224 /**
226 registered this device has been unloaded, and if class_get_devdata()225 * @ops_lock: The lock used around everything related to backlight_ops.
227 points to something in the body of that driver, it is also invalid. */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 */
228 struct mutex ops_lock;231 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 */
229 const struct backlight_ops *ops;240 const struct backlight_ops *ops;
230 241
231 /* The framebuffer notifier block */242 /**
243 * @fb_notif: The framebuffer notifier block
244 */
232 struct notifier_block fb_notif;245 struct notifier_block fb_notif;
233 246
234 /* list entry of all registered backlight devices */247 /**
248 * @entry: List entry of all registered backlight devices
249 */
235 struct list_head entry;250 struct list_head entry;
236 251
252 /**
253 * @dev: Parent device.
254 */
237 struct device dev;255 struct device dev;
238 256
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 */
240 bool fb_bl_on[FB_MAX];263 bool fb_bl_on[FB_MAX];
241 264
265 /**
266 * @use_count: The number of uses of fb_bl_on.
267 */
242 int use_count;268 int use_count;
243};269};
244 270