mirror of https://gitee.com/openkylin/linux.git
pktcdvd: convert ZONE macro to static function get_zone()
Macros should be converted to functions where feasible to verify arguments and the like. Signed-off-by: Joe Perches <joe@perches.com> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
6723734cdf
commit
5323fb770b
|
@ -83,9 +83,6 @@
|
||||||
|
|
||||||
#define MAX_SPEED 0xffff
|
#define MAX_SPEED 0xffff
|
||||||
|
|
||||||
#define ZONE(sector, pd) (((sector) + (pd)->offset) & \
|
|
||||||
~(sector_t)((pd)->settings.size - 1))
|
|
||||||
|
|
||||||
static DEFINE_MUTEX(pktcdvd_mutex);
|
static DEFINE_MUTEX(pktcdvd_mutex);
|
||||||
static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
|
static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
|
||||||
static struct proc_dir_entry *pkt_proc;
|
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_remove_dev(dev_t pkt_dev);
|
||||||
static int pkt_seq_show(struct seq_file *m, void *p);
|
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.
|
* create and register a pktcdvd kernel object.
|
||||||
|
@ -1224,7 +1224,7 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
|
||||||
node = first_node;
|
node = first_node;
|
||||||
while (node) {
|
while (node) {
|
||||||
bio = node->bio;
|
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) {
|
list_for_each_entry(p, &pd->cdrw.pkt_active_list, list) {
|
||||||
if (p->sector == zone) {
|
if (p->sector == zone) {
|
||||||
bio = NULL;
|
bio = NULL;
|
||||||
|
@ -1264,8 +1264,8 @@ static int pkt_handle_queue(struct pktcdvd_device *pd)
|
||||||
while ((node = pkt_rbtree_find(pd, zone)) != NULL) {
|
while ((node = pkt_rbtree_find(pd, zone)) != NULL) {
|
||||||
bio = node->bio;
|
bio = node->bio;
|
||||||
VPRINTK("pkt_handle_queue: found zone=%llx\n",
|
VPRINTK("pkt_handle_queue: found zone=%llx\n",
|
||||||
(unsigned long long)ZONE(bio->bi_sector, pd));
|
(unsigned long long)get_zone(bio->bi_sector, pd));
|
||||||
if (ZONE(bio->bi_sector, pd) != zone)
|
if (get_zone(bio->bi_sector, pd) != zone)
|
||||||
break;
|
break;
|
||||||
pkt_rbtree_erase(pd, node);
|
pkt_rbtree_erase(pd, node);
|
||||||
spin_lock(&pkt->lock);
|
spin_lock(&pkt->lock);
|
||||||
|
@ -2394,7 +2394,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
|
||||||
|
|
||||||
blk_queue_bounce(q, &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",
|
VPRINTK("pkt_make_request: start = %6llx stop = %6llx\n",
|
||||||
(unsigned long long)bio->bi_sector,
|
(unsigned long long)bio->bi_sector,
|
||||||
(unsigned long long)bio_end_sector(bio));
|
(unsigned long long)bio_end_sector(bio));
|
||||||
|
@ -2405,7 +2405,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
|
||||||
sector_t last_zone;
|
sector_t last_zone;
|
||||||
int first_sectors;
|
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) {
|
if (last_zone != zone) {
|
||||||
BUG_ON(last_zone != zone + pd->settings.size);
|
BUG_ON(last_zone != zone + pd->settings.size);
|
||||||
first_sectors = last_zone - bio->bi_sector;
|
first_sectors = last_zone - bio->bi_sector;
|
||||||
|
@ -2500,7 +2500,7 @@ static int pkt_merge_bvec(struct request_queue *q, struct bvec_merge_data *bmd,
|
||||||
struct bio_vec *bvec)
|
struct bio_vec *bvec)
|
||||||
{
|
{
|
||||||
struct pktcdvd_device *pd = q->queuedata;
|
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 used = ((bmd->bi_sector - zone) << 9) + bmd->bi_size;
|
||||||
int remaining = (pd->settings.size << 9) - used;
|
int remaining = (pd->settings.size << 9) - used;
|
||||||
int remaining2;
|
int remaining2;
|
||||||
|
|
Loading…
Reference in New Issue