Commit 6dd9faf8f97e1aad9961a480775612f6cbde27de

Authored by Simon Glass
1 parent 1fde473da7

dm: part: Drop the block_drvr table

This is not needed since we can use the functions provided by the legacy
block device support.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 30 additions and 64 deletions Side-by-side Diff

... ... @@ -21,34 +21,6 @@
21 21 #define PRINTF(fmt,args...)
22 22 #endif
23 23  
24   -const struct block_drvr block_drvr[] = {
25   -#if defined(CONFIG_CMD_IDE)
26   - { .name = "ide", },
27   -#endif
28   -#if defined(CONFIG_CMD_SATA)
29   - {.name = "sata", },
30   -#endif
31   -#if defined(CONFIG_SCSI)
32   - { .name = "scsi", },
33   -#endif
34   -#if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
35   - { .name = "usb", },
36   -#endif
37   -#if defined(CONFIG_MMC)
38   - {
39   - .name = "mmc",
40   - .select_hwpart = mmc_select_hwpart,
41   - },
42   -#endif
43   -#if defined(CONFIG_SYSTEMACE)
44   - { .name = "ace", },
45   -#endif
46   -#if defined(CONFIG_SANDBOX)
47   - { .name = "host", },
48   -#endif
49   - { },
50   -};
51   -
52 24 DECLARE_GLOBAL_DATA_PTR;
53 25  
54 26 #ifdef HAVE_BLOCK_DEVICE
55 27  
56 28  
57 29  
... ... @@ -70,34 +42,23 @@
70 42  
71 43 static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
72 44 {
73   - const struct block_drvr *drvr = block_drvr;
74   - char *name;
  45 + struct blk_desc *dev_desc;
  46 + int ret;
75 47  
76   - if (!ifname)
  48 + dev_desc = blk_get_devnum_by_typename(ifname, dev);
  49 + if (!dev_desc) {
  50 + debug("%s: No device for iface '%s', dev %d\n", __func__,
  51 + ifname, dev);
77 52 return NULL;
78   -
79   - name = drvr->name;
80   -#ifdef CONFIG_NEEDS_MANUAL_RELOC
81   - name += gd->reloc_off;
82   -#endif
83   - while (drvr->name) {
84   - name = drvr->name;
85   -#ifdef CONFIG_NEEDS_MANUAL_RELOC
86   - name += gd->reloc_off;
87   -#endif
88   - if (strncmp(ifname, name, strlen(name)) == 0) {
89   - struct blk_desc *dev_desc;
90   -
91   - dev_desc = blk_get_devnum_by_typename(name, dev);
92   - if (!dev_desc)
93   - return NULL;
94   - if (blk_dselect_hwpart(dev_desc, hwpart))
95   - return NULL;
96   - return dev_desc;
97   - }
98   - drvr++;
99 53 }
100   - return NULL;
  54 + ret = blk_dselect_hwpart(dev_desc, hwpart);
  55 + if (ret) {
  56 + debug("%s: Failed to select h/w partition: err-%d\n", __func__,
  57 + ret);
  58 + return NULL;
  59 + }
  60 +
  61 + return dev_desc;
101 62 }
102 63  
103 64 struct blk_desc *blk_get_dev(const char *ifname, int dev)
lib/efi_loader/efi_disk.c
... ... @@ -7,6 +7,7 @@
7 7 */
8 8  
9 9 #include <common.h>
  10 +#include <blk.h>
10 11 #include <efi_loader.h>
11 12 #include <inttypes.h>
12 13 #include <part.h>
... ... @@ -142,7 +143,7 @@
142 143 };
143 144  
144 145 static void efi_disk_add_dev(char *name,
145   - const struct block_drvr *cur_drvr,
  146 + const struct blk_driver *cur_drvr,
146 147 const struct blk_desc *desc,
147 148 int dev_index,
148 149 lbaint_t offset)
... ... @@ -160,7 +161,7 @@
160 161 diskobj->parent.protocols[1].open = efi_disk_open_dp;
161 162 diskobj->parent.handle = diskobj;
162 163 diskobj->ops = block_io_disk_template;
163   - diskobj->ifname = cur_drvr->name;
  164 + diskobj->ifname = cur_drvr->if_typename;
164 165 diskobj->dev_index = dev_index;
165 166 diskobj->offset = offset;
166 167  
... ... @@ -189,7 +190,7 @@
189 190 }
190 191  
191 192 static int efi_disk_create_eltorito(struct blk_desc *desc,
192   - const struct block_drvr *cur_drvr,
  193 + const struct blk_driver *cur_drvr,
193 194 int diskid)
194 195 {
195 196 int disks = 0;
... ... @@ -202,8 +203,8 @@
202 203 return 0;
203 204  
204 205 while (!part_get_info(desc, part, &info)) {
205   - snprintf(devname, sizeof(devname), "%s%d:%d", cur_drvr->name,
206   - diskid, part);
  206 + snprintf(devname, sizeof(devname), "%s%d:%d",
  207 + cur_drvr->if_typename, diskid, part);
207 208 efi_disk_add_dev(devname, cur_drvr, desc, diskid, info.start);
208 209 part++;
209 210 disks++;
210 211  
211 212  
212 213  
... ... @@ -222,25 +223,29 @@
222 223 */
223 224 int efi_disk_register(void)
224 225 {
225   - const struct block_drvr *cur_drvr;
226   - int i;
  226 + const struct blk_driver *cur_drvr;
  227 + int i, if_type;
227 228 int disks = 0;
228 229  
229 230 /* Search for all available disk devices */
230   - for (cur_drvr = block_drvr; cur_drvr->name; cur_drvr++) {
231   - printf("Scanning disks on %s...\n", cur_drvr->name);
  231 + for (if_type = 0; if_type < IF_TYPE_COUNT; if_type++) {
  232 + cur_drvr = blk_driver_lookup_type(if_type);
  233 + if (!cur_drvr)
  234 + continue;
  235 +
  236 + printf("Scanning disks on %s...\n", cur_drvr->if_typename);
232 237 for (i = 0; i < 4; i++) {
233 238 struct blk_desc *desc;
234 239 char devname[32] = { 0 }; /* dp->str is u16[32] long */
235 240  
236   - desc = blk_get_dev(cur_drvr->name, i);
  241 + desc = blk_get_devnum_by_type(if_type, i);
237 242 if (!desc)
238 243 continue;
239 244 if (desc->type == DEV_TYPE_UNKNOWN)
240 245 continue;
241 246  
242 247 snprintf(devname, sizeof(devname), "%s%d",
243   - cur_drvr->name, i);
  248 + cur_drvr->if_typename, i);
244 249 efi_disk_add_dev(devname, cur_drvr, desc, i, 0);
245 250 disks++;
246 251