From: Christoph Hellwig <hch@infradead.org>
To: Lauri Kasanen <cand@gmx.com>
Cc: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de,
axboe@kernel.dk, linux-block@vger.kernel.org,
Keith Busch <kbusch@kernel.org>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH v10] block: Add n64 cart driver
Date: Fri, 22 Jan 2021 19:38:24 +0000 [thread overview]
Message-ID: <20210122193824.GA271343@infradead.org> (raw)
In-Reply-To: <20210122213346.774020bb9393ebded17e7412@gmx.com>
> +static int n64cart_do_bvec(struct device *dev, struct bio_vec *bv,
> + unsigned int len, unsigned int off,
> + u32 pos)
I think this should either return bool or a blk_status_t instead
of the int with 1/0 values.
> + if (bio_end_sector(bio) > get_capacity(bio->bi_disk))
> + goto io_error;
This check is already performed by the block layer. I have a series
pending that removes it from the few drivers that duplicate it.
> +
> + bio_for_each_segment(bvec, bio, iter) {
> + unsigned int len = bvec.bv_len;
> + int err;
> +
> + /* Alignment check */
> + WARN_ON_ONCE((bvec.bv_offset & (MIN_ALIGNMENT - 1)) ||
> + (len & (MIN_ALIGNMENT - 1)));
> +
> + err = n64cart_do_bvec(dev, &bvec, len,
> + bvec.bv_offset, pos);
> + if (err)
> + goto io_error;
> + pos += len;
Nit: I'd just pass the bvec to n64cart_do_bvec, calculate pos there
locally each time, and also move the WARN_ON_ONCE into the helper.
No real need for the len local variable either.
next prev parent reply other threads:[~2021-01-22 23:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-22 19:33 [PATCH v10] block: Add n64 cart driver Lauri Kasanen
2021-01-22 19:38 ` Christoph Hellwig [this message]
2021-01-23 7:47 ` Lauri Kasanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210122193824.GA271343@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=cand@gmx.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox