From patchwork Thu Nov 28 23:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasileios Amoiridis X-Patchwork-Id: 13888371 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAB701C7B85; Thu, 28 Nov 2024 23:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836308; cv=none; b=JkvZ5kNTv11PASnfNrI/E/PpCO/v9oqtDpYl32LCrelV4hmAPbmzqBX1XH+AHGjOrKLi5vKx5Zd/LQRAamehwGAHvNsfuAtV67IRdWOOYPP3p0wAgb+oOHqTAauQN7Hl+vINQq2izmjz2l8yfDgBr8bmDTvolt23HIyc1wayctU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836308; c=relaxed/simple; bh=I5vv2fWuCCm+0kMBnAa/cHM5vA7PqH5H1QTs6M7O+zM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GayGiLLTBFgoMp50yKmDb5aZrN6zQQbqZkcCRKHD/gHJXh5Gv+sp8YT1iuQ0OQNkfOWd++zru+8cjs9GzIXVV3ZIWXGXWXhkldW0ZSfMHrTvv2IshlhEu4hu8GfojS2dZtTExDcM2nQkICm1X/tGtA1kYQuJjmOihbbIKXIVXcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SViYUbqf; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SViYUbqf" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-385deda28b3so8140f8f.0; Thu, 28 Nov 2024 15:25:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732836305; x=1733441105; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zYXADLk7e56HOtJ9NIfhy4w3YpkQF11ICyrRorAihY8=; b=SViYUbqfa7HyAGl09DRVrSxso8Ealk6EAGiTcse1KgOmYCDmCwuMsW0X4p2mDqeHyq kdM69jM2+lDQ0HMqJyodFijhnY4Em+ZDmAyvwTAEtVJ70zHQJjwo/V9jFXi/g+OkYhmj gLLnuq8shYxE33m8LKfFf8RjzICvpJfEr/Pbd3PBiXwhb8JpK7F0VjqpXDTldR0vPVzM XKi8sckUSVE8l2Vcm3A/Kpt1wP1eCYiWKDafe74IbrTgoLD7nyoDq7NWmiFyG8M/khzl 6KIn2lus/YgmPeOqWpOaYm207Gq1g5MJPeVC4tAytXsejcWTcFDuurELjdjgw7Scs+EY IvRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732836305; x=1733441105; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zYXADLk7e56HOtJ9NIfhy4w3YpkQF11ICyrRorAihY8=; b=RjtjHl6dGkQ9q9gvM4pi48zOl74yjXUP0+reBYYgaFAlS+JPKY8MyxeeYvHzwF9MfS yLTADShQtWWTgc27aHrRkyZ4l+KOJbIoQOl/xdReZQxfWHawsvUU5TYtsIO/nJm3ryF7 Z5zVIl2JvqL48HMe+ENetc1CUvfsP835a3CSLbnWEpxAstHD6+S7IHLb1p3B7mZLp08q Jv1Uruq0H+vZtz993BtQbWAntdOC/g3ckdwC1SSfx3hPGBmbiR5gP29lDjomBIH1Oanj RmzriZ0VHXZRyJAz99V6SiZ3wXA+r/qbLyHE3KlCsol+jggNc16MILMoJZsySaQFrjfM hmPw== X-Forwarded-Encrypted: i=1; AJvYcCWcxLYBdp/UgUayd2h365PagC+fl++jn6qZhiNRgfDu906oDaFwfSHQuXATRkokr8QGYTmh2OHChLa6BQbD@vger.kernel.org, AJvYcCWxeDzBH1YF3xxZWP9TSfi8jXwje2K6HOyzEkWch7PMkuRImvJOWwUQ/T+XzAjZEyhHIfEGlxk3U6cw@vger.kernel.org, AJvYcCXNnXtKpOiRzjy9iblGfZiRDjcsgOK0zKtfCz3oRQF6CEnuiULW81kQQC/zh+surA9wd5VbmK5qqczv@vger.kernel.org X-Gm-Message-State: AOJu0YyRDCR3NAkYCStm/8BFMls7nxKdDA5lvi/eELXfcIxXuTwDyrJ5 8huUPdzneFv2h30yHXAKqfPtVlPjsr5aaSV9yr/K5yO+JrWsupE1 X-Gm-Gg: ASbGncuNw1Yz0wqpfxKxH7itWW6kLxlTJXV3WZaMDxldsBNzGdkgp41HSJ3JLwWvx0i zz0vCnH2ivfe5bO0ynHYG2xvuu/bVoEw37elheczM1NkdSiDGsJxTS96+MHj9R4TZy2IrDvD3Gy MALsZQF1L48uN5TCDma+JiRoLXOCnbBWSmFb1jXezFYhGxyljmh7v8bUwf8erlPfN8BiEGSzJEh 2vdebR00maAYfM6dxEpQojCrLuq+Ku8QbicNR2nDWkMwAjUbP/yu9EYP+nWbwg= X-Google-Smtp-Source: AGHT+IE67yzwQn+Gsp3D0lStWLhO3MHN+OUySiwVy8B6BoCexP/iHdjj1N6VZ+ot33T4CXCUMCbvNQ== X-Received: by 2002:a05:6000:1865:b0:382:4a3b:5139 with SMTP id ffacd0b85a97d-385c6ef598emr7320578f8f.59.1732836305006; Thu, 28 Nov 2024 15:25:05 -0800 (PST) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:a8c6:c7bb:87d7:66dd]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-385ccd3690dsm2765594f8f.35.2024.11.28.15.25.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 15:25:03 -0800 (PST) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: ajarizzo@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, vassilisamir@gmail.com Subject: [PATCH v1 1/3] dt-bindings: iio: pressure: bmp085: Add SPI interface Date: Fri, 29 Nov 2024 00:24:48 +0100 Message-ID: <20241128232450.313862-2-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241128232450.313862-1-vassilisamir@gmail.com> References: <20241128232450.313862-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The BMP{2,3,5}80 and BME280 devices have an SPI interface, so include it in the device-tree. Signed-off-by: Vasileios Amoiridis Reviewed-by: Krzysztof Kozlowski --- .../bindings/iio/pressure/bmp085.yaml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml b/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml index cb201cecfa1a..cbddc7bb26a6 100644 --- a/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml +++ b/Documentation/devicetree/bindings/iio/pressure/bmp085.yaml @@ -55,12 +55,16 @@ properties: If not set, defaults to push-pull configuration. type: boolean + spi-max-frequency: + maximum: 10000000 + required: - compatible - vddd-supply - vdda-supply allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# - if: properties: compatible: @@ -73,6 +77,19 @@ allOf: then: properties: interrupts: false + - if: + properties: + compatible: + not: + contains: + enum: + - bosch,bmp280 + - bosch,bme280 + - bosch,bmp380 + - bosch,bmp580 + then: + properties: + spi-max-frequency: false additionalProperties: false @@ -93,3 +110,21 @@ examples: vdda-supply = <&bar>; }; }; + - | + # include + # include + spi { + #address-cells = <1>; + #size-cells = <0>; + pressure@0 { + compatible = "bosch,bmp280"; + reg = <0>; + spi-max-frequency = <10000000>; + interrupt-parent = <&gpio0>; + interrupts = <25 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; + vddd-supply = <&foo>; + vdda-supply = <&bar>; + }; + }; + From patchwork Thu Nov 28 23:24:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasileios Amoiridis X-Patchwork-Id: 13888372 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D5C31C9DC0; Thu, 28 Nov 2024 23:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836310; cv=none; b=aYHUpqkRQuEElXxglAfJsogtomjFXI8o0lhXjqdPp1Ab0eJkv8RcBtPAnL1HLiQjvXp3XjU8y/o67Z3+gKd1OtJYNm6N1cojfZdNFPJ5yglsnqPdvXdwJbhVS2/Uev390owx8EU/iyU6WtjOecmDVCE0/YXZxCly7w6dEt++uoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836310; c=relaxed/simple; bh=yCz2bEMANU8BAJI6d7k4tpvF4CtTd2lE9JWwo2Rul7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mDP1OLn3awWFCFWYXa6IcODSemYp2sOQmyrT0zp5Kb1H1Q2uIMoT4bTV+0WxoKJjbfp5cVryfLjB924CcCIkqq8DwgkMtG5eEP61uwMtWnHsYp2rFuSBymYvfDLILXBczipgjgXzPPVqPa3XKk1vPXIFkNyLs8jvBCuHMCr8sg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Cru8kqft; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cru8kqft" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4349fb56260so11378465e9.3; Thu, 28 Nov 2024 15:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732836307; x=1733441107; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=62cOZRybRIU4PTMZ+LDcmP89/ORe8vWHVhtloqqzP8E=; b=Cru8kqftZRiKsBTD5oq9wISfG26JieiTYraDfoDVhNPIzTTkaEsNRajHLGpPWoagQE oi8FEdfVhz6TlZIkg04+wMVaf5a46XaZeD5d52cCRcdhngkV4ebV6XY93K01m/6UQj+6 ydwb6O+H3dOv9SlFIGkPaKjxztlu58wwH8m05tcXTkz9BrtjLDnThq/3W3hY1gSz6KsQ 7lCfWIl2nO/JVXX1awtW5/RqPEW7dN1T3CtjcWit5GlIFA+RLaEFKPHTXufzaD66QVQA ++kCV9ghwqqX2+7wgOVUnqN1chNmZgsls/vJ7EmKB7WavK8WO1kmcWNFCQ+y1gv0d+sv MXPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732836307; x=1733441107; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62cOZRybRIU4PTMZ+LDcmP89/ORe8vWHVhtloqqzP8E=; b=VncFB26DSNbmsJLwGg1NnR8QZKCtCIfw5cxoOXo+W9xX64bZHe1azZVnd+iJ8aznf6 qkdzHvzSZB3Zui6Sbj2Dm1DZdWms8YyZaONvSl1Jx/IYtTFfovjsUg9rTjZzF9jNQZsK BOOI7xARM5rb9vVO0x6XJ7oB/7zTRSfcK+5L/LFwsqKPk2/4qklK502MGGB0kDFEyr60 ubC2wVM5EjMgNBiWw2ZI4leQaWRwatI3aHvqWOlOArLM0qhS+xqe4QtSGuRtT+Gulrod FxqgWkWFoIku8yr9CsDTxvWGtOuAarPurdYMvwn2/0muYWI+FBevi1P26E7drVz6cQw/ AKTw== X-Forwarded-Encrypted: i=1; AJvYcCUU7fJBa19AvKLhsgu0sn29G1O+2M3RmZZzqx+qpo71ZgQFx9hwfemuQHw/DPJmOUUnw5e0pxpUY7UI@vger.kernel.org, AJvYcCVqJByKz8mApy+jytaQ+YMs8LG0wYJGWwWspCD1c/IcvhQjPTVxQ8Wxgbk26AyNaQWFdl0WASwr0VmV@vger.kernel.org, AJvYcCXhSGKA2ZLAf1L8yHDO8UUpo4IiPtosCfPzranqgHpu7PY3Q2uSZ8MvDv/BqVT5dLgeoictIK/dCRdG30yE@vger.kernel.org X-Gm-Message-State: AOJu0YzjvpTlc+C30Q2mfPo+ffh/obJ+CqoRHw7HZjwbBR4jbExyyIjQ 9emKIs+IWq7mMKnZEJ/t7n8WtbaS3kihKwynuVDBPnu/U/MI7tfn X-Gm-Gg: ASbGncuM+N4091i0YhDj076F8BJj+OYWUW8BsfSsZPUTgiRWQtkG3wiJTD4H4vB2i0d cyhysPaiiqHxfaaRHd/FOJdia435J9yu63/XN6nN36BBA6kFJBx0OmOLkArW+ZRCTYB0/ORXefV I0DGwP6oqIFvueKymZazF0Wax9XSP1wI4DAMc341T84pZKouqaaiZ/QljfO0M+f7mGh8ot2mzVp cvTgMh6drnTi+VnesR9qNZW/YXb8JB/9D/QvyxM3gogHo7JtmmZMmTq2/vwVDs= X-Google-Smtp-Source: AGHT+IFASptjQfdTDZ415F27fC2FVT6lRlq6Qx6ZmtK0KECj9jnPWy+rEitFHQ09t3B5SqXgEdAilA== X-Received: by 2002:a05:600c:4fd6:b0:434:a781:f5d2 with SMTP id 5b1f17b1804b1-434a9db8483mr76848245e9.5.1732836306513; Thu, 28 Nov 2024 15:25:06 -0800 (PST) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:a8c6:c7bb:87d7:66dd]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-385ccd3690dsm2765594f8f.35.2024.11.28.15.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 15:25:05 -0800 (PST) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: ajarizzo@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, vassilisamir@gmail.com Subject: [PATCH v1 2/3] iio: pressure: bmp280: Use sizeof() for denominator Date: Fri, 29 Nov 2024 00:24:49 +0100 Message-ID: <20241128232450.313862-3-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241128232450.313862-1-vassilisamir@gmail.com> References: <20241128232450.313862-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of using magic number 2 as a denominator, make it intuitive by using sizeof(). Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index 2df1175b6b85..a3631bc0e188 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -470,8 +470,8 @@ struct bmp280_data { /* Sensor data buffer */ u8 buf[BME280_BURST_READ_BYTES]; /* Calibration data buffers */ - __le16 bmp280_cal_buf[BMP280_CONTIGUOUS_CALIB_REGS / 2]; - __be16 bmp180_cal_buf[BMP180_REG_CALIB_COUNT / 2]; + __le16 bmp280_cal_buf[BMP280_CONTIGUOUS_CALIB_REGS / sizeof(__le16)]; + __be16 bmp180_cal_buf[BMP180_REG_CALIB_COUNT / sizeof(__be16)]; u8 bme280_humid_cal_buf[BME280_CONTIGUOUS_CALIB_REGS]; u8 bmp380_cal_buf[BMP380_CALIB_REG_COUNT]; /* Miscellaneous, endianness-aware data buffers */ From patchwork Thu Nov 28 23:24:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasileios Amoiridis X-Patchwork-Id: 13888373 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80CB71CB50E; Thu, 28 Nov 2024 23:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836312; cv=none; b=LEQaY0ZasVQku6jqzXJlIqEg6yZOzarWsTdrOZoC3Np+EffICbvDn53NbvISqZBrQIti9Z1f2e2/ouvv72VXW1TZSOk8cCp/fJMgu7PCUjJJe7sUeHjSpKJZTqa1MuB1RoZETeVR89ew44FwwDTYlp0iqqQ+8de2y1zdOZmSIF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732836312; c=relaxed/simple; bh=/dCE5jtTkrfmNN2qX5Te3n2ZNlxnl5+2YcieRX+C2vA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W5AoweQGUjNPezv3+vVqzizPgGKIqq6dPhjADzGn/M8YMCr9L9LNG42zZPxsL+3fDSDleN/F+PpFzkWRKCyv0AKtp3kNvCDcqHFmQEqEEasAbotnpfOGSx+lWSyatLECSKRigYmYkVuvvXm8UyeCH+IxY6P9quBWNsBiNQnhOi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q/BYAoHF; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q/BYAoHF" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3824709ee03so973235f8f.2; Thu, 28 Nov 2024 15:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732836309; x=1733441109; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YjF5NHMyK7y7jg65uvCn9MXduypsA+uz1rOx/op7hXs=; b=Q/BYAoHFWd3ZyLWhTizPr+7d4Q+BwUPGwJ+19ZtWDhviLD2gQLuO6tG4lI7KPrmKcg lNdat5C1xKuNSYn/vudBPRu1WrHkooxZp6YQ2ukxig8F/LTBLKgudVGVIkXuEKngaz8R QKe9UAMLbDZkkbJtxTnbvnCrVnD8jLnmMSq52rTGx1CKonC8u3o+L7JH0wtO8OxrcoNv lDvTO8+hzlAyd9AW4gN/f5Ri+Cj/9jmPqNEp3jUc7lcPrVAinv+selenH0a+uP1DxATM A/h1OvcnhN8bQdBbzUh7vTPtjOIjXKc587zxh04tb+a6r4RYNNeGhRD8LytXihWA2e7T FNmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732836309; x=1733441109; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YjF5NHMyK7y7jg65uvCn9MXduypsA+uz1rOx/op7hXs=; b=aJfltAdG4w2TDbt1eH/IGmL7pKUILLDKPtgFEkk6XtnbcWNeYZFjhBeg/X1fbJYpAR Smwm1gRM534G5cUwKBvuOHZAayCLrYCWRooE4CX+LcDVLv0jpf3v8H6nJoGD9RxXtQQS QzVcHgVuzk7m0rhUO1+5js9c2W1qpVSSvsaFGCFEwVXYfCs6zgfxjYJtC2phz+ndPzVD IGFG2cdZSO/TYttLYEpkeZVy1jzWVwiL2/XswodMrrDtTqz0v6NK7kvGS99znL4pB8B2 hUFEjf2wookXHTLz2JCZF3vntQxplTXrdDdxUe246PJ5L14STCgJO2l9+BqWCmq4udQe FZVg== X-Forwarded-Encrypted: i=1; AJvYcCVUm2jzrPgEpqZVnd2/XD+SfWJvyFlNDY1eo9N9lYl6bhwTT6kUwzPcSLZ52nVr297/ClA53cX0efS4vXDH@vger.kernel.org, AJvYcCW1dmmUu1zozZCdOBK/bKEMLXgexGSTvJyacc38qh3KjDibUnbPlYPBu0DvmOPvSfGfqIOCThjOsApO@vger.kernel.org, AJvYcCXkepjS1AjzwdNG43r9vN6Fbf+nWw5ay+zGkTod5IqQw72psab5oV6ecq4AFwwcroqmCN7pOVbZPiUl@vger.kernel.org X-Gm-Message-State: AOJu0YyhxfJt20t8zT8mMhAL/NvNZnFjajWLsU80lrjJe8hYW5K/LUmi +jrYfPymYTsgtbAEDGriH5LGUTdyBUCWFwTR1YPFosFoLgZD3Z8Y X-Gm-Gg: ASbGncuBfQDxXFvbbdt6XrmciFHD+6wixOZzFK+lk+OAdPDwhn5tylV0krTq3JY7M+l GWed0Il3HxWo43ZrwDeVECnymrQKIuETBoiakR0kdSWoFvplQRZ/r9bcg//t+baXTaLpG2/gqaB ocItwWRxuWUQ2/JPo1xcBu7evEc+D+GQdpaG2rQWkeuD+Cjn1jNxOfNShxH03F0StYRfaSs763R 0/318pA4/4PL1h/1nnHerbz4c5+5SG6qZasAfk/XeUwTp8HvVsggauhmyTvrq4= X-Google-Smtp-Source: AGHT+IF7PABYTFt/ac8JsqDV2vx86JPxSSJFTTicJkXfV2C4thQXeUmt7NvdeZKFM+6o1EDES/0xPg== X-Received: by 2002:a05:6000:280c:b0:382:420e:5cc0 with SMTP id ffacd0b85a97d-385c6eba973mr5376179f8f.30.1732836308952; Thu, 28 Nov 2024 15:25:08 -0800 (PST) Received: from vamoirid-laptop.. ([2a04:ee41:82:7577:a8c6:c7bb:87d7:66dd]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-385ccd3690dsm2765594f8f.35.2024.11.28.15.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2024 15:25:07 -0800 (PST) From: Vasileios Amoiridis To: jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andriy.shevchenko@linux.intel.com Cc: ajarizzo@gmail.com, ak@it-klinger.de, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, vassilisamir@gmail.com Subject: [PATCH v1 3/3] iio: pressure: bmp280: Make time vars intuitive and move to fsleep Date: Fri, 29 Nov 2024 00:24:50 +0100 Message-ID: <20241128232450.313862-4-vassilisamir@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241128232450.313862-1-vassilisamir@gmail.com> References: <20241128232450.313862-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add time unit abbreviation in the end of the variables to make the names more intuitive. While at it, move to new fsleep(). Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 39 +++++++++++++++--------------- drivers/iio/pressure/bmp280.h | 4 +-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index e5ec8137961f..b39ef30f8eda 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1002,7 +1002,7 @@ static int bmp280_preinit(struct bmp280_data *data) * after resetting, the device uses the complete power-on sequence so * it needs to wait for the defined start-up time. */ - fsleep(data->start_up_time); + fsleep(data->start_up_time_us); ret = regmap_read(data->regmap, BMP280_REG_STATUS, ®); if (ret) @@ -1161,7 +1161,7 @@ const struct bmp280_chip_info bmp280_chip_info = { .chip_id = bmp280_chip_ids, .num_chip_id = ARRAY_SIZE(bmp280_chip_ids), .regmap_config = &bmp280_regmap_config, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bmp280_channels, .num_channels = ARRAY_SIZE(bmp280_channels), .avail_scan_masks = bmp280_avail_scan_masks, @@ -1347,7 +1347,7 @@ const struct bmp280_chip_info bme280_chip_info = { .chip_id = bme280_chip_ids, .num_chip_id = ARRAY_SIZE(bme280_chip_ids), .regmap_config = &bme280_regmap_config, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bme280_channels, .num_channels = ARRAY_SIZE(bme280_channels), .avail_scan_masks = bme280_avail_scan_masks, @@ -1414,7 +1414,7 @@ static int bmp380_cmd(struct bmp280_data *data, u8 cmd) return ret; } /* Wait for 2ms for command to be processed */ - usleep_range(data->start_up_time, data->start_up_time + 100); + fsleep(data->start_up_time_us); /* Check for command processing error */ ret = regmap_read(data->regmap, BMP380_REG_ERROR, ®); if (ret) { @@ -1806,7 +1806,7 @@ static int bmp380_chip_config(struct bmp280_data *data) * formula in datasheet section 3.9.2 with an offset of ~+15% * as it seen as well in table 3.9.1. */ - msleep(150); + fsleep(150 * USEC_PER_MSEC); /* Check config error flag */ ret = regmap_read(data->regmap, BMP380_REG_ERROR, &tmp); @@ -1957,7 +1957,7 @@ const struct bmp280_chip_info bmp380_chip_info = { .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), .regmap_config = &bmp380_regmap_config, .spi_read_extra_byte = true, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bmp380_channels, .num_channels = ARRAY_SIZE(bmp380_channels), .avail_scan_masks = bmp280_avail_scan_masks, @@ -2006,7 +2006,8 @@ static int bmp580_soft_reset(struct bmp280_data *data) dev_err(data->dev, "failed to send reset command to device\n"); return ret; } - usleep_range(2000, 2500); + /* From datasheet's table 4: electrical characteristics */ + fsleep(2000); /* Dummy read of chip_id */ ret = regmap_read(data->regmap, BMP580_REG_CHIP_ID, ®); @@ -2208,7 +2209,7 @@ static int bmp580_nvmem_read_impl(void *priv, unsigned int offset, void *val, goto exit; } /* Wait standby transition time */ - usleep_range(2500, 3000); + fsleep(2500); while (bytes >= sizeof(*dst)) { addr = bmp580_nvmem_addrs[offset / sizeof(*dst)]; @@ -2274,7 +2275,7 @@ static int bmp580_nvmem_write_impl(void *priv, unsigned int offset, void *val, goto exit; } /* Wait standby transition time */ - usleep_range(2500, 3000); + fsleep(2500); while (bytes >= sizeof(*buf)) { addr = bmp580_nvmem_addrs[offset / sizeof(*buf)]; @@ -2458,7 +2459,7 @@ static int bmp580_chip_config(struct bmp280_data *data) return ret; } /* From datasheet's table 4: electrical characteristics */ - usleep_range(2500, 3000); + fsleep(2500); /* Set default DSP mode settings */ reg_val = FIELD_PREP(BMP580_DSP_COMP_MASK, BMP580_DSP_PRESS_TEMP_COMP_EN) | @@ -2649,7 +2650,7 @@ const struct bmp280_chip_info bmp580_chip_info = { .chip_id = bmp580_chip_ids, .num_chip_id = ARRAY_SIZE(bmp580_chip_ids), .regmap_config = &bmp580_regmap_config, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bmp580_channels, .num_channels = ARRAY_SIZE(bmp580_channels), .avail_scan_masks = bmp280_avail_scan_masks, @@ -2720,7 +2721,7 @@ static int bmp180_wait_for_eoc(struct bmp280_data *data, u8 ctrl_meas) delay_us = conversion_time_max[data->oversampling_press]; - usleep_range(delay_us, delay_us + 1000); + fsleep(delay_us); } ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl); @@ -2988,7 +2989,7 @@ const struct bmp280_chip_info bmp180_chip_info = { .chip_id = bmp180_chip_ids, .num_chip_id = ARRAY_SIZE(bmp180_chip_ids), .regmap_config = &bmp180_regmap_config, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bmp280_channels, .num_channels = ARRAY_SIZE(bmp280_channels), .avail_scan_masks = bmp280_avail_scan_masks, @@ -3066,7 +3067,7 @@ const struct bmp280_chip_info bmp085_chip_info = { .chip_id = bmp180_chip_ids, .num_chip_id = ARRAY_SIZE(bmp180_chip_ids), .regmap_config = &bmp180_regmap_config, - .start_up_time = 2000, + .start_up_time_us = 2000, .channels = bmp280_channels, .num_channels = ARRAY_SIZE(bmp280_channels), .avail_scan_masks = bmp280_avail_scan_masks, @@ -3175,7 +3176,7 @@ int bmp280_common_probe(struct device *dev, data->oversampling_temp = chip_info->oversampling_temp_default; data->iir_filter_coeff = chip_info->iir_filter_coeff_default; data->sampling_freq = chip_info->sampling_freq_default; - data->start_up_time = chip_info->start_up_time; + data->start_up_time_us = chip_info->start_up_time_us; /* Bring up regulators */ regulator_bulk_set_supply_names(data->supplies, @@ -3201,7 +3202,7 @@ int bmp280_common_probe(struct device *dev, return ret; /* Wait to make sure we started up properly */ - usleep_range(data->start_up_time, data->start_up_time + 100); + fsleep(data->start_up_time_us); /* Bring chip out of reset if there is an assigned GPIO line */ gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); @@ -3287,7 +3288,7 @@ int bmp280_common_probe(struct device *dev, * Set autosuspend to two orders of magnitude larger than the * start-up time. */ - pm_runtime_set_autosuspend_delay(dev, data->start_up_time / 10); + pm_runtime_set_autosuspend_delay(dev, data->start_up_time_us / 10); pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); @@ -3306,7 +3307,7 @@ static int bmp280_runtime_suspend(struct device *dev) data->chip_info->set_mode(data, BMP280_SLEEP); - fsleep(data->start_up_time); + fsleep(data->start_up_time_us); return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); } @@ -3320,7 +3321,7 @@ static int bmp280_runtime_resume(struct device *dev) if (ret) return ret; - usleep_range(data->start_up_time, data->start_up_time + 100); + fsleep(data->start_up_time_us); ret = data->chip_info->chip_config(data); if (ret) diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index a3631bc0e188..5b2ee1d0ee46 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -434,7 +434,7 @@ struct bmp280_data { struct bmp380_calib bmp380; } calib; struct regulator_bulk_data supplies[BMP280_NUM_SUPPLIES]; - unsigned int start_up_time; /* in microseconds */ + unsigned int start_up_time_us; /* log of base 2 of oversampling rate */ u8 oversampling_press; @@ -490,7 +490,7 @@ struct bmp280_chip_info { const struct iio_chan_spec *channels; int num_channels; - unsigned int start_up_time; + unsigned int start_up_time_us; const unsigned long *avail_scan_masks; const int *oversampling_temp_avail;