Message ID | 20220131210552.482606-10-daniel.vetter@ffwll.ch |
---|---|
State | Superseded |
Headers | show |
Series | some fbcon patches, mostly locking | expand |
Am 31.01.22 um 22:05 schrieb Daniel Vetter: > It's only one flag and slightly tidier code. > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Du Cheng <ducheng2@gmail.com> > Cc: Thomas Zimmermann <tzimmermann@suse.de> > Cc: Claudio Suarez <cssk@net-c.es> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> > --- > drivers/video/fbdev/core/fbcon.c | 11 +++++------ > drivers/video/fbdev/core/fbcon.h | 4 +--- > 2 files changed, 6 insertions(+), 9 deletions(-) > > diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c > index affb40658fee..fa30e1909164 100644 > --- a/drivers/video/fbdev/core/fbcon.c > +++ b/drivers/video/fbdev/core/fbcon.c > @@ -773,7 +773,7 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, > > ops->currcon = fg_console; > > - if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { > + if (info->fbops->fb_set_par && !ops->initialized) { > ret = info->fbops->fb_set_par(info); > > if (ret) > @@ -782,7 +782,7 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, > "error code %d\n", ret); > } > > - ops->flags |= FBCON_FLAGS_INIT; > + ops->initialized = true; > ops->graphics = 0; > fbcon_set_disp(info, &info->var, unit); > > @@ -1101,8 +1101,7 @@ static void fbcon_init(struct vc_data *vc, int init) > * We need to do it in fbcon_init() to prevent screen corruption. > */ > if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) { > - if (info->fbops->fb_set_par && > - !(ops->flags & FBCON_FLAGS_INIT)) { > + if (info->fbops->fb_set_par && !ops->initialized) { > ret = info->fbops->fb_set_par(info); > > if (ret) > @@ -1111,7 +1110,7 @@ static void fbcon_init(struct vc_data *vc, int init) > "error code %d\n", ret); > } > > - ops->flags |= FBCON_FLAGS_INIT; > + ops->initialized = true; > } > > ops->graphics = 0; > @@ -1186,7 +1185,7 @@ static void fbcon_deinit(struct vc_data *vc) > if (con_is_visible(vc)) > fbcon_del_cursor_work(info); > > - ops->flags &= ~FBCON_FLAGS_INIT; > + ops->initialized = false; > finished: > > fbcon_free_font(p, free_font); > diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h > index dce5ce41093e..b18d0cbf73b6 100644 > --- a/drivers/video/fbdev/core/fbcon.h > +++ b/drivers/video/fbdev/core/fbcon.h > @@ -18,8 +18,6 @@ > > #include <asm/io.h> > > -#define FBCON_FLAGS_INIT 1 > - > /* > * This is the interface between the low-level console driver and the > * low-level frame buffer device > @@ -77,7 +75,7 @@ struct fbcon_ops { > int blank_state; > int graphics; > int save_graphics; /* for debug enter/leave */ > - int flags; > + bool initialized; This will add 3 bytes of padding. Maybe you can put the bool elsewhere. > int rotate; > int cur_rotate; > char *cursor_data;
On Wed, Feb 2, 2022 at 10:25 AM Thomas Zimmermann <tzimmermann@suse.de> wrote: > Am 31.01.22 um 22:05 schrieb Daniel Vetter: > > It's only one flag and slightly tidier code. > > > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > > Cc: Daniel Vetter <daniel@ffwll.ch> > > Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > Cc: Du Cheng <ducheng2@gmail.com> > > Cc: Thomas Zimmermann <tzimmermann@suse.de> > > Cc: Claudio Suarez <cssk@net-c.es> > > Acked-by: Thomas Zimmermann <tzimmermann@suse.de> > > +++ b/drivers/video/fbdev/core/fbcon.h > > @@ -18,8 +18,6 @@ > > > > #include <asm/io.h> > > > > -#define FBCON_FLAGS_INIT 1 > > - > > /* > > * This is the interface between the low-level console driver and the > > * low-level frame buffer device > > @@ -77,7 +75,7 @@ struct fbcon_ops { > > int blank_state; > > int graphics; > > int save_graphics; /* for debug enter/leave */ > > - int flags; > > + bool initialized; > > This will add 3 bytes of padding. Maybe you can put the bool elsewhere. Several of the int variables are used as boolean flags, too. Perhaps convert them all to bitfields? unsigned int initialized : 1; ... > > int rotate; > > int cur_rotate; > > char *cursor_data; Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On Mon, Jan 31, 2022 at 10:05:40PM +0100, Daniel Vetter wrote: > It's only one flag and slightly tidier code. > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: Du Cheng <ducheng2@gmail.com> > Cc: Thomas Zimmermann <tzimmermann@suse.de> > Cc: Claudio Suarez <cssk@net-c.es> Acked-by: Sam Ravnborg <sam@ravnborg.org> Next step is to convert some of the int flags to bool - so it is obvious this is bool and not an int. I do not like bitfields for bools when there is no big win in memory usage - so not fan of that suggestion. Sam
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index affb40658fee..fa30e1909164 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -773,7 +773,7 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, ops->currcon = fg_console; - if (info->fbops->fb_set_par && !(ops->flags & FBCON_FLAGS_INIT)) { + if (info->fbops->fb_set_par && !ops->initialized) { ret = info->fbops->fb_set_par(info); if (ret) @@ -782,7 +782,7 @@ static void con2fb_init_display(struct vc_data *vc, struct fb_info *info, "error code %d\n", ret); } - ops->flags |= FBCON_FLAGS_INIT; + ops->initialized = true; ops->graphics = 0; fbcon_set_disp(info, &info->var, unit); @@ -1101,8 +1101,7 @@ static void fbcon_init(struct vc_data *vc, int init) * We need to do it in fbcon_init() to prevent screen corruption. */ if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) { - if (info->fbops->fb_set_par && - !(ops->flags & FBCON_FLAGS_INIT)) { + if (info->fbops->fb_set_par && !ops->initialized) { ret = info->fbops->fb_set_par(info); if (ret) @@ -1111,7 +1110,7 @@ static void fbcon_init(struct vc_data *vc, int init) "error code %d\n", ret); } - ops->flags |= FBCON_FLAGS_INIT; + ops->initialized = true; } ops->graphics = 0; @@ -1186,7 +1185,7 @@ static void fbcon_deinit(struct vc_data *vc) if (con_is_visible(vc)) fbcon_del_cursor_work(info); - ops->flags &= ~FBCON_FLAGS_INIT; + ops->initialized = false; finished: fbcon_free_font(p, free_font); diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h index dce5ce41093e..b18d0cbf73b6 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -18,8 +18,6 @@ #include <asm/io.h> -#define FBCON_FLAGS_INIT 1 - /* * This is the interface between the low-level console driver and the * low-level frame buffer device @@ -77,7 +75,7 @@ struct fbcon_ops { int blank_state; int graphics; int save_graphics; /* for debug enter/leave */ - int flags; + bool initialized; int rotate; int cur_rotate; char *cursor_data;
It's only one flag and slightly tidier code. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Du Cheng <ducheng2@gmail.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Claudio Suarez <cssk@net-c.es> --- drivers/video/fbdev/core/fbcon.c | 11 +++++------ drivers/video/fbdev/core/fbcon.h | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-)