Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1088646lqh; Sun, 5 May 2024 16:08:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRBr6MFQQWhEZyvJJ5J1GLtEd2ECTbi/jfUSvJAdsZl2sVVnLWsZE87DX1H3KGWR67MWHkNMq9x/TDcwccbq88q81OUdr6uTJx4HHvCg== X-Google-Smtp-Source: AGHT+IE/Luhu0FjBUKGTeAlfdPTTBo49Wf5KlICZ6BtegrirM7LcH3JBXGozEU8j7/gLLE7aoqcr X-Received: by 2002:a50:cdd4:0:b0:572:a852:c756 with SMTP id h20-20020a50cdd4000000b00572a852c756mr9550476edj.12.1714950508248; Sun, 05 May 2024 16:08:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714950508; cv=pass; d=google.com; s=arc-20160816; b=p57vwBSptSxBll80smF+6GbkRvtovhEfGF1Da9p9dCOCMzPY+G5spADSEaZlkjAQxo 4XIJPhnlqA9R/kVgVf+6plMneBpcoj7W02TOS4+KA/EL/qZe2F3e43CF2fMSOmbhWJzJ dx6SVbCJPI2fjL5I2EsalLSo9Aec/mwa04ts6FZCFy+jd3RbDdzX+uCQP8rIAPjnc+4N gzRXWcP2JkhKbqOem38xYh42R1A+obGKI0iplvxGwqBcfIRWqVZpnTvINqW0ByC0vIJG kHkD9jGqdTjWXqEbv6WxFmpIkl+NjT+tt2moIvPcvtR8/RtPEnQ9hh9liWNezgPO650S QutQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:date:from:dkim-signature; bh=tskK3STwMBeYl+RbxU4+ZeO0SLew6XfkR91Iyt3O2DQ=; fh=d7oOy59FXY9dsnoJKc0qaV68taoHb9i2U4iik/r+tG0=; b=pv+CmaRH433p8gg9g1cwbO0t2kcDpUuteRdf2KRgkheYz6+sy0FhMhPXVAqNVi77kh zhhAxh/5TJ9T6OeZ21/0zDkebvbMWfnceQe76Z9KK09jgenvAgIYpXiP/zoMvG8OuG1A kBC572k8lRx1BxTggNCNCFFWz+4GX/3UUqEkYcByGzF8yjg+PeXLvDfKhI54Ujb3DodF FD40RIUMlY4oneTeEBDsltWGzm9wOT39oUAQiacjpRLcIf1HttikCvwvvKU5mRuH8AjR OcQAfM85TxmMlfQMs96zI5p2bQ7/VsyWr1YcwWZMPoOkEQ0YeSjHLvlrZYRAKE9xCW1k Ap+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jt4PHsNP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-169197-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r22-20020a50aad6000000b00572a7690ab9si4021822edc.10.2024.05.05.16.08.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 16:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169197-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jt4PHsNP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-169197-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169197-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8ED141F216C0 for ; Sun, 5 May 2024 23:08:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6721B14037C; Sun, 5 May 2024 23:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jt4PHsNP" Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6AD4374CB; Sun, 5 May 2024 23:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714950497; cv=none; b=kbQsuzlPFhuuQmgL/+0+H6A+w4VjfxzYewIELF80G2ngqmMoIKf552ns4FFw29d9MxUZwV0jir9xinqRjkzub9jCTyECQ8G1DWdB6Jf3THWY3mgv6LKSSnYxZiHPwn8igmwN9ItYDBd9JeSSTHQ37newtrrbQV+SVhUnrCCQ2TQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714950497; c=relaxed/simple; bh=sO1bCtWtZNtX/y3txjwfHuSjDHCzKW6qrmiRBggkaHc=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ao/IMDdchMc2J8T/zFORjEyDTScxmcZ/ge1kgIscUKHebFTja06erE8RnmGl2zvcOcw0L7tKssAyEZqdgufgH3M6rlNwXJGHBvbAvRX5lneYh3iGWhG3LGnL+Oow0hY9Snf1KCDQsjWCof1bjeTAV9GxvHmeVnv9w14mj8q0Ssg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jt4PHsNP; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-572babec735so4654450a12.0; Sun, 05 May 2024 16:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714950494; x=1715555294; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=tskK3STwMBeYl+RbxU4+ZeO0SLew6XfkR91Iyt3O2DQ=; b=jt4PHsNPBjvyXGxcI36zkmFAluURyjQT+cf8/o8atcLfJ9YUowORTPxu4IBJXQiKAJ rCSgtdyIJuvDEWt2SO8NB6jfAw+tgXHX/7LZ4S0RKLOHZq8kqRfq4eRyt/0WjP+B6Uhp dSawqV4dCX7wMZQVn8+OeF8NTCJLp+4xPBpWf5QibF+BBFhpvTfDFqje7htkrmUF2UTA RjrzL73tgBf7aKuD09e9i438kmxMQHJOkZZQaU5yjut88PPoEnUES87+O2i+M53IGgis CDUbRVbvLa9omLqT3VQ2LMozN/4eGkNSPFtk7p6I/noz65GrEc0MlP4VMYzTUnZWm5PL lJDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714950494; x=1715555294; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tskK3STwMBeYl+RbxU4+ZeO0SLew6XfkR91Iyt3O2DQ=; b=WOhCcZFlj/a6HAZNAzWkQnJfaZT/csWNPqLcByaTM0ZUJLkBVPQwwGF+bQlVx5o9Lg g+cLrfo7PFj7+f4z4SZNAzoJmuWywhEbirxLQvEEU1l4I7rc9kcggv5C65urBbBRgeso 2nlNUqgEvzmep+Uvn1A4Yi7Whm2x56vNT+c0Mk2ZSGcSmJjIrbDxq9NgpvfgH2MmkPOF eVKkArC6yJdPwOUY91p7PTMAlBkvgz4sDXPbHE8gsKmFN7k3sJ7FMRkvchZVIzO5MCz3 luVfb4TdgPY9rJrAJffvlzI81SCtcv7h5Iq0VqNancxP7WKyj6XKnArlH27xGum21aUp QQZQ== X-Forwarded-Encrypted: i=1; AJvYcCWvkEwkkx5QKhtWPuWY2GiOTOGbAIynquq6LY3KzaP6o+wNM2I71j8P8F2f757yP3ke+j5skKWmK/4r+f8SKPFLzX5tT2vHtYKVJWV2G0GdATho+XH8akKeJ/nQ8KSiu6EX0LV3J+Uf X-Gm-Message-State: AOJu0Yw0m8Fzeq019ZWsta3MaGI8ZZs3AxpuXio1Dd3STOXANEOXbpKO cRi6fLNENMLfSJ2FJ5SSOuTwuwVgp1wYgRMkj4iBMFEP3RYLJMwz46JhODk66YI= X-Received: by 2002:a17:907:7d91:b0:a59:ccc3:544 with SMTP id oz17-20020a1709077d9100b00a59ccc30544mr1246280ejc.2.1714950493898; Sun, 05 May 2024 16:08:13 -0700 (PDT) Received: from vamoiridPC ([2a04:ee41:82:7577:7a5f:ec16:256e:4660]) by smtp.gmail.com with ESMTPSA id er21-20020a056402449500b005726e5e8765sm4423133edb.3.2024.05.05.16.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 16:08:13 -0700 (PDT) From: Vasileios Amoiridis X-Google-Original-From: Vasileios Amoiridis Date: Mon, 6 May 2024 01:08:11 +0200 To: Jonathan Cameron Cc: Vasileios Amoiridis , lars@metafoo.de, andriy.shevchenko@linux.intel.com, ang.iglesiasg@gmail.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, phil@raspberrypi.com, 579lpy@gmail.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 05/10] iio: pressure: bmp280: Make return values consistent Message-ID: <20240505230811.GA17986@vamoiridPC> References: <20240429190046.24252-1-vassilisamir@gmail.com> <20240429190046.24252-6-vassilisamir@gmail.com> <20240505200818.1e70c664@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240505200818.1e70c664@jic23-huawei> On Sun, May 05, 2024 at 08:08:18PM +0100, Jonathan Cameron wrote: > On Mon, 29 Apr 2024 21:00:41 +0200 > Vasileios Amoiridis wrote: > > > Throughout the driver there are quite a few places were return > > values are treated as errors if they are negative or not-zero. > > This commit tries to make the return values of those functions > > consistent and treat them as errors in case there is a negative > > value since the vast majority of the functions are returning > > erorrs coming from regmap_*() functions. > > The changes are fine, but that argument isn't correct. > regmap_*() functions never (that I can recall) return positive > values, so if (ret) would be valid for those and I'd have expected > the exact opposite outcome if you are looking at regmap*() return > values to make the decision. > > The if (ret) pattern is sometimes used throughout because it > makes > return function() > > consistent without needing to do > > ret = function(); > if (ret < 0) > return ret; > > return 0; > > That pattern isn't particularly common in this driver (there are few cases). > We also tend not to worry too much about that slight inconsistency though > in a few cases it has lead to compilers failing to detect that some paths > are not possible and reporting false warnings. > > However, all arguments about which is 'better' aside, key is that consistency > (either choice) is better than a mix. So I'm fine with ret < 0 on basis > it's the most common in this driver being your justification. Just don't > blame regmap*() return values! > Hi Jonathan! Thank you once again for the valueable feedback! Of course, if (ret) would be valid for the return values of the regmap_*() functions. I was just trying to understand which of the 2 options is more widely used in other drivers and I tried to implement that. In general, the if (ret) is used 65 times while the if (ret < 0) only 20. So, in terms of noise, changing the if (ret < 0) to if (ret) will create less noise. I chose the if (ret < 0) because I saw other people using it and it felt better in my eyes. I could check if if (ret) applies everywhere and update it in the v6. > > > > While at it, add error messages that were not implemented before. > > > > Finally, remove any extra error checks that are dead code. > > Ideally this would be broken up a little more as, whilst all error > code related, these aren't all the same thing. > > I'd have preferred: > 1) Dead code removal. > 2) Message updates. > 3) Switch to consistent ret handling. > > However it isn't that bad as a single patch, so just address the question > above and I think this will be fine as one patch. > Since from your comments in the next patches a v6 is for sure, I could split this as well! Cheers, Vasilis > > > > Signed-off-by: Vasileios Amoiridis > > Jonathan