Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp432958pxf; Wed, 31 Mar 2021 07:06:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwePUBQnOwhjoCgvln06GYAuh1GxoctbwxFNZBZiRnc903WpVZ0/9o/7mmBJOIloRvlhklY X-Received: by 2002:aa7:d3ca:: with SMTP id o10mr3929990edr.374.1617199618619; Wed, 31 Mar 2021 07:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617199618; cv=none; d=google.com; s=arc-20160816; b=pua1IhWkUhXeo+twoqoOH7OYbL2jXIFcFUkGGj8hj6TgvPoMOiEIFJ7nkAI07yBdfk f8gecvOXYVStF+Mhv8veHolCvxL4VB+S3CmghFV69zHlzUajTyRLEE91Lxy2zJvwCLwQ EP/r3r2qv8hc3Fviysa+pZsVwqJp1J8YjoSmMJHN288/Wsf7CkFQoOAGoJ0wdnAC08wZ IxBVOGJyGG4YWwDVC7x/J6hy7XVEP+ZRye8A0UgJueE5es992edx0ufoFdR4zVYuWPM4 7iPaEuWMPQfj4GfkJV4vekgpbkhh8b3nao3VdlCm3eFyawfvT8HdqfKppQ2S+JzP0vmO KVgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=eEc+5TO4dE6a0yhoy+EVdWoA/P8NQweT0KhWwf1g5Mk=; b=EvPZKfIND2h24gqHbDrcUON+BXcwWbrRhDooXAXQhnR/v4a07BXKB21AJYZVE7lNvx xoA00hWzms6Nc1x40rX845RbSKNGZm2B4uZeDXMfUDEwam9jPAEWpTxRAqUNESxim9hj gVRzc8XAEHLzGxsJjlNp/DfE4OGcYPrCJdh00mUb6FwIchIKM/56lJMXZypxdVWTVGPy UAbKhSBYn54M086BG64IHo20Cws8j52PQo0khi5TDbb2NY2Mz66iY8oFFwfuQPNICKJR XfPS7Ex08N2Amv/OiVpy3R6oATYwrTuM9hxAMk6zEFr+s0MDbfDlVi/Jeu7vdwFIOXl5 Xm/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H9JjzFVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb9si2018319ejb.29.2021.03.31.07.06.34; Wed, 31 Mar 2021 07:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H9JjzFVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235771AbhCaODL (ORCPT + 99 others); Wed, 31 Mar 2021 10:03:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:53928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235630AbhCaOCl (ORCPT ); Wed, 31 Mar 2021 10:02:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 488A2608FE; Wed, 31 Mar 2021 14:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617199361; bh=0SCL4cotKlzm/Rg3qeRdoMYBvamEm9kL9PkMi8TuWYg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=H9JjzFVCzfkjAOL9OTl+PIRCB06OE3pdLPwQIFHujODcVmNEknlCzHKurpxU17VsE bHeRQprPRU8TfheSh++N7O9CmElFSwa/PrN8OQeDTRKDGni7J/bkt8UWiX7oXqNT6A ILI/tRX89lQz2MZ6MYeEg98DF92fPACivZ5CWOoSGkqFuec8P3c/ESmS1E67K9hRMj +W5QaSmcQtx8kDMxxaOFFMYjDN3p6A+UqCLuAFmvNM4r4I2gYd+InyJskcQ2Y7A6VF vAiX8cjbOalm+NmPvEDqngg0dBCZjim4veGbeJG17IYK0G2/4giarcXa2UnyUMDPMR 7UEC9e/D3S7AA== Received: by pali.im (Postfix) id D09D3AF7; Wed, 31 Mar 2021 16:02:38 +0200 (CEST) Date: Wed, 31 Mar 2021 16:02:38 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Hermes Zhang Cc: lars@metafoo.de, Sebastian Reichel , kernel@axis.com, Hermes Zhang , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] power: supply: bq27xxx: Return the value instead of -ENODATA Message-ID: <20210331140238.jl3qprpqhqave4bf@pali> References: <20210331135141.8063-1-chenhui.zhang@axis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331135141.8063-1-chenhui.zhang@axis.com> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday 31 March 2021 21:51:41 Hermes Zhang wrote: > From: Hermes Zhang > > It might be better to return value (e.g. 65535) instead of an error > (e.g. No data available) for the time property. > > Normally a common function will handle the read string and parse to > integer for all the properties, but will have problem when read the > time property because need to handle the NODATA error as non-error. > So it will make simple for application which indicate success when > read a number, otherwise as an error to handle. > > Signed-off-by: Hermes Zhang > --- > drivers/power/supply/bq27xxx_battery.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c > index 4c4a7b1c64c5..b75e54aa8ada 100644 > --- a/drivers/power/supply/bq27xxx_battery.c > +++ b/drivers/power/supply/bq27xxx_battery.c > @@ -1655,9 +1655,6 @@ static int bq27xxx_battery_read_time(struct bq27xxx_device_info *di, u8 reg) > return tval; > } > > - if (tval == 65535) > - return -ENODATA; > - > return tval * 60; I'm not sure if this is correct change. If value 65535 is special which indicates that data are not available then driver should not return (converted) value 65535*60. If -ENODATA is there to indicate that data are not available then -ENODATA should not be used. And if there is application which does not handle -ENODATA for state when data are not available then it is a bug in application. > } > > -- > 2.20.1 >