]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
blk: Use a macro for the typical block size
authorBin Meng <bmeng@tinylab.org>
Tue, 26 Sep 2023 08:43:31 +0000 (16:43 +0800)
committerTom Rini <trini@konsulko.com>
Tue, 10 Oct 2023 20:19:29 +0000 (16:19 -0400)
Avoid using the magic number 512 directly.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/usb_storage.c
drivers/ata/dwc_ahsata.c
drivers/ata/fsl_sata.c
drivers/ata/sata_mv.c
drivers/ata/sata_sil.c
drivers/block/blkmap.c
drivers/block/host_dev.c
drivers/mmc/mmc-uclass.c
drivers/nvme/nvme.c
include/blk.h

index 85774220ef2aa4699df7d9ba236b2c04630e7ec6..35c656db0dcae6718468319c8ff3459c7bdbd3b3 100644 (file)
@@ -219,8 +219,8 @@ static int usb_stor_probe_device(struct usb_device *udev)
 
                snprintf(str, sizeof(str), "lun%d", lun);
                ret = blk_create_devicef(udev->dev, "usb_storage_blk", str,
-                                        UCLASS_USB, usb_max_devs, 512, 0,
-                                        &dev);
+                                        UCLASS_USB, usb_max_devs,
+                                        DEFAULT_BLKSZ, 0, &dev);
                if (ret) {
                        debug("Cannot bind driver\n");
                        return ret;
index 6a4d861bf1e825b6a4363f8e4cb7afabb47e21b7..b4d4e39c9b3bf00d1cc03fe7f8b0e0ce91d7d7e8 100644 (file)
@@ -880,7 +880,8 @@ int dwc_ahsata_scan(struct udevice *dev)
        device_find_first_child(dev, &blk);
        if (!blk) {
                ret = blk_create_devicef(dev, "dwc_ahsata_blk", "blk",
-                                        UCLASS_AHCI, -1, 512, 0, &blk);
+                                        UCLASS_AHCI, -1, DEFAULT_BLKSZ,
+                                        0, &blk);
                if (ret) {
                        debug("Can't create device\n");
                        return ret;
index 972101b29ce586a0db7f271cf4c49da04f0e8224..969bc191f8e8dd992a9c126e38bdf8ba073ed2ff 100644 (file)
@@ -888,7 +888,8 @@ static int fsl_ata_probe(struct udevice *dev)
        for (i = 0; i < nr_ports; i++) {
                snprintf(sata_name, sizeof(sata_name), "fsl_sata%d", i);
                ret = blk_create_devicef(dev, "sata_fsl_blk", sata_name,
-                                        UCLASS_AHCI, -1, 512, 0, &blk);
+                                        UCLASS_AHCI, -1, DEFAULT_BLKSZ,
+                                        0, &blk);
                if (ret) {
                        debug("Can't create device\n");
                        return ret;
index 18c7a66db1bff992b5a678c9b7150ed3490051fe..1abea0b30936269aa59b6f6bb86e9e963d62b6b4 100644 (file)
@@ -1076,7 +1076,8 @@ static int sata_mv_probe(struct udevice *dev)
 
        for (i = 0; i < nr_ports; i++) {
                ret = blk_create_devicef(dev, "sata_mv_blk", "blk",
-                                        UCLASS_AHCI, -1, 512, 0, &blk);
+                                        UCLASS_AHCI, -1, DEFAULT_BLKSZ,
+                                        0, &blk);
                if (ret) {
                        debug("Can't create device\n");
                        continue;
index b5e150d568ba3f7a1368dfff5bbd28e8c0bfe394..43a91a79120a399f06ee87e698b497c1cb664c14 100644 (file)
@@ -730,7 +730,8 @@ static int sil_pci_probe(struct udevice *dev)
        for (i = sata_info.portbase; i < sata_info.maxport; i++) {
                snprintf(sata_name, sizeof(sata_name), "sil_sata%d", i);
                ret = blk_create_devicef(dev, "sata_sil_blk", sata_name,
-                                        UCLASS_AHCI, -1, 512, 0, &blk);
+                                        UCLASS_AHCI, -1, DEFAULT_BLKSZ,
+                                        0, &blk);
                if (ret) {
                        debug("Can't create device\n");
                        return ret;
index 2bb0acc20f2cb20250ddf7bb67059a83778d848a..409aa46de24023b6a36c49074570f574aa696206 100644 (file)
@@ -390,7 +390,7 @@ int blkmap_dev_bind(struct udevice *dev)
        int err;
 
        err = blk_create_devicef(dev, "blkmap_blk", "blk", UCLASS_BLKMAP,
-                                dev_seq(dev), 512, 0, &bm->blk);
+                                dev_seq(dev), DEFAULT_BLKSZ, 0, &bm->blk);
        if (err)
                return log_msg_ret("blk", err);
 
index 64422417b7496a2ba66d4b142fb9b6f19513c21f..31c7814054e45169fcbb9ce55fbbfadf0fc0c7d1 100644 (file)
@@ -105,7 +105,7 @@ static int host_sb_bind(struct udevice *dev)
        int ret;
 
        ret = blk_create_devicef(dev, "sandbox_host_blk", "blk", UCLASS_HOST,
-                                dev_seq(dev), 512, 0, &blk);
+                                dev_seq(dev), DEFAULT_BLKSZ, 0, &blk);
        if (ret)
                return log_msg_ret("blk", ret);
 
index 0e157672eae0b0707ea333145761435b4916ef74..328456831dd28f24473f8530b8406f1bef269a5b 100644 (file)
@@ -412,7 +412,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
        debug("%s: alias devnum=%d\n", __func__, dev_seq(dev));
 
        ret = blk_create_devicef(dev, "mmc_blk", "blk", UCLASS_MMC,
-                                dev_seq(dev), 512, 0, &bdev);
+                                dev_seq(dev), DEFAULT_BLKSZ, 0, &bdev);
        if (ret) {
                debug("Cannot create block device\n");
                return ret;
index 20dc910d8a33abe435a543d5e51467aaad6f59ad..c39cd41aa38e3bdc9c9047407cd6a965c12cbff2 100644 (file)
@@ -906,7 +906,7 @@ int nvme_init(struct udevice *udev)
 
                /* The real blksz and size will be set by nvme_blk_probe() */
                ret = blk_create_devicef(udev, "nvme-blk", name, UCLASS_NVME,
-                                        -1, 512, 0, &ns_udev);
+                                        -1, DEFAULT_BLKSZ, 0, &ns_udev);
                if (ret)
                        goto free_id;
 
index 95e86e2d5d16cba0be33fc7557b7d99b8de999e6..bbff057aed4eca7ebb3f951965cd868d07237679 100644 (file)
@@ -21,6 +21,8 @@ typedef ulong lbaint_t;
 #define LBAF "%" LBAFlength "x"
 #define LBAFU "%" LBAFlength "u"
 
+#define DEFAULT_BLKSZ          512
+
 struct udevice;
 
 static inline bool blk_enabled(void)