Re: [PATCH 3/4] virtual block device driver (ramzswap)

From: Marcin Slusarz
Date: Fri Sep 18 2009 - 16:49:01 EST


Nitin Gupta wrote:
> (...)
> +
> +static int page_zero_filled(void *ptr)
> +{
> + u32 pos;
> + u64 *page;
> +
> + page = (u64 *)ptr;
> +
> + for (pos = 0; pos != PAGE_SIZE / sizeof(*page); pos++) {
> + if (page[pos])
> + return 0;
> + }
> +
> + return 1;
> +}

Wouldn't unsigned long *page be better for both 32-bit and 64-bit machines?

(This function could return bool)

> (...)
> +static void create_device(struct ramzswap *rzs, int device_id)
> +{
> + mutex_init(&rzs->lock);
> + INIT_LIST_HEAD(&rzs->backing_swap_extent_list);
> +
> + rzs->queue = blk_alloc_queue(GFP_KERNEL);
> + if (!rzs->queue) {
> + pr_err("Error allocating disk queue for device %d\n",
> + device_id);
> + return;
> + }
> +
> + blk_queue_make_request(rzs->queue, ramzswap_make_request);
> + rzs->queue->queuedata = rzs;
> +
> + /* gendisk structure */
> + rzs->disk = alloc_disk(1);
> + if (!rzs->disk) {
> + blk_cleanup_queue(rzs->queue);
> + pr_warning("Error allocating disk structure for device %d\n",
> + device_id);
> + return;
> + }
> +
> + rzs->disk->major = ramzswap_major;
> + rzs->disk->first_minor = device_id;
> + rzs->disk->fops = &ramzswap_devops;
> + rzs->disk->queue = rzs->queue;
> + rzs->disk->private_data = rzs;
> + snprintf(rzs->disk->disk_name, 16, "ramzswap%d", device_id);
> +
> + /*
> + * Actual capacity set using RZSIO_SET_DISKSIZE_KB ioctl
> + * or set equal to backing swap device (if provided)
> + */
> + set_capacity(rzs->disk, 0);
> + add_disk(rzs->disk);
> +
> + rzs->init_done = 0;
> +
> + return;
> +}

needless return

Marcin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/