diff mbox series

[1/7] floppy: use block_size

Message ID 20200626080158.1998621-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/7] floppy: use block_size | expand

Commit Message

Christoph Hellwig June 26, 2020, 8:01 a.m. UTC
Use the block_size helper instead of open coding it.  Also remove the
check for a 0 block size, as that can't happen.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/floppy.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Johannes Thumshirn June 26, 2020, 3:48 p.m. UTC | #1
On 26/06/2020 10:03, Christoph Hellwig wrote:
> -	size = bdev->bd_block_size;
> -	if (!size)
> -		size = 1024;
> -

Why is this correct? block_size() only returns 'bdev->bd_block_size' but I cannot 
see where it's made sure bd_block_size is not 0. At least no calls to set_blocksize()
Johannes Thumshirn June 26, 2020, 3:50 p.m. UTC | #2
On 26/06/2020 17:49, Johannes Thumshirn wrote:
> On 26/06/2020 10:03, Christoph Hellwig wrote:
>> -	size = bdev->bd_block_size;
>> -	if (!size)
>> -		size = 1024;
>> -
> 
> Why is this correct? block_size() only returns 'bdev->bd_block_size' but I cannot 
> see where it's made sure bd_block_size is not 0. At least no calls to set_blocksize()
> 
> 

OK answered the question myself. 

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 3e9db22db2a8f5..09079aee8dc430 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4205,7 +4205,6 @@  static int __floppy_read_block_0(struct block_device *bdev, int drive)
 	struct bio_vec bio_vec;
 	struct page *page;
 	struct rb0_cbdata cbdata;
-	size_t size;
 
 	page = alloc_page(GFP_NOIO);
 	if (!page) {
@@ -4213,15 +4212,11 @@  static int __floppy_read_block_0(struct block_device *bdev, int drive)
 		return -ENOMEM;
 	}
 
-	size = bdev->bd_block_size;
-	if (!size)
-		size = 1024;
-
 	cbdata.drive = drive;
 
 	bio_init(&bio, &bio_vec, 1);
 	bio_set_dev(&bio, bdev);
-	bio_add_page(&bio, page, size, 0);
+	bio_add_page(&bio, page, block_size(bdev), 0);
 
 	bio.bi_iter.bi_sector = 0;
 	bio.bi_flags |= (1 << BIO_QUIET);