Re: [PATCH v2] dell-laptop: Check return value of all SMBIOS calls and do not cache hwswitch state

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

 



On Tuesday 30 June 2015 01:02:40 Darren Hart wrote:
> On Sat, Jun 27, 2015 at 09:34:43AM +0200, Pali Rohár wrote:
> > Make sure that return value of all SMBIOS calls are properly
> > checked and do not continue of processing (received) information
> > if call failed.
> > 
> > Also do not chache hwswitch wireless state as it can be changed at
> > runtime (e.g from userspace smbios applications).
> 
> This "Also do.." tripled the size of the patch. This should really be
> two patches.
> 
> > Signed-off-by: Pali Rohár <pali.rohar@xxxxxxxxx>
> > ---
> > 
> > Changes since v1:
> >  * Call clear_buffer before each sequential SMBIOS call (we expect
> >  zero-filled buffer)
> 
> Another good independent patch candidate
> 

Ok, I will split it into 3 patches.

> >  * Do not cache hwswitch state as it can be modified at runtime by
> >  userspace * simplify some conditions
> > 
> > ---
> > 
> >  drivers/platform/x86/dell-laptop.c |  173
> >  ++++++++++++++++++++++++++---------- 1 file changed, 127
> >  insertions(+), 46 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/dell-laptop.c
> > b/drivers/platform/x86/dell-laptop.c index 35758cb..99f28d3 100644
> > --- a/drivers/platform/x86/dell-laptop.c
> > +++ b/drivers/platform/x86/dell-laptop.c
> 
> ...
> 
> >  static void dell_update_rfkill(struct work_struct *ignored)
> >  {
> > 
> > +	int hwswitch;
> > 
> >  	int status;
> > 
> > +	int ret;
> > 
> >  	get_buffer();
> > 
> > +
> > 
> >  	dell_send_request(buffer, 17, 11);
> > 
> > +	ret = buffer->output[0];
> > 
> >  	status = buffer->output[1];
> > 
> > +	if (ret != 0)
> > +		goto out;
> > +
> > +	clear_buffer();
> > +
> > +	buffer->input[0] = 0x2;
> > +	dell_send_request(buffer, 17, 11);
> > +	ret = buffer->output[0];
> > +
> > +	if (ret == 0 && (status & BIT(0)))
> > +		hwswitch = buffer->output[1];
> > +	else
> > +		hwswitch = 0;
> 
> Initializing hwswitch to 0 above saves the else and assignment line
> here. Generally preferred.
> 

Ok.

> ...
> 
> >  static int dell_get_intensity(struct backlight_device *bd)
> >  {
> > 
> > -	int ret = 0;
> > +	int ret;
> > +	int token;
> 
> Since we're talking respin, declare in order of descending line
> length please, just as you did later when adding token to a
> function.

Ok.

-- 
Pali Rohár
pali.rohar@xxxxxxxxx

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux