From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756064AbdKCMAD (ORCPT ); Fri, 3 Nov 2017 08:00:03 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:54497 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbdKCMAB (ORCPT ); Fri, 3 Nov 2017 08:00:01 -0400 X-Google-Smtp-Source: ABhQp+S53z4koaBE5RK6scEmyDMerRKc6/TaIGTC6L04HdzPpKUYk27mRRwCWK3DEDfk1nJJy4GXPaUzm1uSBBfi0z0= MIME-Version: 1.0 In-Reply-To: <354baacc-58dd-7012-de2c-11042604826e@users.sourceforge.net> References: <17ee534c-9fe6-19c4-0522-76cd3cbe5f88@users.sourceforge.net> <354baacc-58dd-7012-de2c-11042604826e@users.sourceforge.net> From: Andy Shevchenko Date: Fri, 3 Nov 2017 14:00:00 +0200 Message-ID: Subject: Re: [PATCH v2 1/3] Sony-laptop: Fix exception handling in sony_nc_setup_rfkill() To: SF Markus Elfring Cc: Platform Driver , Darren Hart , Marco Chiappero , Matthew Garrett , Mattia Dongili , LKML , kernel-janitors@vger.kernel.org, Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 1, 2017 at 8:46 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 1 Nov 2017 18:42:45 +0100 > > Source code review for a specific software refactoring showed the need > for another correction because the error code "-1" was returned so far > if a call of the function "sony_call_snc_handle" failed here. > Thus assign the return value from these two function calls also to > the variable "err" and provide it in case of a failure. > Applied to my review and testing queue, thanks! > Fixes: d6f15ed876b83a1a0eba1d0473eef58acc95444a ("sony-laptop: use soft rfkill status stored in hw") > Suggested-by: Andy Shevchenko > Link: https://lkml.org/lkml/2017/10/31/463 > Link: https://lkml.kernel.org/r/ > Signed-off-by: Markus Elfring > --- > drivers/platform/x86/sony-laptop.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c > index a16cea2be9c3..4332cc982ce0 100644 > --- a/drivers/platform/x86/sony-laptop.c > +++ b/drivers/platform/x86/sony-laptop.c > @@ -1660,17 +1660,19 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, > if (!rfk) > return -ENOMEM; > > - if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0) { > + err = sony_call_snc_handle(sony_rfkill_handle, 0x200, &result); > + if (err < 0) { > rfkill_destroy(rfk); > - return -1; > + return err; > } > hwblock = !(result & 0x1); > > - if (sony_call_snc_handle(sony_rfkill_handle, > - sony_rfkill_address[nc_type], > - &result) < 0) { > + err = sony_call_snc_handle(sony_rfkill_handle, > + sony_rfkill_address[nc_type], > + &result); > + if (err < 0) { > rfkill_destroy(rfk); > - return -1; > + return err; > } > swblock = !(result & 0x2); > > -- > 2.14.3 > -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Fri, 03 Nov 2017 12:00:00 +0000 Subject: Re: [PATCH v2 1/3] Sony-laptop: Fix exception handling in sony_nc_setup_rfkill() Message-Id: List-Id: References: <17ee534c-9fe6-19c4-0522-76cd3cbe5f88@users.sourceforge.net> <354baacc-58dd-7012-de2c-11042604826e@users.sourceforge.net> In-Reply-To: <354baacc-58dd-7012-de2c-11042604826e@users.sourceforge.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: SF Markus Elfring Cc: Platform Driver , Darren Hart , Marco Chiappero , Matthew Garrett , Mattia Dongili , LKML , kernel-janitors@vger.kernel.org, Andy Shevchenko On Wed, Nov 1, 2017 at 8:46 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Wed, 1 Nov 2017 18:42:45 +0100 > > Source code review for a specific software refactoring showed the need > for another correction because the error code "-1" was returned so far > if a call of the function "sony_call_snc_handle" failed here. > Thus assign the return value from these two function calls also to > the variable "err" and provide it in case of a failure. > Applied to my review and testing queue, thanks! > Fixes: d6f15ed876b83a1a0eba1d0473eef58acc95444a ("sony-laptop: use soft rfkill status stored in hw") > Suggested-by: Andy Shevchenko > Link: https://lkml.org/lkml/2017/10/31/463 > Link: https://lkml.kernel.org/r/ > Signed-off-by: Markus Elfring > --- > drivers/platform/x86/sony-laptop.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c > index a16cea2be9c3..4332cc982ce0 100644 > --- a/drivers/platform/x86/sony-laptop.c > +++ b/drivers/platform/x86/sony-laptop.c > @@ -1660,17 +1660,19 @@ static int sony_nc_setup_rfkill(struct acpi_device *device, > if (!rfk) > return -ENOMEM; > > - if (sony_call_snc_handle(sony_rfkill_handle, 0x200, &result) < 0) { > + err = sony_call_snc_handle(sony_rfkill_handle, 0x200, &result); > + if (err < 0) { > rfkill_destroy(rfk); > - return -1; > + return err; > } > hwblock = !(result & 0x1); > > - if (sony_call_snc_handle(sony_rfkill_handle, > - sony_rfkill_address[nc_type], > - &result) < 0) { > + err = sony_call_snc_handle(sony_rfkill_handle, > + sony_rfkill_address[nc_type], > + &result); > + if (err < 0) { > rfkill_destroy(rfk); > - return -1; > + return err; > } > swblock = !(result & 0x2); > > -- > 2.14.3 > -- With Best Regards, Andy Shevchenko