Re: [PATCH 4/5] drm/i915/bios: Extract vbt_signature[]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 23, 2024 at 05:24:46PM +0300, Jani Nikula wrote:
> On Mon, 23 Sep 2024, Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> > On Mon, Sep 23, 2024 at 12:12:39PM +0300, Jani Nikula wrote:
> >> On Fri, 20 Sep 2024, Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> >> > On Thu, Sep 12, 2024 at 03:15:52PM +0300, Jani Nikula wrote:
> >> >> On Tue, 10 Sep 2024, Ville Syrjala <ville.syrjala@xxxxxxxxxxxxxxx> wrote:
> >> >> > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> >> >> >
> >> >> > Replace the three hand rolled "$VBT"s with a vbt_signature[]
> >> >> > to avoid accidents.
> >> >> >
> >> >> > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> >> >> > ---
> >> >> >  drivers/gpu/drm/i915/display/intel_bios.c | 12 +++++++++---
> >> >> >  1 file changed, 9 insertions(+), 3 deletions(-)
> >> >> >
> >> >> > diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> >> >> > index cbbda94c3dab..0b92b494117f 100644
> >> >> > --- a/drivers/gpu/drm/i915/display/intel_bios.c
> >> >> > +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> >> >> > @@ -2964,6 +2964,8 @@ static const struct bdb_header *get_bdb_header(const struct vbt_header *vbt)
> >> >> >  	return _vbt + vbt->bdb_offset;
> >> >> >  }
> >> >> >  
> >> >> > +static const char vbt_signature[4] = "$VBT";
> >> >> 
> >> >> Always a bit scary to add strings without termination, but I guess it's
> >> >> justified here.
> >> >
> >> > I guess we could make it look less like a string with eg.
> >> > static const u8 vbt_signature[] = { '$', 'V', 'B', 'T' };
> >> > ?
> >> 
> >> Alternatively,
> >> 
> >> static const char *vbt_signature = "$VBT";
> >
> > Or could just be something like:
> >
> > static const char vbt_signature[] = "$VBT";
> > static const int vbt_signature_len = 4;
> >
> > BUILD_BUG_ON(vbt_signature_len != sizeof(vbt_signature) - 1);
> > BUILD_BUG_ON(vbt_signature_len != sizeof(u32));
> >
> > and use vbt_signature_len instead sizeof(vbt_signature) everwhere.
> 
> Works for me, up to you.

I'll roll with that. I guess it's safer to have the '\0'
in case someone gets the urge to do something like
printk("Unable to find %s ...\n", vbt_signature) etc.

-- 
Ville Syrjälä
Intel



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux