linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Darren Hart <dvhart@infradead.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Gabriele Mazzotta <gabriele.mzt@gmail.com>
Subject: Re: [PATCH v2] dell-laptop: Check return value of all SMBIOS calls and do not cache hwswitch state
Date: Wed, 1 Jul 2015 20:04:45 +0200	[thread overview]
Message-ID: <201507012004.45275@pali> (raw)
In-Reply-To: <20150629230240.GE57818@vmdeb7>

[-- Attachment #1: Type: Text/Plain, Size: 2391 bytes --]

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@gmail.com>
> > ---
> > 
> > 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@gmail.com

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2015-07-01 18:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-21  8:39 [PATCH 0/4] Fixes for dell-laptop.c driver Pali Rohár
2015-06-21  8:39 ` [PATCH 1/4] dell-laptop: Update information about wireless control Pali Rohár
2015-06-22 19:06   ` Darren Hart
2015-06-21  8:39 ` [PATCH 2/4] dell-laptop: Check return value of all SMBIOS calls Pali Rohár
2015-06-22 18:26   ` Darren Hart
2015-06-27  7:34   ` [PATCH v2] dell-laptop: Check return value of all SMBIOS calls and do not cache hwswitch state Pali Rohár
2015-06-29 23:02     ` Darren Hart
2015-07-01 18:04       ` Pali Rohár [this message]
2015-07-01 18:08         ` [PATCH 1/3] dell-laptop: Clear buffer before each SMBIOS call Pali Rohár
2015-07-01 18:08           ` [PATCH 2/3] dell-laptop: Check return value of " Pali Rohár
2015-07-01 18:08           ` [PATCH 3/3] dell-laptop: Do not cache hwswitch state Pali Rohár
2015-07-02  0:42             ` Darren Hart
2015-07-06 10:09               ` Pali Rohár
2015-07-02  0:45           ` [PATCH 1/3] dell-laptop: Clear buffer before each SMBIOS call Darren Hart
2015-07-03  8:10             ` Pali Rohár
2015-07-06 10:08           ` [PATCH v2 " Pali Rohár
2015-07-06 10:08             ` [PATCH v2 2/3] dell-laptop: Check return value of " Pali Rohár
2015-07-06 10:08             ` [PATCH v2 3/3] dell-laptop: Do not cache hwswitch state Pali Rohár
2015-07-06 22:39             ` [PATCH v2 1/3] dell-laptop: Clear buffer before each SMBIOS call Darren Hart
2015-07-07 14:04               ` Pali Rohár
2015-07-07 15:52                 ` Darren Hart
2015-06-21  8:41 ` [PATCH 3/4] dell-laptop: Fix allocating & freeing SMI buffer page Pali Rohár
2015-06-22  8:46   ` Michal Hocko
2015-06-22 19:04   ` Darren Hart
2015-06-23  8:11   ` [PATCH] " Pali Rohár
2015-06-25  3:23     ` Darren Hart
2015-06-21  8:41 ` [PATCH 4/4] dell-laptop: Show info about WiGig and UWB in debugfs Pali Rohár
2015-06-22 19:05   ` Darren Hart
2015-06-22 18:02 ` [PATCH 0/4] Fixes for dell-laptop.c driver Darren Hart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201507012004.45275@pali \
    --to=pali.rohar@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=gabriele.mzt@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).