Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1893705rdb; Sun, 24 Dec 2023 06:36:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMCEyDvDRW4RZEJ3LFNCgd/dz3QW9gF5M9tzNXt46wchW6vYM24L17LEPYhP8kc7ODi9kb X-Received: by 2002:a05:622a:452:b0:427:922f:42af with SMTP id o18-20020a05622a045200b00427922f42afmr4960541qtx.46.1703428600676; Sun, 24 Dec 2023 06:36:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703428600; cv=none; d=google.com; s=arc-20160816; b=S6dj13Uk7j9wUo6Q0HZf245ExNYH8pyTAJC6NuYuXhUAlE9z0kdaK9Efhj5Nzl9yn1 AYVEaecAhwb5a0nhfuweU386CVTRGK1WjQWpqOIgNhDvq6LDtAZoSNIVDwTD8dLoYEDc +73pd4eehsat7fqC3qIl4YvsER+aYIbVL36pp+mLECvFwqOq7abHUWUtJuMlEvv7g/9h WBRLlCGR2zkgfpnUK50m2diFTMq/8qXDo3xf5TsaVzpx5pWYCPG/JxWqaQb5I/wApeXq tXtnGeJELq+m6ofS6xZ/bGv+6hkiShqoT8RtuG0lrVeXdKY9dcse59UrM6uNoxMSMAZ0 8taA== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=subdimension.ro Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p18-20020a05622a13d200b0042588c5be0asi8903874qtk.545.2023.12.24.06.36.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 06:36:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10726-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=@subdimension.ro header.s=skycaves header.b=UexyF4zT; spf=pass (google.com: domain of linux-kernel+bounces-10726-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10726-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5DE021C20DB3 for ; Sun, 24 Dec 2023 14:36:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 594B2FC12; Sun, 24 Dec 2023 14:35:23 +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 Content-Transfer-Encoding: 8bit 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(-) 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; -- 2.41.0