Commit bf3e6b8f authored by Gaosheng Cui's avatar Gaosheng Cui Committed by Miquel Raynal

mtd: ftl: use container_of() rather than cast

The container_of() is much more readable and also safer.
Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220816135910.268016-1-cuigaosheng1@huawei.com
parent 8d704c4e
...@@ -941,7 +941,7 @@ static int ftl_write(partition_t *part, caddr_t buffer, ...@@ -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) 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; u_long sect;
/* Sort of arbitrary: round size down to 4KiB boundary */ /* Sort of arbitrary: round size down to 4KiB boundary */
...@@ -969,7 +969,7 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev, ...@@ -969,7 +969,7 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev,
static int ftl_discardsect(struct mtd_blktrans_dev *dev, static int ftl_discardsect(struct mtd_blktrans_dev *dev,
unsigned long sector, unsigned nr_sects) 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; uint32_t bsize = 1 << part->header.EraseUnitSize;
pr_debug("FTL erase sector %ld for %d sectors\n", pr_debug("FTL erase sector %ld for %d sectors\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment