Skip to content

Commit a87d422

Browse files
Lucas Tanurebroonie
authored andcommitted
ASoC: cs35l41: Convert tables to shared source code
To support CS35L41 in HDA systems the HDA driver for CS35L41 would have to duplicate some functions that already exist on ASoC driver So instead of duplicate the code, use the new lib source as a shared resource for both ASoC and HDA Also, change the way CONFIG_SND_SOC_CS35L41 is selected, as reported by Intel Kernel test robot, it is possible to build SND_SOC_CS35L41_SPI/I2C without the main driver, which would lead to build failures. Signed-off-by: Lucas Tanure <[email protected]> Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent cc5c978 commit a87d422

File tree

7 files changed

+755
-743
lines changed

7 files changed

+755
-743
lines changed

include/sound/cs35l41.h

Lines changed: 733 additions & 0 deletions
Large diffs are not rendered by default.

sound/soc/codecs/Kconfig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,21 +624,24 @@ config SND_SOC_CS35L36
624624
tristate "Cirrus Logic CS35L36 CODEC"
625625
depends on I2C
626626

627+
config SND_SOC_CS35L41_LIB
628+
tristate
629+
627630
config SND_SOC_CS35L41
628631
tristate
629-
default y if SND_SOC_CS35L41_SPI=y
630-
default y if SND_SOC_CS35L41_I2C=y
631-
default m if SND_SOC_CS35L41_SPI=m
632-
default m if SND_SOC_CS35L41_I2C=m
633632

634633
config SND_SOC_CS35L41_SPI
635634
tristate "Cirrus Logic CS35L41 CODEC (SPI)"
636635
depends on SPI_MASTER
636+
select SND_SOC_CS35L41_LIB
637+
select SND_SOC_CS35L41
637638
select REGMAP_SPI
638639

639640
config SND_SOC_CS35L41_I2C
640641
tristate "Cirrus Logic CS35L41 CODEC (I2C)"
641642
depends on I2C
643+
select SND_SOC_CS35L41_LIB
644+
select SND_SOC_CS35L41
642645
select REGMAP_I2C
643646

644647
config SND_SOC_CS42L42

sound/soc/codecs/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ snd-soc-cs35l33-objs := cs35l33.o
5555
snd-soc-cs35l34-objs := cs35l34.o
5656
snd-soc-cs35l35-objs := cs35l35.o
5757
snd-soc-cs35l36-objs := cs35l36.o
58-
snd-soc-cs35l41-objs := cs35l41.o cs35l41-tables.o
58+
snd-soc-cs35l41-lib-objs := cs35l41-lib.o
59+
snd-soc-cs35l41-objs := cs35l41.o
5960
snd-soc-cs35l41-spi-objs := cs35l41-spi.o
6061
snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o
6162
snd-soc-cs42l42-objs := cs42l42.o
@@ -396,6 +397,7 @@ obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o
396397
obj-$(CONFIG_SND_SOC_CS35L35) += snd-soc-cs35l35.o
397398
obj-$(CONFIG_SND_SOC_CS35L36) += snd-soc-cs35l36.o
398399
obj-$(CONFIG_SND_SOC_CS35L41) += snd-soc-cs35l41.o
400+
obj-$(CONFIG_SND_SOC_CS35L41_LIB) += snd-soc-cs35l41-lib.o
399401
obj-$(CONFIG_SND_SOC_CS35L41_SPI) += snd-soc-cs35l41-spi.o
400402
obj-$(CONFIG_SND_SOC_CS35L41_I2C) += snd-soc-cs35l41-i2c.o
401403
obj-$(CONFIG_SND_SOC_CS42L42) += snd-soc-cs42l42.o

sound/soc/codecs/cs35l41-i2c.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/platform_device.h>
1818
#include <linux/slab.h>
1919

20-
#include <sound/cs35l41.h>
2120
#include "cs35l41.h"
2221

2322
static const struct i2c_device_id cs35l41_id_i2c[] = {

sound/soc/codecs/cs35l41-tables.c renamed to sound/soc/codecs/cs35l41-lib.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
// SPDX-License-Identifier: GPL-2.0
22
//
3-
// cs35l41-tables.c -- CS35L41 ALSA SoC audio driver
3+
// cs35l41-lib.c -- CS35L41 Common functions for HDA and ASoC Audio drivers
44
//
55
// Copyright 2017-2021 Cirrus Logic, Inc.
66
//
77
// Author: David Rhodes <[email protected]>
8+
// Author: Lucas Tanure <[email protected]>
89

9-
#include "cs35l41.h"
10+
#include <linux/module.h>
11+
#include <linux/regmap.h>
12+
13+
#include <sound/cs35l41.h>
1014

1115
static const struct reg_default cs35l41_reg[] = {
1216
{ CS35L41_PWR_CTRL1, 0x00000000 },
@@ -688,6 +692,7 @@ const struct cs35l41_otp_map_element_t cs35l41_otp_map_map[CS35L41_NUM_OTP_MAPS]
688692
.word_offset = 2,
689693
},
690694
};
695+
EXPORT_SYMBOL_GPL(cs35l41_otp_map_map);
691696

692697
struct regmap_config cs35l41_regmap_i2c = {
693698
.reg_bits = 32,
@@ -721,3 +726,8 @@ struct regmap_config cs35l41_regmap_spi = {
721726
.cache_type = REGCACHE_RBTREE,
722727
};
723728
EXPORT_SYMBOL_GPL(cs35l41_regmap_spi);
729+
730+
MODULE_DESCRIPTION("CS35L41 library");
731+
MODULE_AUTHOR("David Rhodes, Cirrus Logic Inc, <[email protected]>");
732+
MODULE_AUTHOR("Lucas Tanure, Cirrus Logic Inc, <[email protected]>");
733+
MODULE_LICENSE("GPL");

sound/soc/codecs/cs35l41-spi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <linux/platform_device.h>
1616
#include <linux/spi/spi.h>
1717

18-
#include <sound/cs35l41.h>
1918
#include "cs35l41.h"
2019

2120
static const struct spi_device_id cs35l41_id_spi[] = {

0 commit comments

Comments
 (0)