Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1020119lqh; Sun, 5 May 2024 12:08:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYdAKPVAosFgrS/sOpjbjykpH3WacHKz1tUjmVrPUQT+6Vp7GnDDywrQkL+FnUUkOmMI5t/x4HpqQpsEbU+TozOYk7pqIMXZLCWcuZsw== X-Google-Smtp-Source: AGHT+IGCa5s2hGQ59du796aGXNNbAZtjlAICBwBxhOsHa2I4m/VLqLh7izCGNnguyWLF4shdQZ2G X-Received: by 2002:a50:c349:0:b0:572:983e:4aaa with SMTP id q9-20020a50c349000000b00572983e4aaamr7280885edb.31.1714936120651; Sun, 05 May 2024 12:08:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714936120; cv=pass; d=google.com; s=arc-20160816; b=foE1JRUdpqqj535VMT3ZgY2L4GmhH5vsO3bEWjamzlMDSpfc0FBvYnf3E2xRt3b4MD E7qCaZhzKouYlk1YPW/gbvcd6JVJjkbGTRcDrLIXChr5nKyEpI6szYlzkStOyjUMfh43 1GFJY5wikAZp+8OHFXAtfxuYW0U+kXjN1PUDVOkD96PGRcDLzrZYBZnQwS7ZcTXlYqGi QWPeUwubdA3WppbwDMhhDvqJ+tdn7Zj/mWPB0J0OrreOpZStLodQjUZlnmvNWRAZmLVY /I+XJqkXERUMtF61Lwya5eU/D/rhnSSjhbnH+VQFy+QSCKr8Bvujlmq1/D2ZikUHFSlW drIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=VL038o03al1MZShZoMM7qKoxWqUOlhoOy2o4egkWTT8=; fh=ULxNTxaaQIEX8Y9ih2rqqI9Lxn2bbvdaV8tkS1+QGD8=; b=hLlbzTeU7cnLKmzz7jxR8OD83N4Uwg4zjPaYXTVQZZ5yPzoexeTO+g0HA0C1hq+UA3 4zPwIPn/A45OxqrPBlIAs/WavyeQKRTEFYkyCjXX3AuME63k/VPJ+HdEgdFLRbAvaaEO sPnqy2+drjzEZtX0FCmnGIChSyDu+zDecMrh06Xdw3tVKWCGX8NSNP7+0L6ZOa+GZwJt 9LQPNjCHmtdKouTZ6armYKmDmD8q3ziME1yzAZABk775baTe5MQipwYLvwbZCT24qJx4 mw1IikyNUuX+TyvT0fFoYZmY/6zT/QmZLbnCAGXnETQcaIWfPwN1Ph7YEijjdycSct2x 7Ttw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnj2piaE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169107-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169107-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q22-20020a056402033600b00572ac3d6412si4236619edw.279.2024.05.05.12.08.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 12:08:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169107-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=@kernel.org header.s=k20201202 header.b=gnj2piaE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169107-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169107-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 61FF51F212A5 for ; Sun, 5 May 2024 19:08:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCBF16D1B9; Sun, 5 May 2024 19:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gnj2piaE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0992C2D60A; Sun, 5 May 2024 19:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714936112; cv=none; b=SuHgoBY+/xv8FxgzHvEogMACBTBPxOLU/YOT+yNBLGLFwCva+RfCXpfgL1nr+/UpBVhTnxVvFdOodKul+A/QFoE+wBr8UwzfgzqxJHthNJmTLghV611rAyezC2DeE/BOcP+kntxtrf4aGH1uCBLoPHyACyQ6TDeib1BS1F0gG/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714936112; c=relaxed/simple; bh=K16y/nn6xI0FhC18mkIVH38yRFOytXJYADZiDnJAY4o=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vj5Fkg+HZRphJYuwB5pbost3zTNusWkIBGEwiduS7J9MQ4d3O/nYXdqQ/+3HfGazyh9zma48GUIrB7/5tKh7iOGdqAzi9rWMMnHfH32Gbkf7BQcKEQTZUx62k1Mez3/+gztQupUzoCk/Yn+ESBCc7mwthbxsJgrFQJpVgCL/3EM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gnj2piaE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 021C7C113CC; Sun, 5 May 2024 19:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714936111; bh=K16y/nn6xI0FhC18mkIVH38yRFOytXJYADZiDnJAY4o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gnj2piaE8RInpdwYMyy6RgWw85A8XOf//mvl3UgTq2s3zxmhMZhSHNqWk6yGnwkVd gAFhvkU/YKPpBvIeoMxWC9U2cIVXNKZttlFZ3ypmzA9g+4ni4gcu2mb76HO7/HDnvZ 1ed1+CTaBBwM9oXadxEut3uLyp2q2OmeDR9/9ZlCc5t2W5vaHkv+Gz8n7OA9EQPUeO PahxyRjJngJORHsD9+pllV71aUcaGGMfhbZeFRP21W12wUB+cdkFGGRNEkcvO3RAle bGsCnU0/CyWWpk45g2sHoOmizmaJjkSuP5IZWlCGeSoqW34xBMPHeYU6o6u53yg18L V/DUcBP+OPxQg== Date: Sun, 5 May 2024 20:08:18 +0100 From: Jonathan Cameron To: Vasileios Amoiridis Cc: 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: <20240505200818.1e70c664@jic23-huawei> In-Reply-To: <20240429190046.24252-6-vassilisamir@gmail.com> References: <20240429190046.24252-1-vassilisamir@gmail.com> <20240429190046.24252-6-vassilisamir@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit 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! > > 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. > > Signed-off-by: Vasileios Amoiridis Jonathan