Skip to content

Commit

Permalink
media: max9271: Fix GPIO enable/disable
Browse files Browse the repository at this point in the history
[ Upstream commit 909a0a1 ]

Fix GPIO enable/disable operations which wrongly read the 0x0f register
to obtain the current mask of the enabled lines instead of using
the correct 0x0e register.

Also fix access to bit 0 of the register which is marked as reserved.

Fixes: 34009bf ("media: i2c: Add RDACM20 driver")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Jacopo Mondi authored and gregkh committed Dec 30, 2020
1 parent af85e24 commit 978649a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/media/i2c/max9271.c
Expand Up @@ -223,12 +223,12 @@ int max9271_enable_gpios(struct max9271_device *dev, u8 gpio_mask)
{
int ret;

ret = max9271_read(dev, 0x0f);
ret = max9271_read(dev, 0x0e);
if (ret < 0)
return 0;

/* BIT(0) reserved: GPO is always enabled. */
ret |= gpio_mask | BIT(0);
ret |= (gpio_mask & ~BIT(0));
ret = max9271_write(dev, 0x0e, ret);
if (ret < 0) {
dev_err(&dev->client->dev, "Failed to enable gpio (%d)\n", ret);
Expand All @@ -245,12 +245,12 @@ int max9271_disable_gpios(struct max9271_device *dev, u8 gpio_mask)
{
int ret;

ret = max9271_read(dev, 0x0f);
ret = max9271_read(dev, 0x0e);
if (ret < 0)
return 0;

/* BIT(0) reserved: GPO cannot be disabled */
ret &= (~gpio_mask | BIT(0));
ret &= ~(gpio_mask | BIT(0));
ret = max9271_write(dev, 0x0e, ret);
if (ret < 0) {
dev_err(&dev->client->dev, "Failed to disable gpio (%d)\n", ret);
Expand Down

0 comments on commit 978649a

Please sign in to comment.