ppc / layerscape: Clean up CONFIG_SYS_CCSR_DO_NOT_RELOCATE usage
[platform/kernel/u-boot.git] / common / usb_storage.c
index aba9ccb..eaa3137 100644 (file)
 
 #include <common.h>
 #include <blk.h>
+#include <bootdev.h>
 #include <command.h>
 #include <dm.h>
 #include <errno.h>
+#include <log.h>
 #include <mapmem.h>
 #include <memalign.h>
 #include <asm/byteorder.h>
@@ -44,6 +46,7 @@
 #include <asm/processor.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <linux/delay.h>
 
 #include <part.h>
 #include <usb.h>
@@ -92,7 +95,7 @@ struct us_data {
        int             action;                 /* what to do */
        int             ip_wanted;              /* needed */
        int             *irq_handle;            /* for USB int requests */
-       unsigned int    irqpipe;                /* pipe for release_irq */
+       unsigned int    irqpipe;                /* pipe for release_irq */
        unsigned char   irqmaxp;                /* max packed for irq Pipe */
        unsigned char   irqinterval;            /* Intervall for IRQ Pipe */
        struct scsi_cmd *srb;                   /* current srb */
@@ -144,7 +147,7 @@ int usb_stor_info(void)
        for (blk_first_device(IF_TYPE_USB, &dev);
             dev;
             blk_next_device(&dev)) {
-               struct blk_desc *desc = dev_get_uclass_platdata(dev);
+               struct blk_desc *desc = dev_get_uclass_plat(dev);
 
                printf("  Device %d: ", desc->devnum);
                dev_print(desc);
@@ -201,11 +204,11 @@ static int usb_stor_probe_device(struct usb_device *udev)
        debug("\n\nProbing for storage\n");
 #if CONFIG_IS_ENABLED(BLK)
        /*
-        * We store the us_data in the mass storage device's platdata. It
+        * We store the us_data in the mass storage device's plat. It
         * is shared by all LUNs (block devices) attached to this mass storage
         * device.
         */
-       data = dev_get_platdata(udev->dev);
+       data = dev_get_plat(udev->dev);
        if (!usb_storage_probe(udev, 0, data))
                return 0;
        max_lun = usb_get_max_lun(data);
@@ -223,7 +226,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
                        return ret;
                }
 
-               blkdev = dev_get_uclass_platdata(dev);
+               blkdev = dev_get_uclass_plat(dev);
                blkdev->target = 0xff;
                blkdev->lun = lun;
 
@@ -237,6 +240,20 @@ static int usb_stor_probe_device(struct usb_device *udev)
                        if (ret)
                                return ret;
                }
+
+               ret = blk_probe_or_unbind(dev);
+               if (ret)
+                       return ret;
+
+               ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
+               if (ret) {
+                       int ret2;
+
+                       ret2 = device_unbind(dev);
+                       if (ret2)
+                               return log_msg_ret("bootdev", ret2);
+                       return log_msg_ret("bootdev", ret);
+               }
        }
 #else
        /* We don't have space to even probe if we hit the maximum */
@@ -429,8 +446,8 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
                                        return 0;
                                }
                                /* if our try counter reaches 0, bail out */
-                                       debug(" %ld, data %d\n",
-                                             us->pusb_dev->status, partial);
+                               debug(" %ld, data %d\n",
+                                     us->pusb_dev->status, partial);
                                if (!maxtry--)
                                                return result;
                        }
@@ -1145,7 +1162,7 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
                return 0;
        /* Setup  device */
 #if CONFIG_IS_ENABLED(BLK)
-       block_dev = dev_get_uclass_platdata(dev);
+       block_dev = dev_get_uclass_plat(dev);
        udev = dev_get_parent_priv(dev_get_parent(dev));
        debug("\nusb_read: udev %d\n", block_dev->devnum);
 #else
@@ -1229,7 +1246,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
 
        /* Setup  device */
 #if CONFIG_IS_ENABLED(BLK)
-       block_dev = dev_get_uclass_platdata(dev);
+       block_dev = dev_get_uclass_plat(dev);
        udev = dev_get_parent_priv(dev_get_parent(dev));
        debug("\nusb_read: udev %d\n", block_dev->devnum);
 #else
@@ -1527,7 +1544,7 @@ U_BOOT_DRIVER(usb_mass_storage) = {
        .of_match = usb_mass_storage_ids,
        .probe = usb_mass_storage_probe,
 #if CONFIG_IS_ENABLED(BLK)
-       .platdata_auto_alloc_size       = sizeof(struct us_data),
+       .plat_auto      = sizeof(struct us_data),
 #endif
 };