hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/video/fbdev/core/fbsysfs.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * fbsysfs.c - framebuffer device class and attributes
34 *
45 * Copyright (c) 2004 James Simmons <jsimmons@infradead.org>
5
- *
6
- * This program is free software you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License
8
- * as published by the Free Software Foundation; either version
9
- * 2 of the License, or (at your option) any later version.
106 */
117
128 /*
....@@ -18,6 +14,7 @@
1814 #include <linux/kernel.h>
1915 #include <linux/slab.h>
2016 #include <linux/fb.h>
17
+#include <linux/fbcon.h>
2118 #include <linux/console.h>
2219 #include <linux/module.h>
2320
....@@ -60,7 +57,7 @@
6057 info->device = dev;
6158 info->fbcon_rotate_hint = -1;
6259
63
-#ifdef CONFIG_FB_BACKLIGHT
60
+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
6461 mutex_init(&info->bl_curve_mutex);
6562 #endif
6663
....@@ -94,9 +91,9 @@
9491
9592 var->activate |= FB_ACTIVATE_FORCE;
9693 console_lock();
97
- fb_info->flags |= FBINFO_MISC_USEREVENT;
9894 err = fb_set_var(fb_info, var);
99
- fb_info->flags &= ~FBINFO_MISC_USEREVENT;
95
+ if (!err)
96
+ fbcon_update_vcs(fb_info, var->activate & FB_ACTIVATE_ALL);
10097 console_unlock();
10198 if (err)
10299 return err;
....@@ -179,10 +176,7 @@
179176 return -EINVAL;
180177
181178 console_lock();
182
- if (!lock_fb_info(fb_info)) {
183
- console_unlock();
184
- return -ENODEV;
185
- }
179
+ lock_fb_info(fb_info);
186180
187181 list_splice(&fb_info->modelist, &old_list);
188182 fb_videomode_to_modelist((const struct fb_videomode *)buf, i,
....@@ -308,12 +302,13 @@
308302 {
309303 struct fb_info *fb_info = dev_get_drvdata(device);
310304 char *last = NULL;
311
- int err;
305
+ int err, arg;
312306
307
+ arg = simple_strtoul(buf, &last, 0);
313308 console_lock();
314
- fb_info->flags |= FBINFO_MISC_USEREVENT;
315
- err = fb_blank(fb_info, simple_strtoul(buf, &last, 0));
316
- fb_info->flags &= ~FBINFO_MISC_USEREVENT;
309
+ err = fb_blank(fb_info, arg);
310
+ /* might again call into fb_blank */
311
+ fbcon_fb_blanked(fb_info, arg);
317312 console_unlock();
318313 if (err < 0)
319314 return err;
....@@ -409,10 +404,7 @@
409404 state = simple_strtoul(buf, &last, 0);
410405
411406 console_lock();
412
- if (!lock_fb_info(fb_info)) {
413
- console_unlock();
414
- return -ENODEV;
415
- }
407
+ lock_fb_info(fb_info);
416408
417409 fb_set_suspend(fb_info, (int)state);
418410
....@@ -429,7 +421,7 @@
429421 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
430422 }
431423
432
-#ifdef CONFIG_FB_BACKLIGHT
424
+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
433425 static ssize_t store_bl_curve(struct device *device,
434426 struct device_attribute *attr,
435427 const char *buf, size_t count)
....@@ -510,7 +502,7 @@
510502 __ATTR(stride, S_IRUGO, show_stride, NULL),
511503 __ATTR(rotate, S_IRUGO|S_IWUSR, show_rotate, store_rotate),
512504 __ATTR(state, S_IRUGO|S_IWUSR, show_fbstate, store_fbstate),
513
-#ifdef CONFIG_FB_BACKLIGHT
505
+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
514506 __ATTR(bl_curve, S_IRUGO|S_IWUSR, show_bl_curve, store_bl_curve),
515507 #endif
516508 };
....@@ -551,7 +543,7 @@
551543 }
552544 }
553545
554
-#ifdef CONFIG_FB_BACKLIGHT
546
+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
555547 /* This function generates a linear backlight curve
556548 *
557549 * 0: off