Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2900462rdb; Tue, 26 Dec 2023 08:39:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIvT5APFyHVViIAvHLnZPM2rfRgBWfGUv0HmWkTa64Ywu5s/D4exwBhmTXsfgUtMV++xUg X-Received: by 2002:ac8:5a8b:0:b0:425:4043:5f41 with SMTP id c11-20020ac85a8b000000b0042540435f41mr10727617qtc.127.1703608765705; Tue, 26 Dec 2023 08:39:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703608765; cv=none; d=google.com; s=arc-20160816; b=cOSmUdO7quNtOczD+Qf5v4V+Ip0dBAK3AcIYZzZ8PWKe15hM1iyIDHV24xzEpcJbZ+ Jn90buek4ZG+T3ymU3ytfhE1N40hg/45mn2MchYtkjrDqsBF+92Wy6eaFthLqhBGqIcN 6o4XoTS7ICWMFoK2gG+FVewMsFpD7cjGNnsn3dViIAlfuk7CVejkZH4sGDfuH1YLIFTn KcazXErVD0ePHiY7FgjHSSpHC8+qWrMo/1CaWmi/3vbfpJlT+8WG5lusUXwH/uPM+JiP zA//F1vhOUxTszPa0abP2Cza5hg6+dMlvWIiECG/x6p/niaax3SdQ0Qd9lfz68npnkZT ja3Q== ARC-Message-Signature: i=1; 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=46T+KfSO3ZvC6naa8bprSQTbcVVXwy9ALObaUos+wLA=; fh=IZEyg1r7+rdpYIMPOyKgmlT60DbvHqug0Qte+ho+yjw=; b=vYOnKNQdxW8nLUfGJggEtDUgobKpACPgydVRrXb5VyRGH8aPvavurbkq9WOeVyCWHW euRjI+NliO/+J2zyvx2bqP8UkXJRad2SbJ4jgotE0rHWqQRL5/wiYS1c8wroWWcJQHl2 0d+OI5Iim76fvhzkxxVNiDP5FbXS20XxRkPl434q8MHgwxQRLchr06/kuK1/SFP+IDm8 ezg4mfAvu8Cipp0pXfy8wfnlc7EUwR3lW57ejIrxMcUNv3SU5h3T3edpwYwQbgEmPIyQ uAVn6dqeeA2dz5GAaULNWdFHunsjLIJe+d96I/wMuf3sWU9eU6RPdPM88hiQ1OlX7Dvn YsLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H8s4Q5pW; spf=pass (google.com: domain of linux-kernel+bounces-11582-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u21-20020ac858d5000000b004259d9fde02si12448164qta.438.2023.12.26.08.39.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 08:39:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11582-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H8s4Q5pW; spf=pass (google.com: domain of linux-kernel+bounces-11582-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11582-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 73D2B1C21F5F for ; Tue, 26 Dec 2023 16:39:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E5CC4F880; Tue, 26 Dec 2023 16:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H8s4Q5pW" X-Original-To: linux-kernel@vger.kernel.org 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 5E9254F1FC; Tue, 26 Dec 2023 16:39:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA9F6C433C7; Tue, 26 Dec 2023 16:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703608757; bh=U/AR4wLwQTf7eqiS5GFn3+8pIrRcRjP/AN+Er7aV3o0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=H8s4Q5pW3psSYDICWfeN1fZWPVyH4bX2AebJtDedBOEcPnvLcfosu4Ps9rKB3oZ5r fP4GY3LZzPNR2nF6zkV6YnBCdiA/MEWNzvtH1EGcjT7oNshOxloGPazSZTyxNaR1GM VpnSlOnl7xY2gQtIMPFz3aiNnLpwikRDsqm/iFDFWd6G88WLaGKyuGpU7jykp0MRlp KP7ILevApKpMQhC6wGoxavLyKTIVXAd55KCgFXMcKQmSCIPoA5BLgsLSoYXWztmqgp U2Ju5kV6fQwVwHg82Gq+eZ8eicvpOViLeDfpGcQ05I7GJ3GJPFHHj9WBKb+unDF/i2 yAG5bsyXuMNAw== Date: Tue, 26 Dec 2023 16:39:11 +0000 From: Jonathan Cameron To: Petre Rodan Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Klinger , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: Re: [PATCH v2 06/10] iio: pressure: mprls0025pa.c remove dangerous defaults Message-ID: <20231226163911.35a4dba2@jic23-huawei> In-Reply-To: <20231224143500.10940-7-petre.rodan@subdimension.ro> References: <20231224143500.10940-1-petre.rodan@subdimension.ro> <20231224143500.10940-7-petre.rodan@subdimension.ro> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; 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 Sun, 24 Dec 2023 16:34:51 +0200 Petre Rodan wrote: > This driver supports 32*3 combinations of fixed ranges and transfer > functions, plus custom ranges. > > So statistically a user has more than 99% chance that the provided > default configuration will generate invalid pressure readings if the > bindings are not initialized and the driver is instantiated via sysfs. I guess 99% is strong enough that it's unlikely we will break anyone so fair enough to drop this attempt to guess the values. > > The current patch removes this loophole making sure the driver loads > only if the dt has been initialized. Drop the reference to DT. It's correctly using generic firmware accessors so should work fine with ACPI PRP0001 for example as well as DT. Usually we just refer to the need for firmware properties. There are lots of places they could be coming from. > > Signed-off-by: Petre Rodan > Signed-off-by: Andreas Klinger > --- > drivers/iio/pressure/mprls0025pa.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c > index 233cc1dc38ad..63c46592956f 100644 > --- a/drivers/iio/pressure/mprls0025pa.c > +++ b/drivers/iio/pressure/mprls0025pa.c > @@ -375,11 +375,8 @@ static int mpr_probe(struct i2c_client *client) > "honeywell,transfer-function %d invalid\n", > data->function); > } else { I'd prefer the condition flipped even though patch will be more noisy. if (!dev_fwnode(dev)) return dev_err_probe()... ... As end result will be more readable. > - /* when loaded as i2c device we need to use default values */ > - dev_notice(dev, "firmware node not found; using defaults\n"); > - data->pmin = 0; > - data->pmax = 172369; /* 25 psi */ > - data->function = MPR_FUNCTION_A; > + return dev_err_probe(dev, -EINVAL, > + "driver needs to be initialized in the dt\n"); > } > > data->outmin = mpr_func_spec[data->function].output_min; > -- > 2.41.0 >