Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4437113rdb; Fri, 29 Dec 2023 01:26:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfsx3R6C+ZPI3pv8CJkBu/avQ6LaUg2QV22K01rpYCFmBHXpec3B4/L1e221PoEtg7UEAY X-Received: by 2002:ac8:58c1:0:b0:425:4043:29e8 with SMTP id u1-20020ac858c1000000b00425404329e8mr16414311qta.99.1703842005244; Fri, 29 Dec 2023 01:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703842005; cv=none; d=google.com; s=arc-20160816; b=h9C7HccpuVLIcErnEYkkFi5Nzq3rpQrf+Ws+bZTwaRmPVNcByTpeoOc6BA0mm3d9Rf UTOzx2Azrzlb4wiQkHKQtzp9TaFwffw12cAgOpKzHwhH8aYT6hTgxJEDwmzpf3/aq0iB jyIus8WIYM/FAEdCvA9xDmjzG6Ya80ZIEoC9CZ+sq8Z5XaNIIQkpcwJnMNjXuLjz3Hph Zx2muXjnailnXGTHf+V1PMEKrVZ+ve9J/QvId/xO/+GFIwy6Ug+z/nbuz7RlOt3DgGx2 RL2LbXvkZ1zifhTxqHN9RIlnfwmWPGVbfpkfjc9FJTioF9f1PjXLsbj+yExL84gfYO6L sfoA== 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=4CPc072cphdKuDuAHDK3JYBuTeNxIRsUN+ltDBLASnQ=; fh=cuSrpdmFbNnIGKLvcD6905UtzyKVEbJe+tTFY3eiseU=; b=CPqS09ea30wcK+QXEejVP5u4lyI6k3s1i2hTr0kZiEJX/d8Pwjy/pBVFEE3WHKXTpW 9SSFC4nP5FQ/0yXi1yrebG+iCTEuSdkIlTlR2Kcs5MgeKSTGxiEf0cajcdd/FvhiNnfY C8yEVkETQWAxLmyMoMuixBShVGr3DzSp0TMceH5NlZZg4McG6grRi0icE6YObIxEgSJ8 K66lyjbKOSIXZX14HDTLynxMvok8Ll8e+N3j91ghs26QF4lG2JH0AtGmk76ndBuHlBXI 01xsAz/vCUWL5glErWusK0P/Hl2Y9PsI63IuCwpNtCR6jypTY3V5lzn6/qzStfP+nHga 9xCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="Q6iGt/rq"; spf=pass (google.com: domain of linux-kernel+bounces-13031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13031-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t13-20020ac8588d000000b004254877622asi18702358qta.501.2023.12.29.01.26.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 01:26:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@subdimension.ro header.s=skycaves header.b="Q6iGt/rq"; spf=pass (google.com: domain of linux-kernel+bounces-13031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13031-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 0627B1C22DB7 for ; Fri, 29 Dec 2023 09:26:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33832125DB; Fri, 29 Dec 2023 09:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=subdimension.ro header.i=@subdimension.ro header.b="Q6iGt/rq" 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 6D1D9111B2; Fri, 29 Dec 2023 09:25:16 +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 AD3EC28B589; Fri, 29 Dec 2023 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=subdimension.ro; s=skycaves; t=1703841907; bh=u3xyd+nm/UZuOc3ZGkrOgUgkrAV7H1N45wZ4bM46qHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Q6iGt/rqPO/JT9MpC9yAhsdDth9McjbYCHpUsFU9C8BX7RCcKSvlXmz4AbhqdmDiQ 6InniD54xqzIL/taHDRqyoPG4bh6WF5yfeX3vJKIR9QxBuB5IREQ8gEJBs7KahBC1V GIDUsQrlynv466geO7D3L8QNRbRIXgQgdU4m8LA0= 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 v3 06/10] iio: pressure: mprls0025pa remove defaults Date: Fri, 29 Dec 2023 11:24:34 +0200 Message-ID: <20231229092445.30180-7-petre.rodan@subdimension.ro> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231229092445.30180-1-petre.rodan@subdimension.ro> References: <20231229092445.30180-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 firmware properties are present. Co-developed-by: Andreas Klinger Signed-off-by: Andreas Klinger Signed-off-by: Petre Rodan --- v2 -> v3 drop the use of dev_fwnode() entirely drivers/iio/pressure/mprls0025pa.c | 48 +++++++++++++----------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c index 233cc1dc38ad..e0a2a60c6245 100644 --- a/drivers/iio/pressure/mprls0025pa.c +++ b/drivers/iio/pressure/mprls0025pa.c @@ -353,34 +353,26 @@ static int mpr_probe(struct i2c_client *client) return dev_err_probe(dev, ret, "can't get and enable vdd supply\n"); - if (dev_fwnode(dev)) { - ret = device_property_read_u32(dev, "honeywell,pmin-pascal", - &data->pmin); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmin-pascal could not be read\n"); - ret = device_property_read_u32(dev, "honeywell,pmax-pascal", - &data->pmax); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,pmax-pascal could not be read\n"); - ret = device_property_read_u32(dev, - "honeywell,transfer-function", &func); - if (ret) - return dev_err_probe(dev, ret, - "honeywell,transfer-function could not be read\n"); - data->function = func - 1; - if (data->function > MPR_FUNCTION_C) - return dev_err_probe(dev, -EINVAL, - "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; - } + ret = device_property_read_u32(dev, "honeywell,pmin-pascal", + &data->pmin); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmin-pascal could not be read\n"); + ret = device_property_read_u32(dev, "honeywell,pmax-pascal", + &data->pmax); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,pmax-pascal could not be read\n"); + ret = device_property_read_u32(dev, + "honeywell,transfer-function", &func); + if (ret) + return dev_err_probe(dev, ret, + "honeywell,transfer-function could not be read\n"); + data->function = func - 1; + if (data->function > MPR_FUNCTION_C) + return dev_err_probe(dev, -EINVAL, + "honeywell,transfer-function %d invalid\n", + data->function); data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max; -- 2.41.0