diff options
-rw-r--r-- | arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | 6 | ||||
-rw-r--r-- | drivers/mmc/host/mmc_spi.c | 8 | ||||
-rw-r--r-- | drivers/of/base.c | 64 |
3 files changed, 23 insertions, 55 deletions
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c index 59b0ed1a56b1..70798ac911ef 100644 --- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c +++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c | |||
@@ -160,10 +160,16 @@ static const struct i2c_device_id mcu_ids[] = { | |||
160 | }; | 160 | }; |
161 | MODULE_DEVICE_TABLE(i2c, mcu_ids); | 161 | MODULE_DEVICE_TABLE(i2c, mcu_ids); |
162 | 162 | ||
163 | static struct of_device_id mcu_of_match_table[] __devinitdata = { | ||
164 | { .compatible = "fsl,mcu-mpc8349emitx", }, | ||
165 | { }, | ||
166 | }; | ||
167 | |||
163 | static struct i2c_driver mcu_driver = { | 168 | static struct i2c_driver mcu_driver = { |
164 | .driver = { | 169 | .driver = { |
165 | .name = "mcu-mpc8349emitx", | 170 | .name = "mcu-mpc8349emitx", |
166 | .owner = THIS_MODULE, | 171 | .owner = THIS_MODULE, |
172 | .of_match_table = mcu_of_match_table, | ||
167 | }, | 173 | }, |
168 | .probe = mcu_probe, | 174 | .probe = mcu_probe, |
169 | .remove = __devexit_p(mcu_remove), | 175 | .remove = __devexit_p(mcu_remove), |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index ad847a24a675..7b0f3ef50f96 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1533,12 +1533,20 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) | |||
1533 | return 0; | 1533 | return 0; |
1534 | } | 1534 | } |
1535 | 1535 | ||
1536 | #if defined(CONFIG_OF) | ||
1537 | static struct of_device_id mmc_spi_of_match_table[] __devinitdata = { | ||
1538 | { .compatible = "mmc-spi-slot", }, | ||
1539 | }; | ||
1540 | #endif | ||
1536 | 1541 | ||
1537 | static struct spi_driver mmc_spi_driver = { | 1542 | static struct spi_driver mmc_spi_driver = { |
1538 | .driver = { | 1543 | .driver = { |
1539 | .name = "mmc_spi", | 1544 | .name = "mmc_spi", |
1540 | .bus = &spi_bus_type, | 1545 | .bus = &spi_bus_type, |
1541 | .owner = THIS_MODULE, | 1546 | .owner = THIS_MODULE, |
1547 | #if defined(CONFIG_OF) | ||
1548 | .of_match_table = mmc_spi_of_match_table, | ||
1549 | #endif | ||
1542 | }, | 1550 | }, |
1543 | .probe = mmc_spi_probe, | 1551 | .probe = mmc_spi_probe, |
1544 | .remove = __devexit_p(mmc_spi_remove), | 1552 | .remove = __devexit_p(mmc_spi_remove), |
diff --git a/drivers/of/base.c b/drivers/of/base.c index b5ad9740d8b2..e3f7af882e45 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -545,74 +545,28 @@ struct device_node *of_find_matching_node(struct device_node *from, | |||
545 | EXPORT_SYMBOL(of_find_matching_node); | 545 | EXPORT_SYMBOL(of_find_matching_node); |
546 | 546 | ||
547 | /** | 547 | /** |
548 | * of_modalias_table: Table of explicit compatible ==> modalias mappings | ||
549 | * | ||
550 | * This table allows particulare compatible property values to be mapped | ||
551 | * to modalias strings. This is useful for busses which do not directly | ||
552 | * understand the OF device tree but are populated based on data contained | ||
553 | * within the device tree. SPI and I2C are the two current users of this | ||
554 | * table. | ||
555 | * | ||
556 | * In most cases, devices do not need to be listed in this table because | ||
557 | * the modalias value can be derived directly from the compatible table. | ||
558 | * However, if for any reason a value cannot be derived, then this table | ||
559 | * provides a method to override the implicit derivation. | ||
560 | * | ||
561 | * At the moment, a single table is used for all bus types because it is | ||
562 | * assumed that the data size is small and that the compatible values | ||
563 | * should already be distinct enough to differentiate between SPI, I2C | ||
564 | * and other devices. | ||
565 | */ | ||
566 | struct of_modalias_table { | ||
567 | char *of_device; | ||
568 | char *modalias; | ||
569 | }; | ||
570 | static struct of_modalias_table of_modalias_table[] = { | ||
571 | { "fsl,mcu-mpc8349emitx", "mcu-mpc8349emitx" }, | ||
572 | { "mmc-spi-slot", "mmc_spi" }, | ||
573 | }; | ||
574 | |||
575 | /** | ||
576 | * of_modalias_node - Lookup appropriate modalias for a device node | 548 | * of_modalias_node - Lookup appropriate modalias for a device node |
577 | * @node: pointer to a device tree node | 549 | * @node: pointer to a device tree node |
578 | * @modalias: Pointer to buffer that modalias value will be copied into | 550 | * @modalias: Pointer to buffer that modalias value will be copied into |
579 | * @len: Length of modalias value | 551 | * @len: Length of modalias value |
580 | * | 552 | * |
581 | * Based on the value of the compatible property, this routine will determine | 553 | * Based on the value of the compatible property, this routine will attempt |
582 | * an appropriate modalias value for a particular device tree node. Two | 554 | * to choose an appropriate modalias value for a particular device tree node. |
583 | * separate methods are attempted to derive a modalias value. | 555 | * It does this by stripping the manufacturer prefix (as delimited by a ',') |
556 | * from the first entry in the compatible list property. | ||
584 | * | 557 | * |
585 | * First method is to lookup the compatible value in of_modalias_table. | 558 | * This routine returns 0 on success, <0 on failure. |
586 | * Second is to strip off the manufacturer prefix from the first | ||
587 | * compatible entry and use the remainder as modalias | ||
588 | * | ||
589 | * This routine returns 0 on success | ||
590 | */ | 559 | */ |
591 | int of_modalias_node(struct device_node *node, char *modalias, int len) | 560 | int of_modalias_node(struct device_node *node, char *modalias, int len) |
592 | { | 561 | { |
593 | int i, cplen; | 562 | const char *compatible, *p; |
594 | const char *compatible; | 563 | int cplen; |
595 | const char *p; | ||
596 | |||
597 | /* 1. search for exception list entry */ | ||
598 | for (i = 0; i < ARRAY_SIZE(of_modalias_table); i++) { | ||
599 | compatible = of_modalias_table[i].of_device; | ||
600 | if (!of_device_is_compatible(node, compatible)) | ||
601 | continue; | ||
602 | strlcpy(modalias, of_modalias_table[i].modalias, len); | ||
603 | return 0; | ||
604 | } | ||
605 | 564 | ||
606 | compatible = of_get_property(node, "compatible", &cplen); | 565 | compatible = of_get_property(node, "compatible", &cplen); |
607 | if (!compatible) | 566 | if (!compatible || strlen(compatible) > cplen) |
608 | return -ENODEV; | 567 | return -ENODEV; |
609 | |||
610 | /* 2. take first compatible entry and strip manufacturer */ | ||
611 | p = strchr(compatible, ','); | 568 | p = strchr(compatible, ','); |
612 | if (!p) | 569 | strlcpy(modalias, p ? p + 1 : compatible, len); |
613 | return -ENODEV; | ||
614 | p++; | ||
615 | strlcpy(modalias, p, len); | ||
616 | return 0; | 570 | return 0; |
617 | } | 571 | } |
618 | EXPORT_SYMBOL_GPL(of_modalias_node); | 572 | EXPORT_SYMBOL_GPL(of_modalias_node); |