Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2900595rwd; Wed, 14 Jun 2023 08:39:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PzVTDsfEwIishIXoTFaCPUh2jNIkUUWzqPsOcWRpblMhQQzbv6+M9+0ilFO6BN4v4+UaL X-Received: by 2002:a17:902:ecc9:b0:1ad:8c8f:afb1 with SMTP id a9-20020a170902ecc900b001ad8c8fafb1mr13408386plh.39.1686757190668; Wed, 14 Jun 2023 08:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686757190; cv=none; d=google.com; s=arc-20160816; b=eH9VZZmjw7YBxjaP4GFFcOj5y3tVAtq1i4bH8WkOphx8cRj/furxUTUBmB4ZeyiB/r 65BFH/06fsOMpkBIIHx7TkRaYgzNfKXnNaL2vUhXGXevNhn+Ger2MbFEvjpMDUsmFkfH VgPEM8aB3hOEU/x6mB+pP2C4GWezjVgtr2klNX9EpU48uhJz+RyVD9MwrprKA0BpnfDC ht/WtVyIla5v6WBZZmUTfWp9/X+BTqgRM3DKqQ8eQpJ+mYzaUvWx1lDGrh5fubdhQ9oY 41dqtZb2oLn8A48zUKJm0AkV+FiEtQ01Hf7SY+YCRrD6KDxoHUaqjtv29g/Haj2lrOzd +mIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GYk4kd03iSGZhfVFprutdAv2aQV2Nsamx+2Vz5BGekA=; b=NnuVni5hBb1+ZGTdw8i3TUVt1Q2zNL9Yk8AxHoBenJ1LN7yEQDRL+WxQMqH5j+snF6 EUoelZBhnYm8Bhw/MWdklC3h+2sriPINH7lg9To2EpEU9xFkKgcIRbr1ADs91BUEV6G0 gfUA2hF7gOex2BUx7I0M4870uZ/QuFRAplJkVA7SmQxcVRCxfA788p2CrEO+Wgv+y1v6 ISKQW/uHaPwJr8WFX4R4UZ+4DeQoEAszPk4dc77YHKqCr3F8wgOByKEzADyUVND7o92a 8eJPl5ZhuDiznM2bqY1sCf8+ecsDp+SKTkKRLOVs/W4111pfgYQpVa+HkDdUQfVkCcQD MRhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EPB4Qf9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170902ea1000b001a93c1d66e0si11404954plg.269.2023.06.14.08.39.37; Wed, 14 Jun 2023 08:39:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EPB4Qf9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343634AbjFNPOF (ORCPT + 99 others); Wed, 14 Jun 2023 11:14:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343616AbjFNPOC (ORCPT ); Wed, 14 Jun 2023 11:14:02 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCDF2107; Wed, 14 Jun 2023 08:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686755639; x=1718291639; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=MmppHhausc57QaDzWWA+gNGrwmT8VwlTPcsgP+wDNds=; b=EPB4Qf9H6YZ4tk+JgNNcrXqVDzjY7JF91kF67YLUKuF0CQfR8bse0e+d mJMPrvxkr6/nR6hjp8fNPbQSBtmhpiJ/JK2uOCrze/Jivkd1JCPvBoCey xqneGYZkyOptC+ggRmO+NiWPmuGPgLWwtmz4jKWyWUCxEK+Ax4gp66FIN 2OyVBSvqGMW76+IBQ/riZp7hT8pF+MQDa6OngVmi6mge4vUtS3b4wB499 Y2+9/WyHRc6qV32BjVeb56rwUy1TpdY7y3Ls1zJKOf7qMCuvGkPUa7kRe uQR/FdcE/b7Pq0NPALutYr/2hTp00NWHZSdS0CyZQu6YHRy73GbzUyT4M Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="348301625" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="348301625" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 08:13:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="886272995" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="886272995" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 14 Jun 2023 08:13:54 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1q9SC0-003j7Z-2q; Wed, 14 Jun 2023 18:13:52 +0300 Date: Wed, 14 Jun 2023 18:13:52 +0300 From: Andy Shevchenko To: Alexandre Belloni Cc: Rasmus Villemoes , Alessandro Zummo , devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/8] rtc: isl12022: implement RTC_VL_READ ioctl Message-ID: References: <20230612113059.247275-1-linux@rasmusvillemoes.dk> <20230613130011.305589-1-linux@rasmusvillemoes.dk> <20230613130011.305589-6-linux@rasmusvillemoes.dk> <20230613212651c8770218@mail.local> <20230614135036a3e049c4@mail.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230614135036a3e049c4@mail.local> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 14, 2023 at 03:50:36PM +0200, Alexandre Belloni wrote: > On 14/06/2023 15:16:14+0300, Andy Shevchenko wrote: > > On Tue, Jun 13, 2023 at 11:26:51PM +0200, Alexandre Belloni wrote: > > > On 13/06/2023 18:20:56+0300, Andy Shevchenko wrote: > > > > On Tue, Jun 13, 2023 at 03:00:07PM +0200, Rasmus Villemoes wrote: ... > > > > > + ret = regmap_read(regmap, ISL12022_REG_SR, &val); > > > > > + if (ret < 0) > > > > > > > > I always feel uneasy with ' < 0' — Does positive error makes sense? > > > > Is it even possible? OTOH if the entire driver uses this idiom... > > > > oh well, let's make it consistent. > > > > > > /** > > > * regmap_read() - Read a value from a single register > > > * > > > * @map: Register map to read from > > > * @reg: Register to be read from > > > * @val: Pointer to store read value > > > * > > > * A value of zero will be returned on success, a negative errno will > > > * be returned in error cases. > > > */ > > > > I'm not sure what you meant by this. Yes, I know that there is no > > possibility that regmap API returns positive value. Do you mean that > > regmap API documentation is unclear? > > No, I mean that you'd have to be clearer as to why you are uneasy with a > test for a negative value when the function returns 0 for success and a > negative value for an error. Else, this is pure bullying. From the perspective of the code reader, a person, who might have not known all the implementation details of the calls this kind of check will always puzzle about positive value. When reading such a code the following questions are arisen: 1) Can the positive return value be the case? 2) If so, what is the meaning of a such? 3) Why do we not care about it? All this can simply gone if we use ret = foo(...); if (ret) return ret; As it's clear that whatever is non-zero we accept as something to be promoted to the upper layer. I hope this explains my position. > > > > > + return ret; -- With Best Regards, Andy Shevchenko