Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 204911
b: refs/heads/master
c: 2ffe8c5
h: refs/heads/master
i:
  204909: d3d4db5
  204907: 6c24405
  204903: ad593b2
  204895: d0578a5
v: v3
  • Loading branch information
Grant Likely committed Jul 5, 2010
1 parent de04ed0 commit 2f9da15
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 959e85f7751c33d1a2dabc5cc3fe2ed0db7052e5
refs/heads/master: 2ffe8c5f323c3b9749bf7bc2375d909d20bdbb15
6 changes: 6 additions & 0 deletions trunk/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,16 @@ static const struct i2c_device_id mcu_ids[] = {
};
MODULE_DEVICE_TABLE(i2c, mcu_ids);

static struct of_device_id mcu_of_match_table[] __devinitdata = {
{ .compatible = "fsl,mcu-mpc8349emitx", },
{ },
};

static struct i2c_driver mcu_driver = {
.driver = {
.name = "mcu-mpc8349emitx",
.owner = THIS_MODULE,
.of_match_table = mcu_of_match_table,
},
.probe = mcu_probe,
.remove = __devexit_p(mcu_remove),
Expand Down
8 changes: 8 additions & 0 deletions trunk/drivers/mmc/host/mmc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,12 +1533,20 @@ static int __devexit mmc_spi_remove(struct spi_device *spi)
return 0;
}

#if defined(CONFIG_OF)
static struct of_device_id mmc_spi_of_match_table[] __devinitdata = {
{ .compatible = "mmc-spi-slot", },
};
#endif

static struct spi_driver mmc_spi_driver = {
.driver = {
.name = "mmc_spi",
.bus = &spi_bus_type,
.owner = THIS_MODULE,
#if defined(CONFIG_OF)
.of_match_table = mmc_spi_of_match_table,
#endif
},
.probe = mmc_spi_probe,
.remove = __devexit_p(mmc_spi_remove),
Expand Down
64 changes: 9 additions & 55 deletions trunk/drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,75 +544,29 @@ struct device_node *of_find_matching_node(struct device_node *from,
}
EXPORT_SYMBOL(of_find_matching_node);

/**
* of_modalias_table: Table of explicit compatible ==> modalias mappings
*
* This table allows particulare compatible property values to be mapped
* to modalias strings. This is useful for busses which do not directly
* understand the OF device tree but are populated based on data contained
* within the device tree. SPI and I2C are the two current users of this
* table.
*
* In most cases, devices do not need to be listed in this table because
* the modalias value can be derived directly from the compatible table.
* However, if for any reason a value cannot be derived, then this table
* provides a method to override the implicit derivation.
*
* At the moment, a single table is used for all bus types because it is
* assumed that the data size is small and that the compatible values
* should already be distinct enough to differentiate between SPI, I2C
* and other devices.
*/
struct of_modalias_table {
char *of_device;
char *modalias;
};
static struct of_modalias_table of_modalias_table[] = {
{ "fsl,mcu-mpc8349emitx", "mcu-mpc8349emitx" },
{ "mmc-spi-slot", "mmc_spi" },
};

/**
* of_modalias_node - Lookup appropriate modalias for a device node
* @node: pointer to a device tree node
* @modalias: Pointer to buffer that modalias value will be copied into
* @len: Length of modalias value
*
* Based on the value of the compatible property, this routine will determine
* an appropriate modalias value for a particular device tree node. Two
* separate methods are attempted to derive a modalias value.
* Based on the value of the compatible property, this routine will attempt
* to choose an appropriate modalias value for a particular device tree node.
* It does this by stripping the manufacturer prefix (as delimited by a ',')
* from the first entry in the compatible list property.
*
* First method is to lookup the compatible value in of_modalias_table.
* Second is to strip off the manufacturer prefix from the first
* compatible entry and use the remainder as modalias
*
* This routine returns 0 on success
* This routine returns 0 on success, <0 on failure.
*/
int of_modalias_node(struct device_node *node, char *modalias, int len)
{
int i, cplen;
const char *compatible;
const char *p;

/* 1. search for exception list entry */
for (i = 0; i < ARRAY_SIZE(of_modalias_table); i++) {
compatible = of_modalias_table[i].of_device;
if (!of_device_is_compatible(node, compatible))
continue;
strlcpy(modalias, of_modalias_table[i].modalias, len);
return 0;
}
const char *compatible, *p;
int cplen;

compatible = of_get_property(node, "compatible", &cplen);
if (!compatible)
if (!compatible || strlen(compatible) > cplen)
return -ENODEV;

/* 2. take first compatible entry and strip manufacturer */
p = strchr(compatible, ',');
if (!p)
return -ENODEV;
p++;
strlcpy(modalias, p, len);
strlcpy(modalias, p ? p + 1 : compatible, len);
return 0;
}
EXPORT_SYMBOL_GPL(of_modalias_node);
Expand Down

0 comments on commit 2f9da15

Please sign in to comment.