Commit 33cf727b1634dbd9cd68a6ebc444a88f053822d7

Authored by Simon Glass
1 parent 8b726dc945

dm: sandbox: Drop the pre-DM host implementation

Driver model is used for host device block devices now, so we don't need the
old code. Remove it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>

Showing 1 changed file with 0 additions and 90 deletions Side-by-side Diff

drivers/block/sandbox.c
... ... @@ -17,19 +17,6 @@
17 17  
18 18 DECLARE_GLOBAL_DATA_PTR;
19 19  
20   -#ifndef CONFIG_BLK
21   -static struct host_block_dev host_devices[CONFIG_HOST_MAX_DEVICES];
22   -
23   -static struct host_block_dev *find_host_device(int dev)
24   -{
25   - if (dev >= 0 && dev < CONFIG_HOST_MAX_DEVICES)
26   - return &host_devices[dev];
27   -
28   - return NULL;
29   -}
30   -#endif
31   -
32   -#ifdef CONFIG_BLK
33 20 static unsigned long host_block_read(struct udevice *dev,
34 21 unsigned long start, lbaint_t blkcnt,
35 22 void *buffer)
... ... @@ -37,18 +24,6 @@
37 24 struct host_block_dev *host_dev = dev_get_priv(dev);
38 25 struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
39 26  
40   -#else
41   -static unsigned long host_block_read(struct blk_desc *block_dev,
42   - unsigned long start, lbaint_t blkcnt,
43   - void *buffer)
44   -{
45   - int dev = block_dev->devnum;
46   - struct host_block_dev *host_dev = find_host_device(dev);
47   -
48   - if (!host_dev)
49   - return -1;
50   -#endif
51   -
52 27 if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
53 28 -1) {
54 29 printf("ERROR: Invalid block %lx\n", start);
55 30  
... ... @@ -60,21 +35,12 @@
60 35 return -1;
61 36 }
62 37  
63   -#ifdef CONFIG_BLK
64 38 static unsigned long host_block_write(struct udevice *dev,
65 39 unsigned long start, lbaint_t blkcnt,
66 40 const void *buffer)
67 41 {
68 42 struct host_block_dev *host_dev = dev_get_priv(dev);
69 43 struct blk_desc *block_dev = dev_get_uclass_platdata(dev);
70   -#else
71   -static unsigned long host_block_write(struct blk_desc *block_dev,
72   - unsigned long start, lbaint_t blkcnt,
73   - const void *buffer)
74   -{
75   - int dev = block_dev->devnum;
76   - struct host_block_dev *host_dev = find_host_device(dev);
77   -#endif
78 44  
79 45 if (os_lseek(host_dev->fd, start * block_dev->blksz, OS_SEEK_SET) ==
80 46 -1) {
... ... @@ -87,7 +53,6 @@
87 53 return -1;
88 54 }
89 55  
90   -#ifdef CONFIG_BLK
91 56 int host_dev_bind(int devnum, char *filename)
92 57 {
93 58 struct host_block_dev *host_dev;
94 59  
95 60  
... ... @@ -150,51 +115,9 @@
150 115 free(str);
151 116 return ret;
152 117 }
153   -#else
154   -int host_dev_bind(int dev, char *filename)
155   -{
156   - struct host_block_dev *host_dev = find_host_device(dev);
157 118  
158   - if (!host_dev)
159   - return -1;
160   - if (host_dev->blk_dev.priv) {
161   - os_close(host_dev->fd);
162   - host_dev->blk_dev.priv = NULL;
163   - }
164   - if (host_dev->filename)
165   - free(host_dev->filename);
166   - if (filename && *filename) {
167   - host_dev->filename = strdup(filename);
168   - } else {
169   - host_dev->filename = NULL;
170   - return 0;
171   - }
172   -
173   - host_dev->fd = os_open(host_dev->filename, OS_O_RDWR);
174   - if (host_dev->fd == -1) {
175   - printf("Failed to access host backing file '%s'\n",
176   - host_dev->filename);
177   - return 1;
178   - }
179   -
180   - struct blk_desc *blk_dev = &host_dev->blk_dev;
181   - blk_dev->if_type = IF_TYPE_HOST;
182   - blk_dev->priv = host_dev;
183   - blk_dev->blksz = 512;
184   - blk_dev->lba = os_lseek(host_dev->fd, 0, OS_SEEK_END) / blk_dev->blksz;
185   - blk_dev->block_read = host_block_read;
186   - blk_dev->block_write = host_block_write;
187   - blk_dev->devnum = dev;
188   - blk_dev->part_type = PART_TYPE_UNKNOWN;
189   - part_init(blk_dev);
190   -
191   - return 0;
192   -}
193   -#endif
194   -
195 119 int host_get_dev_err(int devnum, struct blk_desc **blk_devp)
196 120 {
197   -#ifdef CONFIG_BLK
198 121 struct udevice *dev;
199 122 int ret;
200 123  
201 124  
... ... @@ -202,18 +125,7 @@
202 125 if (ret)
203 126 return ret;
204 127 *blk_devp = dev_get_uclass_platdata(dev);
205   -#else
206   - struct host_block_dev *host_dev = find_host_device(devnum);
207 128  
208   - if (!host_dev)
209   - return -ENODEV;
210   -
211   - if (!host_dev->blk_dev.priv)
212   - return -ENOENT;
213   -
214   - *blk_devp = &host_dev->blk_dev;
215   -#endif
216   -
217 129 return 0;
218 130 }
219 131  
... ... @@ -227,7 +139,6 @@
227 139 return blk_dev;
228 140 }
229 141  
230   -#ifdef CONFIG_BLK
231 142 static const struct blk_ops sandbox_host_blk_ops = {
232 143 .read = host_block_read,
233 144 .write = host_block_write,
... ... @@ -239,5 +150,4 @@
239 150 .ops = &sandbox_host_blk_ops,
240 151 .priv_auto_alloc_size = sizeof(struct host_block_dev),
241 152 };
242   -#endif