From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753372AbbF2XCx (ORCPT ); Mon, 29 Jun 2015 19:02:53 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44760 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752879AbbF2XCp (ORCPT ); Mon, 29 Jun 2015 19:02:45 -0400 Date: Mon, 29 Jun 2015 16:02:40 -0700 From: Darren Hart To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Matthew Garrett , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Gabriele Mazzotta Subject: Re: [PATCH v2] dell-laptop: Check return value of all SMBIOS calls and do not cache hwswitch state Message-ID: <20150629230240.GE57818@vmdeb7> References: <1434875967-13370-3-git-send-email-pali.rohar@gmail.com> <1435390483-10694-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1435390483-10694-1-git-send-email-pali.rohar@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > Changes since v1: > * Call clear_buffer before each sequential SMBIOS call (we expect zero-filled buffer) Another good independent patch candidate > * 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. ... > > 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. -- Darren Hart Intel Open Source Technology Center