Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937885AbdDSQ0d (ORCPT ); Wed, 19 Apr 2017 12:26:33 -0400 Received: from mail-qt0-f169.google.com ([209.85.216.169]:33483 "EHLO mail-qt0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763013AbdDSQ0a (ORCPT ); Wed, 19 Apr 2017 12:26:30 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170409135608.15621-1-carlo@caione.org> <20170409135608.15621-2-carlo@caione.org> From: Andy Shevchenko Date: Wed, 19 Apr 2017 19:26:28 +0300 Message-ID: Subject: Re: [PATCH 1/2] hp-wmi: Fix error value for hp_wmi_tablet_state To: Carlo Caione Cc: Carlo Caione , "dvhart@infradead.org" , Andy Shevchenko , Platform Driver , "linux-kernel@vger.kernel.org" , Linux Upstreaming Team Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1138 Lines: 33 On Wed, Apr 19, 2017 at 7:24 PM, Carlo Caione wrote: > On Wed, Apr 19, 2017 at 6:21 PM, Andy Shevchenko > wrote: >> On Sun, Apr 9, 2017 at 4:56 PM, Carlo Caione wrote: >>> From: Carlo Caione >>> >>> hp_wmi_tablet_state() fails to return the correct error code when >>> hp_wmi_perform_query() returns the HP WMI query specific error code >>> that is a positive value. >> >>> int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, >>> sizeof(state), sizeof(state)); >>> if (ret) >>> - return ret; >>> + return -EINVAL; >> >> Shouldn't be something like >> >> if (ret) >> return ret < 0 ? ret : -EINVAL; >> >> Looking into the code it looks like it may return all possible values: >> 0, negative, positive. > > When the HP WMI query returns a positive value something went wrong. > hp_wmi_perform_query() returns 0 on success. Yes, that's what I didn't object anyhow. My point is not to shadow negative errors if any. -- With Best Regards, Andy Shevchenko