[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231120144641.1660574-7-andriy.shevchenko@linux.intel.com>
Date: Mon, 20 Nov 2023 16:41:48 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Mario Limonciello <mario.limonciello@....com>,
Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Wolfram Sang <wsa@...nel.org>, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>,
Jan Dabros <jsd@...ihalf.com>,
Andi Shyti <andi.shyti@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>
Subject: [PATCH v4 06/24] i2c: designware: Save pointer to semaphore callbacks instead of index
Instead of saving index and do an additional level of referencing,
save just a pointer to the semaphore callbacks directly. It makes
code cleaner.
Acked-by: Jarkko Nikula <jarkko.nikula@...ux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/i2c/busses/i2c-designware-core.h | 4 +++-
drivers/i2c/busses/i2c-designware-platdrv.c | 12 ++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index a7f6f3eafad7..f8dd87cb0ae9 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -187,6 +187,8 @@ struct clk;
struct device;
struct reset_control;
+struct i2c_dw_semaphore_callbacks;
+
/**
* struct dw_i2c_dev - private i2c-designware data
* @dev: driver model device node
@@ -291,7 +293,7 @@ struct dw_i2c_dev {
u16 hs_lcnt;
int (*acquire_lock)(void);
void (*release_lock)(void);
- int semaphore_idx;
+ const struct i2c_dw_semaphore_callbacks *semaphore_cb;
bool shared_with_punit;
void (*disable)(struct dw_i2c_dev *dev);
int (*init)(struct dw_i2c_dev *dev);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index cb954f11540e..4b5e58e1ce5b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -247,21 +247,18 @@ static void i2c_dw_remove_lock_support(void *data)
{
struct dw_i2c_dev *dev = data;
- if (dev->semaphore_idx < 0)
+ if (!dev->semaphore_cb)
return;
- if (i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove)
- i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove(dev);
+ if (dev->semaphore_cb->remove)
+ dev->semaphore_cb->remove(dev);
}
static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
{
const struct i2c_dw_semaphore_callbacks *ptr;
- int i = 0;
int ret;
- dev->semaphore_idx = -1;
-
for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) {
ret = ptr->probe(dev);
if (ret) {
@@ -273,11 +270,10 @@ static int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev)
if (ret != -ENODEV)
return ret;
- i++;
continue;
}
- dev->semaphore_idx = i;
+ dev->semaphore_cb = ptr;
break;
}
--
2.43.0.rc1.1.gbec44491f096
Powered by blists - more mailing lists