Skip to content

Commit 3fbe3fe

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: cy8c95x0: Avoid accessing reserved registers
The checks for vrtual registers in the cy8c95x0_readable_register() and cy8c95x0_writeable_register() are not aligned and broken. Fix that by explicitly avoiding reserved registers to be accessed. Fixes: 71e4001 ("pinctrl: pinctrl-cy8c95x0: Fix regcache") Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 6f36f10 commit 3fbe3fe

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/pinctrl/pinctrl-cy8c95x0.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,14 @@ static int cypress_get_pin_mask(struct cy8c95x0_pinctrl *chip, unsigned int pin)
328328
static bool cy8c95x0_readable_register(struct device *dev, unsigned int reg)
329329
{
330330
/*
331-
* Only 12 registers are present per port (see Table 6 in the
332-
* datasheet).
331+
* Only 12 registers are present per port (see Table 6 in the datasheet).
333332
*/
334-
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) < 12)
335-
return true;
333+
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) >= 12)
334+
return false;
336335

337336
switch (reg) {
338337
case 0x24 ... 0x27:
338+
case 0x31 ... 0x3f:
339339
return false;
340340
default:
341341
return true;
@@ -344,15 +344,19 @@ static bool cy8c95x0_readable_register(struct device *dev, unsigned int reg)
344344

345345
static bool cy8c95x0_writeable_register(struct device *dev, unsigned int reg)
346346
{
347-
if (reg >= CY8C95X0_VIRTUAL)
348-
return true;
347+
/*
348+
* Only 12 registers are present per port (see Table 6 in the datasheet).
349+
*/
350+
if (reg >= CY8C95X0_VIRTUAL && (reg % MUXED_STRIDE) >= 12)
351+
return false;
349352

350353
switch (reg) {
351354
case CY8C95X0_INPUT_(0) ... CY8C95X0_INPUT_(7):
352355
return false;
353356
case CY8C95X0_DEVID:
354357
return false;
355358
case 0x24 ... 0x27:
359+
case 0x31 ... 0x3f:
356360
return false;
357361
default:
358362
return true;

0 commit comments

Comments
 (0)