From: Joe Perches <joe@perches.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH V2 1/8] pktcdvd: Convert ZONE macro to static function get_zone()
Date: Fri, 31 May 2013 21:11:22 -0700 [thread overview]
Message-ID: <cffa2f13c7621e38d2ecfbd5d8ea02920e1d4afb.1370048648.git.joe@perches.com> (raw)
In-Reply-To: <cover.1370048648.git.joe@perches.com>
Macros should be converted to functions where feasible to
verify arguments and the like.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/block/pktcdvd.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 09142c4..9dcb601 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -83,9 +83,6 @@
#define MAX_SPEED 0xffff
-#define ZONE(sector, pd) (((sector) + (pd)->offset) & \
- ~(sector_t)((pd)->settings.size - 1))
-
static DEFINE_MUTEX(pktcdvd_mutex);
static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
static struct proc_dir_entry *pkt_proc;
@@ -103,7 +100,10 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev);
static int pkt_remove_dev(dev_t pkt_dev);
static int pkt_seq_show(struct seq_file *m, void *p);
-
+static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
+{
+ return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
+}
/*
* create and register a pktcdvd kernel object.
@@ -1226,7 +1226,7 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
node = first_node;
while (node) {
bio = node->bio;
- zone = ZONE(bio->bi_sector, pd);
+ zone = get_zone(bio->bi_sector, pd);
list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) {
if (p->sector == zone) {
bio = NULL;
@@ -1266,8 +1266,8 @@ try_next_bio:
while ((node = pkt_rbtree_find(pd, zone)) != NULL) {
bio = node->bio;
VPRINTK("pkt_handle_queue: found zone=%llx\n",
- (unsigned long long)ZONE(bio->bi_sector, pd));
- if (ZONE(bio->bi_sector, pd) != zone)
+ (unsigned long long)get_zone(bio->bi_sector, pd));
+ if (get_zone(bio->bi_sector, pd) != zone)
break;
pkt_rbtree_erase(pd, node);
spin_lock(&pkt->lock);
@@ -2397,7 +2397,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
blk_queue_bounce(q, &bio);
- zone = ZONE(bio->bi_sector, pd);
+ zone = get_zone(bio->bi_sector, pd);
VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n",
(unsigned long long)bio->bi_sector,
(unsigned long long)bio_end_sector(bio));
@@ -2408,7 +2408,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
sector_t last_zone;
int first_sectors;
- last_zone = ZONE(bio_end_sector(bio) - 1, pd);
+ last_zone = get_zone(bio_end_sector(bio) - 1, pd);
if (last_zone != zone) {
BUG_ON(last_zone != zone + pd->settings.size);
first_sectors = last_zone - bio->bi_sector;
@@ -2503,7 +2503,7 @@ static int pkt_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd,
struct bio_vec *bvec)
{
struct pktcdvd_device *pd = q->queuedata;
- sector_t zone = ZONE(bmd->bi_sector, pd);
+ sector_t zone = get_zone(bmd->bi_sector, pd);
int used = ((bmd->bi_sector - zone) << 9) + bmd->bi_size;
int remaining = (pd->settings.size << 9) - used;
int remaining2;
--
1.8.1.2.459.gbcd45b4.dirty
next prev parent reply other threads:[~2013-06-01 4:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 8:11 [patch] pktcdvd: silence static checker warning Dan Carpenter
2013-05-29 13:37 ` Jiri Kosina
2013-05-30 20:57 ` [PATCH 0/3] pktcdvd: A few more neatenings Joe Perches
2013-05-30 20:57 ` [PATCH 1/3] pktcdvd: Convert ZONE macro to static function get_zone() Joe Perches
2013-05-30 20:57 ` [PATCH 2/3] pktcdvd: Convert printk to pr_<level> Joe Perches
2013-05-31 19:44 ` Andy Shevchenko
2013-05-31 21:56 ` Joe Perches
2013-05-30 20:57 ` [PATCH 3/3] pktcdvd: Consolidate DPRINTK and VPRINTK macros Joe Perches
2013-05-31 5:37 ` [PATCH 0/3] pktcdvd: A few more neatenings Joe Perches
2013-06-01 4:11 ` [PATCH V2 0/8] pktcdvd: More neatenings Joe Perches
2013-06-01 4:11 ` Joe Perches [this message]
2013-06-01 4:11 ` [PATCH V2 2/8] pktcdvd: Convert printk to pr_<level> Joe Perches
2013-06-03 9:57 ` Dan Carpenter
2013-06-03 10:42 ` Andy Shevchenko
2013-06-03 11:59 ` Joe Perches
2013-06-03 12:50 ` Dan Carpenter
2013-06-03 12:58 ` Joe Perches
2013-06-03 16:45 ` [PATCH V3 0/8] pktcdvd: More neatenings Joe Perches
2013-06-03 16:45 ` [PATCH V3 1/8] pktcdvd: Convert ZONE macro to static function get_zone() Joe Perches
2013-06-03 16:45 ` [PATCH V3 2/8] pktcdvd: Convert printk to pr_<level> Joe Perches
2013-06-03 16:45 ` [PATCH V3 3/8] pktcdvd: Consolidate DPRINTK and VPRINTK macros Joe Perches
2013-06-03 16:45 ` [PATCH V3 4/8] pktcdvd: Add struct pktcdvd_device * to pkt_dbg Joe Perches
2013-06-03 16:45 ` [PATCH V3 5/8] pktcdvd: Add struct pktcdvd_device.name to pr_err logging where possible Joe Perches
2013-06-03 16:45 ` [PATCH V3 6/8] pktcdvd: Convert pr_notice to pkt_notice Joe Perches
2013-06-03 16:45 ` [PATCH V3 7/8] pktcdvd: Convert pr_info to pkt_info Joe Perches
2013-06-03 16:45 ` [PATCH V3 8/8] pktcdvd: Add struct pktcdvd_device * to pkt_dump_sense() Joe Perches
2013-07-23 0:53 ` [PATCH V3 0/8] pktcdvd: More neatenings Joe Perches
2013-07-30 9:18 ` Jiri Kosina
2013-06-01 4:11 ` [PATCH V2 3/8] pktcdvd: Consolidate DPRINTK and VPRINTK macros Joe Perches
2013-06-01 4:11 ` [PATCH V2 4/8] pktcdvd: Add struct pktcdvd_device * to pkt_dbg Joe Perches
2013-06-01 4:11 ` [PATCH V2 5/8] pktcdvd: Add struct pktcdvd_device.name to pr_err logging where possible Joe Perches
2013-06-01 4:11 ` [PATCH V2 6/8] pktcdvd: Convert pr_notice to pkt_notice Joe Perches
2013-06-02 12:12 ` Andy Shevchenko
2013-06-02 12:22 ` Joe Perches
2013-06-01 4:11 ` [PATCH V2 7/8] pktcdvd: Convert pr_info to pkt_info Joe Perches
2013-06-01 4:11 ` [PATCH V2 8/8] pktcdvd: Add struct pktcdvd_device * to pkt_dump_sense() Joe Perches
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=cffa2f13c7621e38d2ecfbd5d8ea02920e1d4afb.1370048648.git.joe@perches.com \
--to=joe@perches.com \
--cc=andy.shevchenko@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®