@@ -135,9 +135,9 @@ static int logo_shown = FBCON_LOGO_CANSHOW;
135135/* console mappings */
136136static unsigned int first_fb_vc ;
137137static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1 ;
138- static int fbcon_is_default = 1 ;
138+ static bool fbcon_is_default = true ;
139139static int primary_device = -1 ;
140- static int fbcon_has_console_bind ;
140+ static bool fbcon_has_console_bind ;
141141
142142#ifdef CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY
143143static int map_override ;
@@ -172,7 +172,7 @@ static const struct consw fb_con;
172172
173173#define advance_row (p , delta ) (unsigned short *)((unsigned long)(p) + (delta) * vc->vc_size_row)
174174
175- static int fbcon_cursor_noblink ;
175+ static bool fbcon_cursor_blink = true ;
176176
177177#define divides (a , b ) ((!(a) || (b)%(a)) ? 0 : 1)
178178
@@ -289,16 +289,16 @@ static bool fbcon_skip_panic(struct fb_info *info)
289289#endif
290290}
291291
292- static inline int fbcon_is_inactive (struct vc_data * vc , struct fb_info * info )
292+ static inline bool fbcon_is_active (struct vc_data * vc , struct fb_info * info )
293293{
294294 struct fbcon_ops * ops = info -> fbcon_par ;
295295
296- return ( info -> state != FBINFO_STATE_RUNNING ||
297- vc -> vc_mode != KD_TEXT || ops -> graphics || fbcon_skip_panic (info ) );
296+ return info -> state == FBINFO_STATE_RUNNING &&
297+ vc -> vc_mode == KD_TEXT && ! ops -> graphics && ! fbcon_skip_panic (info );
298298}
299299
300300static int get_color (struct vc_data * vc , struct fb_info * info ,
301- u16 c , int is_fg )
301+ u16 c , bool is_fg )
302302{
303303 int depth = fb_get_color_depth (& info -> var , & info -> fix );
304304 int color = 0 ;
@@ -364,6 +364,16 @@ static int get_color(struct vc_data *vc, struct fb_info *info,
364364 return color ;
365365}
366366
367+ static int get_fg_color (struct vc_data * vc , struct fb_info * info , u16 c )
368+ {
369+ return get_color (vc , info , c , true);
370+ }
371+
372+ static int get_bg_color (struct vc_data * vc , struct fb_info * info , u16 c )
373+ {
374+ return get_color (vc , info , c , false);
375+ }
376+
367377static void fb_flashcursor (struct work_struct * work )
368378{
369379 struct fbcon_ops * ops = container_of (work , struct fbcon_ops , cursor_work .work );
@@ -395,8 +405,9 @@ static void fb_flashcursor(struct work_struct *work)
395405
396406 c = scr_readw ((u16 * ) vc -> vc_pos );
397407 enable = ops -> cursor_flash && !ops -> cursor_state .enable ;
398- ops -> cursor (vc , info , enable , get_color (vc , info , c , 1 ),
399- get_color (vc , info , c , 0 ));
408+ ops -> cursor (vc , info , enable ,
409+ get_fg_color (vc , info , c ),
410+ get_bg_color (vc , info , c ));
400411 console_unlock ();
401412
402413 queue_delayed_work (system_power_efficient_wq , & ops -> cursor_work ,
@@ -407,7 +418,7 @@ static void fbcon_add_cursor_work(struct fb_info *info)
407418{
408419 struct fbcon_ops * ops = info -> fbcon_par ;
409420
410- if (! fbcon_cursor_noblink )
421+ if (fbcon_cursor_blink )
411422 queue_delayed_work (system_power_efficient_wq , & ops -> cursor_work ,
412423 ops -> cur_blink_jiffies );
413424}
@@ -464,7 +475,7 @@ static int __init fb_console_setup(char *this_opt)
464475 last_fb_vc = simple_strtoul (options , & options , 10 ) - 1 ;
465476 if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES )
466477 last_fb_vc = MAX_NR_CONSOLES - 1 ;
467- fbcon_is_default = 0 ;
478+ fbcon_is_default = false ;
468479 continue ;
469480 }
470481
@@ -559,7 +570,7 @@ static int do_fbcon_takeover(int show_logo)
559570 con2fb_map [i ] = -1 ;
560571 info_idx = -1 ;
561572 } else {
562- fbcon_has_console_bind = 1 ;
573+ fbcon_has_console_bind = true ;
563574 }
564575
565576 return err ;
@@ -1267,7 +1278,7 @@ static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
12671278 struct fbcon_display * p = & fb_display [vc -> vc_num ];
12681279 u_int y_break ;
12691280
1270- if (fbcon_is_inactive (vc , info ))
1281+ if (! fbcon_is_active (vc , info ))
12711282 return ;
12721283
12731284 if (!height || !width )
@@ -1311,18 +1322,18 @@ static void fbcon_putcs(struct vc_data *vc, const u16 *s, unsigned int count,
13111322 struct fbcon_display * p = & fb_display [vc -> vc_num ];
13121323 struct fbcon_ops * ops = info -> fbcon_par ;
13131324
1314- if (! fbcon_is_inactive (vc , info ))
1325+ if (fbcon_is_active (vc , info ))
13151326 ops -> putcs (vc , info , s , count , real_y (p , ypos ), xpos ,
1316- get_color (vc , info , scr_readw (s ), 1 ),
1317- get_color (vc , info , scr_readw (s ), 0 ));
1327+ get_fg_color (vc , info , scr_readw (s )),
1328+ get_bg_color (vc , info , scr_readw (s )));
13181329}
13191330
13201331static void fbcon_clear_margins (struct vc_data * vc , int bottom_only )
13211332{
13221333 struct fb_info * info = fbcon_info_from_console (vc -> vc_num );
13231334 struct fbcon_ops * ops = info -> fbcon_par ;
13241335
1325- if (! fbcon_is_inactive (vc , info ))
1336+ if (fbcon_is_active (vc , info ))
13261337 ops -> clear_margins (vc , info , margin_color , bottom_only );
13271338}
13281339
@@ -1334,7 +1345,7 @@ static void fbcon_cursor(struct vc_data *vc, bool enable)
13341345
13351346 ops -> cur_blink_jiffies = msecs_to_jiffies (vc -> vc_cur_blink_ms );
13361347
1337- if (fbcon_is_inactive (vc , info ) || vc -> vc_deccm != 1 )
1348+ if (! fbcon_is_active (vc , info ) || vc -> vc_deccm != 1 )
13381349 return ;
13391350
13401351 if (vc -> vc_cursor_type & CUR_SW )
@@ -1347,8 +1358,9 @@ static void fbcon_cursor(struct vc_data *vc, bool enable)
13471358 if (!ops -> cursor )
13481359 return ;
13491360
1350- ops -> cursor (vc , info , enable , get_color (vc , info , c , 1 ),
1351- get_color (vc , info , c , 0 ));
1361+ ops -> cursor (vc , info , enable ,
1362+ get_fg_color (vc , info , c ),
1363+ get_bg_color (vc , info , c ));
13521364}
13531365
13541366static int scrollback_phys_max = 0 ;
@@ -1740,7 +1752,7 @@ static void fbcon_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx,
17401752 struct fb_info * info = fbcon_info_from_console (vc -> vc_num );
17411753 struct fbcon_display * p = & fb_display [vc -> vc_num ];
17421754
1743- if (fbcon_is_inactive (vc , info ))
1755+ if (! fbcon_is_active (vc , info ))
17441756 return ;
17451757
17461758 if (!width || !height )
@@ -1764,7 +1776,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
17641776 struct fbcon_display * p = & fb_display [vc -> vc_num ];
17651777 int scroll_partial = info -> flags & FBINFO_PARTIAL_PAN_OK ;
17661778
1767- if (fbcon_is_inactive (vc , info ))
1779+ if (! fbcon_is_active (vc , info ))
17681780 return true;
17691781
17701782 fbcon_cursor (vc , false);
@@ -2148,7 +2160,7 @@ static bool fbcon_switch(struct vc_data *vc)
21482160 fbcon_del_cursor_work (old_info );
21492161 }
21502162
2151- if (fbcon_is_inactive (vc , info ) ||
2163+ if (! fbcon_is_active (vc , info ) ||
21522164 ops -> blank_state != FB_BLANK_UNBLANK )
21532165 fbcon_del_cursor_work (info );
21542166 else
@@ -2188,7 +2200,7 @@ static bool fbcon_switch(struct vc_data *vc)
21882200 scrollback_max = 0 ;
21892201 scrollback_current = 0 ;
21902202
2191- if (! fbcon_is_inactive (vc , info )) {
2203+ if (fbcon_is_active (vc , info )) {
21922204 ops -> var .xoffset = ops -> var .yoffset = p -> yscroll = 0 ;
21932205 ops -> update_start (info );
21942206 }
@@ -2244,7 +2256,7 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
22442256 }
22452257 }
22462258
2247- if (! fbcon_is_inactive (vc , info )) {
2259+ if (fbcon_is_active (vc , info )) {
22482260 if (ops -> blank_state != blank ) {
22492261 ops -> blank_state = blank ;
22502262 fbcon_cursor (vc , !blank );
@@ -2258,7 +2270,7 @@ static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank,
22582270 update_screen (vc );
22592271 }
22602272
2261- if (mode_switch || fbcon_is_inactive (vc , info ) ||
2273+ if (mode_switch || ! fbcon_is_active (vc , info ) ||
22622274 ops -> blank_state != FB_BLANK_UNBLANK )
22632275 fbcon_del_cursor_work (info );
22642276 else
@@ -2588,7 +2600,7 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)
25882600 int i , j , k , depth ;
25892601 u8 val ;
25902602
2591- if (fbcon_is_inactive (vc , info ))
2603+ if (! fbcon_is_active (vc , info ))
25922604 return ;
25932605
25942606 if (!con_is_visible (vc ))
@@ -2688,7 +2700,7 @@ static void fbcon_modechanged(struct fb_info *info)
26882700 scrollback_max = 0 ;
26892701 scrollback_current = 0 ;
26902702
2691- if (! fbcon_is_inactive (vc , info )) {
2703+ if (fbcon_is_active (vc , info )) {
26922704 ops -> var .xoffset = ops -> var .yoffset = p -> yscroll = 0 ;
26932705 ops -> update_start (info );
26942706 }
@@ -2806,7 +2818,7 @@ static void fbcon_unbind(void)
28062818 fbcon_is_default );
28072819
28082820 if (!ret )
2809- fbcon_has_console_bind = 0 ;
2821+ fbcon_has_console_bind = false ;
28102822}
28112823#else
28122824static inline void fbcon_unbind (void ) {}
@@ -3257,8 +3269,9 @@ static ssize_t cursor_blink_store(struct device *device,
32573269 const char * buf , size_t count )
32583270{
32593271 struct fb_info * info ;
3260- int blink , idx ;
32613272 char * * last = NULL ;
3273+ bool blink ;
3274+ int idx ;
32623275
32633276 console_lock ();
32643277 idx = con2fb_map [fg_console ];
@@ -3274,10 +3287,10 @@ static ssize_t cursor_blink_store(struct device *device,
32743287 blink = simple_strtoul (buf , last , 0 );
32753288
32763289 if (blink ) {
3277- fbcon_cursor_noblink = 0 ;
3290+ fbcon_cursor_blink = true ;
32783291 fbcon_add_cursor_work (info );
32793292 } else {
3280- fbcon_cursor_noblink = 1 ;
3293+ fbcon_cursor_blink = false ;
32813294 fbcon_del_cursor_work (info );
32823295 }
32833296
0 commit comments