[U-Boot] [PATCH 14/30] dm: sound: max98095: Drop global i2c-address variable

Simon Glass sjg at chromium.org
Mon Dec 3 11:37:30 UTC 2018


We can put this in the private structure and avoid a global.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/sound/max98095.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/sound/max98095.c b/drivers/sound/max98095.c
index 51556c07f5e..2ec67bf24a8 100644
--- a/drivers/sound/max98095.c
+++ b/drivers/sound/max98095.c
@@ -28,11 +28,11 @@ struct max98095_priv {
 	unsigned int sysclk;
 	unsigned int rate;
 	unsigned int fmt;
+	int i2c_addr;
 };
 
 static struct sound_codec_info g_codec_info;
 struct max98095_priv g_max98095_info;
-unsigned int g_max98095_i2c_dev_addr;
 
 /* Index 0 is reserved. */
 int rate_table[] = {0, 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000,
@@ -52,7 +52,7 @@ static int max98095_i2c_write(struct max98095_priv *priv, unsigned int reg,
 {
 	debug("%s: Write Addr : 0x%02X, Data :  0x%02X\n",
 	      __func__, reg, data);
-	return i2c_write(g_max98095_i2c_dev_addr, reg, 1, &data, 1);
+	return i2c_write(priv->i2c_addr, reg, 1, &data, 1);
 }
 
 /*
@@ -69,7 +69,7 @@ static unsigned int max98095_i2c_read(struct max98095_priv *priv,
 {
 	int ret;
 
-	ret = i2c_read(g_max98095_i2c_dev_addr, reg, 1, data, 1);
+	ret = i2c_read(priv->i2c_addr, reg, 1, data, 1);
 	if (ret != 0) {
 		debug("%s: Error while reading register %#04x\n",
 		      __func__, reg);
@@ -574,7 +574,7 @@ int max98095_init(const void *blob, enum en_max_audio_interface aif_id,
 	i2c_set_bus_num(pcodec_info->i2c_bus);
 
 	/* shift the device address by 1 for 7 bit addressing */
-	g_max98095_i2c_dev_addr = pcodec_info->i2c_dev_addr >> 1;
+	g_max98095_info.i2c_addr = pcodec_info->i2c_dev_addr >> 1;
 	ret = max98095_device_init(&g_max98095_info);
 	if (ret < 0) {
 		debug("%s: max98095 codec chip init failed\n", __func__);
-- 
2.20.0.rc1.387.gf8505762e3-goog



More information about the U-Boot mailing list