Re: [RFC] possible fix for broken floppy driver since 2.5.13

Pavel Machek (pavel@ucw.cz)
Sun, 26 May 2002 16:19:23 +0200


Hi!

> > I haven't got a clue on how to program Linux' block I/O interfaces.
> > Show me how to do a modern equivalent of getblk(dev,0,1024) + waiting
> > for the operation to complete and I'll update the patch ASAP.
>
> I think something like the following should do it.
> (WARNING: entirely untested)

This looks pretty complicated... Maybe bread() is worth being put back
for 2.5?
Pavel

> static void io_done(struct bio *bio)
> {
> complete((struct completion *)bio->bi_private);
> }
>
> static int doio(struct block_device *bdev, size_t size)
> {
> struct completion comp;
> struct page * page;
> struct bio * bio;
>
> bio = bio_alloc(GFP_KERNEL, 1);
> if (!bio)
> return -ENOMEM;
>
> page = alloc_page(GFP_KERNEL);
> if (!page) {
> bio_put(bio);
> return -ENOMEM;
> }
>
> bio->bi_sector = 0;
> bio->bi_bdev = bdev;
> bio->bi_io_vec[0].bv_page = page;
> bio->bi_io_vec[0].bv_len = size;
> bio->bi_io_vec[0].bv_offset = 0;
>
> bio->bi_vcnt = 1;
> bio->bi_idx = 0;
> bio->bi_size = LOGPSIZE;
>
> bio->bi_end_io = io_done;
> bio->bi_private = &complete;
>
> submit_bio(READ, bio);
> run_task_queue(&tq_disk);
>
> wait_for_completion(&comp);
>
> bio_put(bio);
> __free_page(page);
>
> return 0;
> }
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

-- 
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/