diff options
author | Gaosheng Cui <cuigaosheng1@huawei.com> | 2022-08-16 21:59:10 +0800 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2022-09-19 18:14:53 +0200 |
commit | bf3e6b8f837afdf01d31cdc86028660f3f342bbe (patch) | |
tree | 75ea9f4da9d0d96ba18a2e9075f3e357ed0c1299 /drivers/mtd/ftl.c | |
parent | 8d704c4e1ead92b6185d6aedeb08ac6a85c4a42a (diff) | |
download | linux-stable-bf3e6b8f837afdf01d31cdc86028660f3f342bbe.tar.gz linux-stable-bf3e6b8f837afdf01d31cdc86028660f3f342bbe.tar.bz2 linux-stable-bf3e6b8f837afdf01d31cdc86028660f3f342bbe.zip |
mtd: ftl: use container_of() rather than cast
The container_of() is much more readable and also safer.
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220816135910.268016-1-cuigaosheng1@huawei.com
Diffstat (limited to 'drivers/mtd/ftl.c')
-rw-r--r-- | drivers/mtd/ftl.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index f655d2905270..8c22064ead38 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -941,7 +941,7 @@ static int ftl_write(partition_t *part, caddr_t buffer, static int ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo) { - partition_t *part = (void *)dev; + partition_t *part = container_of(dev, struct partition_t, mbd); u_long sect; /* Sort of arbitrary: round size down to 4KiB boundary */ @@ -969,7 +969,7 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev, static int ftl_discardsect(struct mtd_blktrans_dev *dev, unsigned long sector, unsigned nr_sects) { - partition_t *part = (void *)dev; + partition_t *part = container_of(dev, struct partition_t, mbd); uint32_t bsize = 1 << part->header.EraseUnitSize; pr_debug("FTL erase sector %ld for %d sectors\n", |