Skip to content

Commit b4635b9

Browse files
jwrdegoedebroonie
authored andcommitted
ASoC: rt5645: Add rt5645_get_pdata() helper
Add a rt5645_get_pdata() helper function which retreives the platform-data and overrides it with the quirks module parameter if that is set. This is a preparation patch for adding the rt5645_components() function. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://msgid.link/r/20231126214024.300505-5-hdegoede@redhat.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f72a9c2 commit b4635b9

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

sound/soc/codecs/rt5645.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,10 +3877,33 @@ static void rt5645_parse_dt(struct device *dev, struct rt5645_platform_data *pda
38773877
device_property_read_u32(dev, "realtek,jd-mode", &pdata->jd_mode);
38783878
}
38793879

3880-
static int rt5645_i2c_probe(struct i2c_client *i2c)
3880+
static void rt5645_get_pdata(struct device *codec_dev, struct rt5645_platform_data *pdata)
38813881
{
3882-
struct rt5645_platform_data *pdata = NULL;
38833882
const struct dmi_system_id *dmi_data;
3883+
3884+
dmi_data = dmi_first_match(dmi_platform_data);
3885+
if (dmi_data) {
3886+
dev_info(codec_dev, "Detected %s platform\n", dmi_data->ident);
3887+
*pdata = *((struct rt5645_platform_data *)dmi_data->driver_data);
3888+
} else if (rt5645_check_dp(codec_dev)) {
3889+
rt5645_parse_dt(codec_dev, pdata);
3890+
} else {
3891+
*pdata = jd_mode3_platform_data;
3892+
}
3893+
3894+
if (quirk != -1) {
3895+
pdata->in2_diff = QUIRK_IN2_DIFF(quirk);
3896+
pdata->level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
3897+
pdata->inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
3898+
pdata->inv_hp_pol = QUIRK_INV_HP_POL(quirk);
3899+
pdata->jd_mode = QUIRK_JD_MODE(quirk);
3900+
pdata->dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
3901+
pdata->dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
3902+
}
3903+
}
3904+
3905+
static int rt5645_i2c_probe(struct i2c_client *i2c)
3906+
{
38843907
struct rt5645_priv *rt5645;
38853908
int ret, i;
38863909
unsigned int val;
@@ -3893,29 +3916,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c)
38933916

38943917
rt5645->i2c = i2c;
38953918
i2c_set_clientdata(i2c, rt5645);
3896-
3897-
dmi_data = dmi_first_match(dmi_platform_data);
3898-
if (dmi_data) {
3899-
dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
3900-
pdata = dmi_data->driver_data;
3901-
}
3902-
3903-
if (pdata)
3904-
rt5645->pdata = *pdata;
3905-
else if (rt5645_check_dp(&i2c->dev))
3906-
rt5645_parse_dt(&i2c->dev, &rt5645->pdata);
3907-
else
3908-
rt5645->pdata = jd_mode3_platform_data;
3909-
3910-
if (quirk != -1) {
3911-
rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
3912-
rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
3913-
rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
3914-
rt5645->pdata.inv_hp_pol = QUIRK_INV_HP_POL(quirk);
3915-
rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk);
3916-
rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
3917-
rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
3918-
}
3919+
rt5645_get_pdata(&i2c->dev, &rt5645->pdata);
39193920

39203921
if (has_acpi_companion(&i2c->dev)) {
39213922
if (cht_rt5645_gpios) {

0 commit comments

Comments
 (0)