checkpatch.pl: Request a test when a new command is added
[oweals/u-boot.git] / drivers / block / blk-uclass.c
index c23b6682a6cc4857b7a52f5eb0e291e874773a91..b19375cbc8da3466eef5e22a3d27952b2140500d 100644 (file)
@@ -7,9 +7,13 @@
 #include <common.h>
 #include <blk.h>
 #include <dm.h>
+#include <log.h>
+#include <malloc.h>
+#include <part.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
 #include <dm/uclass-internal.h>
+#include <linux/err.h>
 
 static const char *if_typename_str[IF_TYPE_COUNT] = {
        [IF_TYPE_IDE]           = "ide",
@@ -142,9 +146,9 @@ struct blk_desc *blk_get_devnum_by_typename(const char *if_typename, int devnum)
  */
 struct blk_desc *blk_get_by_device(struct udevice *dev)
 {
-       struct udevice *child_dev, *next;
+       struct udevice *child_dev;
 
-       device_foreach_child_safe(child_dev, next, dev) {
+       device_foreach_child(child_dev, dev) {
                if (device_get_uclass_id(child_dev) != UCLASS_BLK)
                        continue;
 
@@ -208,11 +212,7 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart)
        if (ret)
                return ret;
 
-       ret = blk_select_hwpart(dev, hwpart);
-       if (!ret)
-               blkcache_invalidate(if_type, devnum);
-
-       return ret;
+       return blk_select_hwpart(dev, hwpart);
 }
 
 int blk_list_part(enum if_type if_type)
@@ -352,13 +352,7 @@ int blk_select_hwpart(struct udevice *dev, int hwpart)
 
 int blk_dselect_hwpart(struct blk_desc *desc, int hwpart)
 {
-       int ret;
-
-       ret = blk_select_hwpart(desc->bdev, hwpart);
-       if (!ret)
-               blkcache_invalidate(desc->if_type, desc->devnum);
-
-       return ret;
+       return blk_select_hwpart(desc->bdev, hwpart);
 }
 
 int blk_first_device(int if_type, struct udevice **devp)
@@ -590,6 +584,7 @@ int blk_create_device(struct udevice *parent, const char *drv_name,
        desc = dev_get_uclass_platdata(dev);
        desc->if_type = if_type;
        desc->blksz = blksz;
+       desc->log2blksz = LOG2(desc->blksz);
        desc->lba = lba;
        desc->part_type = PART_TYPE_UNKNOWN;
        desc->bdev = dev;