Commit 9f30bfb78dfd09b47c4a1dd9b59282812319792c

Authored by Eric Lee
1 parent c461db2ad6

mmc: block: Support the fixed index for mmcblk with aliases nodes

Showing 2 changed files with 18 additions and 1 deletions Side-by-side Diff

arch/arm/boot/dts/am33xx.dtsi
... ... @@ -36,6 +36,8 @@
36 36 phy1 = &usb1_phy;
37 37 ethernet0 = &cpsw_emac0;
38 38 ethernet1 = &cpsw_emac1;
  39 + mmc1 = &mmc1; /* Fixed to mmcblk1 for &mmc1 */
  40 + mmc0 = &mmc2; /* Fixed to mmcblk0 for &mmc2 */
39 41 };
40 42  
41 43 cpus {
drivers/mmc/card/block.c
... ... @@ -35,6 +35,7 @@
35 35 #include <linux/capability.h>
36 36 #include <linux/compat.h>
37 37 #include <linux/pm_runtime.h>
  38 +#include <linux/of.h>
38 39  
39 40 #include <linux/mmc/ioctl.h>
40 41 #include <linux/mmc/card.h>
... ... @@ -2026,6 +2027,7 @@
2026 2027 {
2027 2028 struct mmc_blk_data *md;
2028 2029 int devidx, ret;
  2030 + int idx = 0;
2029 2031  
2030 2032 devidx = find_first_zero_bit(dev_use, max_devices);
2031 2033 if (devidx >= max_devices)
... ... @@ -2045,7 +2047,20 @@
2045 2047 * index anymore so we keep track of a name index.
2046 2048 */
2047 2049 if (!subname) {
2048   - md->name_idx = find_first_zero_bit(name_use, max_devices);
  2050 + if (card->dev.parent->parent->of_node)
  2051 + idx = of_alias_get_id(card->dev.parent->parent->of_node,
  2052 + "mmc");
  2053 +
  2054 + if (idx < 0)
  2055 + md->name_idx = find_first_zero_bit(name_use,
  2056 + max_devices);
  2057 + else {
  2058 + if (test_bit(idx, name_use))
  2059 + md->name_idx = find_first_zero_bit(name_use,
  2060 + max_devices);
  2061 + else
  2062 + md->name_idx = (unsigned int)idx;
  2063 + }
2049 2064 __set_bit(md->name_idx, name_use);
2050 2065 } else
2051 2066 md->name_idx = ((struct mmc_blk_data *)