Commit 6132725e authored by Timur Tabi's avatar Timur Tabi Committed by Mark Brown

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: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent a806aa92
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_i2c.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/fsl_guts.h> #include <asm/fsl_guts.h>
...@@ -249,8 +250,9 @@ static int get_parent_cell_index(struct device_node *np) ...@@ -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) static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
{ {
const u32 *iprop; const u32 *iprop;
int bus, addr; int addr;
char temp[DAI_NAME_SIZE]; char temp[DAI_NAME_SIZE];
struct i2c_client *i2c;
of_modalias_node(np, temp, DAI_NAME_SIZE); 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) ...@@ -260,11 +262,12 @@ static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
addr = be32_to_cpup(iprop); addr = be32_to_cpup(iprop);
bus = get_parent_cell_index(np); /* We need the adapter number */
if (bus < 0) i2c = of_find_i2c_device_by_node(np);
return bus; 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; return 0;
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_i2c.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/fsl_guts.h> #include <asm/fsl_guts.h>
...@@ -252,8 +253,9 @@ static int get_parent_cell_index(struct device_node *np) ...@@ -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) static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
{ {
const u32 *iprop; const u32 *iprop;
int bus, addr; int addr;
char temp[DAI_NAME_SIZE]; char temp[DAI_NAME_SIZE];
struct i2c_client *i2c;
of_modalias_node(np, temp, DAI_NAME_SIZE); 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) ...@@ -263,11 +265,12 @@ static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
addr = be32_to_cpup(iprop); addr = be32_to_cpup(iprop);
bus = get_parent_cell_index(np); /* We need the adapter number */
if (bus < 0) i2c = of_find_i2c_device_by_node(np);
return bus; 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment