[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220630112651.2739425-1-julian.haller@bbl.ms.philips.com>
Date: Thu, 30 Jun 2022 13:26:48 +0200
From: Julian Haller <julian.haller@....ms.philips.com>
To: linux-kernel@...r.kernel.org
Cc: julian.haller@...lips.com, zbr@...emap.net
Subject: [PATCH 1/4] w1: ds1wm: Fix check for resource size
From: Julian Haller <julian.haller@...lips.com>
Commit 242b476f821b ("w1: ds1wm: fix register offset (bus shift)
calculation") introduced a check for the minimum resource size to span
at least 8 registers. However, the DS1WM only has 6 registers:
DS1WM_CMD 0x00 /* R/W 4 bits command */
DS1WM_DATA 0x01 /* R/W 8 bits, transmit/receive buffer */
DS1WM_INT 0x02 /* R/W interrupt status */
DS1WM_INT_EN 0x03 /* R/W interrupt enable */
DS1WM_CLKDIV 0x04 /* R/W 5 bits of divisor and pre-scale */
DS1WM_CNTRL 0x05 /* R/W master control register */
This causes the probe to fail incorrectly when the actual resource size of
6 is specified instead of 8.
Fixes: 242b476f821b ("w1: ds1wm: fix register offset (bus shift) calculation")
Signed-off-by: Julian Haller <julian.haller@...lips.com>
---
drivers/w1/masters/ds1wm.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index f661695fb589..0ecb14772f30 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -544,13 +544,12 @@ static int ds1wm_probe(struct platform_device *pdev)
return -EINVAL;
}
- ds1wm_data->bus_shift = plat->bus_shift;
- /* make sure resource has space for 8 registers */
- if ((8 << ds1wm_data->bus_shift) > resource_size(res)) {
+ /* make sure resource has space for 6 registers */
+ if ((6 << ds1wm_data->bus_shift) > resource_size(res)) {
dev_err(&ds1wm_data->pdev->dev,
"memory resource size %d to small, should be %d\n",
(int)resource_size(res),
- 8 << ds1wm_data->bus_shift);
+ 6 << ds1wm_data->bus_shift);
return -EINVAL;
}
--
2.25.1
Powered by blists - more mailing lists