Skip to content

Commit 8ad7f3b

Browse files
Pei Xiaobroonie
authored andcommitted
regmap: i3c: Add non-devm regmap_init_i3c() helper
Add __regmap_init_i3c() and the corresponding regmap_init_i3c() macro to allow creating a regmap for I3C devices without using the device-managed version. This mirrors the pattern already established for other buses such as I2C, SPI and so on, giving drivers more flexibility when the regmap lifetime is not directly tied to the device. Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Link: https://patch.msgid.link/a81256a8866b163979a20406abf01df7d7440104.1775788105.git.xiaopei01@kylinos.cn Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 7d69621 commit 8ad7f3b

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

drivers/base/regmap/regmap-i3c.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ static const struct regmap_bus regmap_i3c = {
4646
.read = regmap_i3c_read,
4747
};
4848

49+
struct regmap *__regmap_init_i3c(struct i3c_device *i3c,
50+
const struct regmap_config *config,
51+
struct lock_class_key *lock_key,
52+
const char *lock_name)
53+
{
54+
return __regmap_init(&i3c->dev, &regmap_i3c, &i3c->dev, config,
55+
lock_key, lock_name);
56+
}
57+
EXPORT_SYMBOL_GPL(__regmap_init_i3c);
58+
4959
struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c,
5060
const struct regmap_config *config,
5161
struct lock_class_key *lock_key,

include/linux/regmap.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ struct regmap *__regmap_init_sdw_mbq(struct device *dev, struct sdw_slave *sdw,
693693
const struct regmap_sdw_mbq_cfg *mbq_config,
694694
struct lock_class_key *lock_key,
695695
const char *lock_name);
696+
struct regmap *__regmap_init_i3c(struct i3c_device *i3c,
697+
const struct regmap_config *config,
698+
struct lock_class_key *lock_key,
699+
const char *lock_name);
696700
struct regmap *__regmap_init_spi_avmm(struct spi_device *spi,
697701
const struct regmap_config *config,
698702
struct lock_class_key *lock_key,
@@ -999,6 +1003,19 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg);
9991003
__regmap_lockdep_wrapper(__regmap_init_sdw_mbq, #config, \
10001004
dev, sdw, config, mbq_config)
10011005

1006+
/**
1007+
* regmap_init_i3c() - Initialise register map
1008+
*
1009+
* @i3c: Device that will be interacted with
1010+
* @config: Configuration for register map
1011+
*
1012+
* The return value will be an ERR_PTR() on error or a valid pointer to
1013+
* a struct regmap.
1014+
*/
1015+
#define regmap_init_i3c(i3c, config) \
1016+
__regmap_lockdep_wrapper(__regmap_init_i3c, #config, \
1017+
i3c, config)
1018+
10021019
/**
10031020
* regmap_init_spi_avmm() - Initialize register map for Intel SPI Slave
10041021
* to AVMM Bus Bridge

0 commit comments

Comments
 (0)