On Friday 30 January 2009 09:35:07 Alex Williamson wrote:
> +static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
> +                              void *data, unsigned int len)
> +{
> +     struct scatterlist sg[3];
> +     struct virtio_net_ctrl_hdr ctrl;
> +     virtio_net_ctrl_ack status;
> +     unsigned int tmp;
> +     int i = 0;
> +
> +     if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ))
> +             return false;
> +
> +     sg_init_table(sg, len ? 3 : 2);

I'd test data rather than len here.

> +     sg_set_buf(&sg[i++], &ctrl, sizeof(ctrl));
> +     if (len)
> +             sg_set_buf(&sg[i++], data, len);
> +     sg_set_buf(&sg[i], &status, sizeof(status));
> +
> +     ctrl.class = class;
> +     ctrl.cmd = cmd;
> +
> +     status = ~0;
> +
> +     if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, i, 1, vi) != 0)
> +             BUG();

Hmm, I prefer initialize buffer, then set sg to refer to it.  Seems to make
more sense to me.

> +     while (!vi->cvq->vq_ops->get_buf(vi->cvq, &tmp))
> +             cpu_relax();

This probably deserves a comment about why it's OK to spin here.

> +     return status == VIRTIO_NET_OK ? true : false;

Or "return status == VIRTIO_NET_OK;" ?

See what I mean about nit-picking?
Rusty.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to