From patchwork Sun Dec 24 14:34:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petre Rodan X-Patchwork-Id: 183067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp2161720dyi; Sun, 24 Dec 2023 06:38:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEp7MZouna1q1a/rJ/ozk9nbkajUvQSKXjV0iRjPx5jhQswlkKP+N8IYK6PiUMArSeyKwka X-Received: by 2002:a05:6358:9141:b0:174:b2f7:52e6 with SMTP id r1-20020a056358914100b00174b2f752e6mr4475928rwr.43.1703428684747; Sun, 24 Dec 2023 06:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428684; cv=none; d=google.com; s=arc-20160816; b=UBTZ9UnKjPCyJMjJhZpqo1bTJ7UX8yM1YKEvgwTDkdet60XXR7NaeGWFtyTRozgyzT ahCPS2J6FLua0OLibMaCno7hCobkqFAEwmcTKUMe6qgoS6stQWqonScyakVt7TIX45zB Ynj6qjN4fUybHcKOdQtrxFnNvQL3yh6DieuEKk4ah1q9PBhdcEanLX/MjDXXstW5t3uj Xrl2c5NmsvcHcMK7Nlgct2YWfzTIp9S8D5y8bcQgMaiygAdMyyTA1WhdPLJpOcGbTZir FgtpPNw04sQR2T6obYl3hNLUdVILaZW/33I8drnZFtTRvstjOpC/hHzt32ELlKmzREx8 OSUg== 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 :date:subject:cc:to:from:dkim-signature; bh=6TZQ4Ug7lcqqlOma6w90uAoBMvFhOU+W38A+OCSroUk=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=O/VjL6lA2E/yP+gigr7AcTn7spIHMB+mX6wlQ83kfmWp2l1EaMWVJZQhMkU0bGrFc2 MeKD/e+G2ttbHcCvbh24Vht85W6wf7NSCM1kt/32YrPiSwBZ7STUqg6xRJg8X4W96zfU VdtJdV9BucNmPpurMrx2aQeJb+Lfy3w7/DltL6ZUhITbd/Pp/NQ+t3erypNgs5BR7Kcj 6n4cgPD6VUV5INorG+oboqL/F5ix0fVd0KKxTiSNGeRY695sylhh62Pu7itKsaC74qsP 86xm0bKYNpqNzpkQXmw++aySb3WCK7OlwzLAUg979FBjR59qwMiJ83jlrqwbgBNfb1Tp 9ycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=UexyF4zT; spf=pass (google.com: domain of linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o8-20020a17090ac08800b0028bc7cefee2si6586697pjs.34.2023.12.24.06.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:38:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b=UexyF4zT; spf=pass (google.com: domain of linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B1BA4B216B5 for ; Sun, 24 Dec 2023 14:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 396A2134D1; Sun, 24 Dec 2023 14:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="UexyF4zT" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.subdimension.ro (skycaves.subdimension.ro [172.104.132.142]) (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 CE793CA62; Sun, 24 Dec 2023 14:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=subdimension.ro Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=subdimension.ro Received: from localhost.localdomain (unknown [188.24.94.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.subdimension.ro (Postfix) with ESMTPSA id F276B28B589; Sun, 24 Dec 2023 14:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703428512; bh=HLqQLEVNtiMPyM7hryG6OMvLH1BriN5OL0vabmTcwRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UexyF4zTPQ68Hmc6DOF9oHqK9Bws8Gl1X+lGqKuwYsVkDhIeyNI3yR+CKNEkGtH5i Lk7nkHiZmXeM9Xzu/CYRuYmcZJ7AD5IsJjW09cUhKWMvxWDQrMhR/nDnayXaBm92xh FxRVbWXoglGfuclOf2n6CjiG0hKbeYH/x6rkUeAI= From: Petre Rodan To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Petre Rodan , Andreas Klinger , Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko , Angel Iglesias , Matti Vaittinen Subject: [PATCH v2 06/10] iio: pressure: mprls0025pa.c remove dangerous defaults Date: Sun, 24 Dec 2023 16:34:51 +0200 Message-ID: <20231224143500.10940-7-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231224143500.10940-1-petre.rodan@subdimension.ro> References: <20231224143500.10940-1-petre.rodan@subdimension.ro> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786174436509164522 X-GMAIL-MSGID: 1786174436509164522 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. The current patch removes this loophole making sure the driver loads only if the dt has been initialized. Signed-off-by: Petre Rodan Signed-off-by: Andreas Klinger --- drivers/iio/pressure/mprls0025pa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.41.0 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 { - /* 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;