}
 #endif
 
-/*
- * zram_bio_discard - handler on discard request
- * @index: physical block index in PAGE_SIZE units
- * @offset: byte offset within physical block
- */
-static void zram_bio_discard(struct zram *zram, u32 index,
-                            int offset, struct bio *bio)
+static void zram_bio_discard(struct zram *zram, struct bio *bio)
 {
        size_t n = bio->bi_iter.bi_size;
+       u32 index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
+       u32 offset = (bio->bi_iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
+                       SECTOR_SHIFT;
 
        /*
         * zram manages data in physical block size units. Because logical block
                index++;
                n -= PAGE_SIZE;
        }
+
+       bio_endio(bio);
 }
 
 /*
        switch (bio_op(bio)) {
        case REQ_OP_DISCARD:
        case REQ_OP_WRITE_ZEROES:
-               zram_bio_discard(zram, index, offset, bio);
-               bio_endio(bio);
+               zram_bio_discard(zram, bio);
                return;
        default:
                break;