Match data improvements for tlv320aic32x4 driver

Merge series from Biju Das <biju.das.jz@bp.renesas.com>:

This patch series aims to add match data improvements for tlv320aic32x4
driver.

This patch series is only compile tested.
This commit is contained in:
Mark Brown 2023-09-11 22:38:52 +01:00
commit 0a69e8a697
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
4 changed files with 11 additions and 34 deletions

View File

@ -16,33 +16,20 @@
#include "tlv320aic32x4.h"
static const struct of_device_id aic32x4_of_id[];
static const struct i2c_device_id aic32x4_i2c_id[];
static int aic32x4_i2c_probe(struct i2c_client *i2c)
{
struct regmap *regmap;
struct regmap_config config;
enum aic32x4_type type;
config = aic32x4_regmap_config;
config.reg_bits = 8;
config.val_bits = 8;
regmap = devm_regmap_init_i2c(i2c, &config);
type = (uintptr_t)i2c_get_match_data(i2c);
if (i2c->dev.of_node) {
const struct of_device_id *oid;
oid = of_match_node(aic32x4_of_id, i2c->dev.of_node);
dev_set_drvdata(&i2c->dev, (void *)oid->data);
} else {
const struct i2c_device_id *id;
id = i2c_match_id(aic32x4_i2c_id, i2c);
dev_set_drvdata(&i2c->dev, (void *)id->driver_data);
}
return aic32x4_probe(&i2c->dev, regmap);
return aic32x4_probe(&i2c->dev, regmap, type);
}
static void aic32x4_i2c_remove(struct i2c_client *i2c)

View File

@ -16,12 +16,11 @@
#include "tlv320aic32x4.h"
static const struct of_device_id aic32x4_of_id[];
static int aic32x4_spi_probe(struct spi_device *spi)
{
struct regmap *regmap;
struct regmap_config config;
enum aic32x4_type type;
config = aic32x4_regmap_config;
config.reg_bits = 7;
@ -30,20 +29,9 @@ static int aic32x4_spi_probe(struct spi_device *spi)
config.read_flag_mask = 0x01;
regmap = devm_regmap_init_spi(spi, &config);
type = (uintptr_t)spi_get_device_match_data(spi);
if (spi->dev.of_node) {
const struct of_device_id *oid;
oid = of_match_node(aic32x4_of_id, spi->dev.of_node);
dev_set_drvdata(&spi->dev, (void *)oid->data);
} else {
const struct spi_device_id *id_entry;
id_entry = spi_get_device_id(spi);
dev_set_drvdata(&spi->dev, (void *)id_entry->driver_data);
}
return aic32x4_probe(&spi->dev, regmap);
return aic32x4_probe(&spi->dev, regmap, type);
}
static void aic32x4_spi_remove(struct spi_device *spi)

View File

@ -1333,7 +1333,8 @@ error_ldo:
return ret;
}
int aic32x4_probe(struct device *dev, struct regmap *regmap)
int aic32x4_probe(struct device *dev, struct regmap *regmap,
enum aic32x4_type type)
{
struct aic32x4_priv *aic32x4;
struct aic32x4_pdata *pdata = dev->platform_data;
@ -1349,7 +1350,7 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap)
return -ENOMEM;
aic32x4->dev = dev;
aic32x4->type = (uintptr_t)dev_get_drvdata(dev);
aic32x4->type = type;
dev_set_drvdata(dev, aic32x4);

View File

@ -17,7 +17,8 @@ enum aic32x4_type {
};
extern const struct regmap_config aic32x4_regmap_config;
int aic32x4_probe(struct device *dev, struct regmap *regmap);
int aic32x4_probe(struct device *dev, struct regmap *regmap,
enum aic32x4_type type);
void aic32x4_remove(struct device *dev);
int aic32x4_register_clocks(struct device *dev, const char *mclk_name);