]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: Simplify read_part_sector()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 18 May 2022 03:36:55 +0000 (23:36 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 2 Aug 2022 16:34:03 +0000 (12:34 -0400)
That rather complicated expression is just trying to find the offset
of this sector within a page, and there are easier ways to express that.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
block/partitions/core.c

index a9a51bac42df8b91cd133e8a8003144f4a5e1346..52871fa224eeb273d648211eef53378082169859 100644 (file)
@@ -718,8 +718,7 @@ void *read_part_sector(struct parsed_partitions *state, sector_t n, Sector *p)
                goto out;
 
        p->v = page;
-       return (unsigned char *)page_address(page) +
-                       ((n & ((1 << (PAGE_SHIFT - 9)) - 1)) << SECTOR_SHIFT);
+       return page_address(page) + offset_in_page(n * SECTOR_SIZE);
 out:
        p->v = NULL;
        return NULL;