From: Timur Tabi Date: Fri, 2 Dec 2011 01:52:47 +0000 (-0600) Subject: ASoC: fsl/powerpc: don't rely on the cell-index property X-Git-Tag: v3.3-rc1~14^2~229 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6132725eac521b89dee3d58df3c6d04a1e50844c;p=platform%2Fkernel%2Flinux-stable.git ASoC: fsl/powerpc: don't rely on the cell-index property Instead of using the 'cell-index' property in the I2C adapter node to determine the adapter number, just query the i2c_adapter object directly. Previously, the I2C nodes always appeared in cell-index order, so the dynamic numbering coincided with the cell-index property. With commit ab827d97 ("powerpc/85xx: Rework P1022DS device tree"), the I2C nodes are unintentionally reversed in the device tree, and so the machine driver guesses the wrong I2C adapter number. Signed-off-by: Timur Tabi Signed-off-by: Mark Brown --- diff --git a/sound/soc/fsl/mpc8610_hpcd.c b/sound/soc/fsl/mpc8610_hpcd.c index ae49f1c..0ea4a5a 100644 --- a/sound/soc/fsl/mpc8610_hpcd.c +++ b/sound/soc/fsl/mpc8610_hpcd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -249,8 +250,9 @@ static int get_parent_cell_index(struct device_node *np) static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) { const u32 *iprop; - int bus, addr; + int addr; char temp[DAI_NAME_SIZE]; + struct i2c_client *i2c; of_modalias_node(np, temp, DAI_NAME_SIZE); @@ -260,11 +262,12 @@ static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) addr = be32_to_cpup(iprop); - bus = get_parent_cell_index(np); - if (bus < 0) - return bus; + /* We need the adapter number */ + i2c = of_find_i2c_device_by_node(np); + if (!i2c) + return -ENODEV; - snprintf(buf, len, "%s-codec.%u-%04x", temp, bus, addr); + snprintf(buf, len, "%s-codec.%u-%04x", temp, i2c->adapter->nr, addr); return 0; } diff --git a/sound/soc/fsl/p1022_ds.c b/sound/soc/fsl/p1022_ds.c index 3091626..a5d4e80 100644 --- a/sound/soc/fsl/p1022_ds.c +++ b/sound/soc/fsl/p1022_ds.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -252,8 +253,9 @@ static int get_parent_cell_index(struct device_node *np) static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) { const u32 *iprop; - int bus, addr; + int addr; char temp[DAI_NAME_SIZE]; + struct i2c_client *i2c; of_modalias_node(np, temp, DAI_NAME_SIZE); @@ -263,11 +265,12 @@ static int codec_node_dev_name(struct device_node *np, char *buf, size_t len) addr = be32_to_cpup(iprop); - bus = get_parent_cell_index(np); - if (bus < 0) - return bus; + /* We need the adapter number */ + i2c = of_find_i2c_device_by_node(np); + if (!i2c) + return -ENODEV; - snprintf(buf, len, "%s.%u-%04x", temp, bus, addr); + snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr); return 0; }