return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE);
}
-static int p9_virtio_write(struct p9_trans *trans, void *buf, int count)
-{
- /* Only use the rpc mechanism for now */
- return count;
-}
-
-static int p9_virtio_read(struct p9_trans *trans, void *buf, int count)
-{
- /* Only use the rpc mechanism for now */
- return 0;
-}
-
-/* The poll function is used by 9p transports to determine if there
- * is there is activity available on a particular channel. In our case
- * we use it to wait for a callback from the input routines.
- */
-static unsigned int
-p9_virtio_poll(struct p9_trans *trans, struct poll_table_struct *pt)
-{
- /* Only use the rpc mechanism for now */
- return 0;
-}
-
static void p9_virtio_close(struct p9_trans *trans)
{
struct virtio_chan *chan = trans->priv;
}
static int
-p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc,
- int msize, int dotu)
+p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
{
int in, out;
int n, err, size;
unsigned long flags;
if (*rc == NULL) {
- *rc = kmalloc(sizeof(struct p9_fcall) + msize, GFP_KERNEL);
+ *rc = kmalloc(sizeof(struct p9_fcall) + t->msize, GFP_KERNEL);
if (!*rc)
return -ENOMEM;
}
rdata = (char *)*rc+sizeof(struct p9_fcall);
- spin_lock_irqsave(&chan->lock, flags);
n = P9_NOTAG;
if (tc->id != P9_TVERSION) {
n = p9_idpool_get(chan->tagpool);
return -ENOMEM;
}
+ spin_lock_irqsave(&chan->lock, flags);
req = p9_lookup_tag(chan, n);
spin_unlock_irqrestore(&chan->lock, flags);
P9_DPRINTK(P9_DEBUG_TRANS, "9p debug: virtio rpc tag %d\n", n);
out = pack_sg_list(chan->sg, 0, VIRTQUEUE_NUM, tc->sdata, tc->size);
- in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM-out, rdata, msize);
+ in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM-out, rdata, t->msize);
req->status = REQ_STATUS_SENT;
size = le32_to_cpu(*(__le32 *) rdata);
- err = p9_deserialize_fcall(rdata, size, *rc, dotu);
+ err = p9_deserialize_fcall(rdata, size, *rc, t->extended);
if (err < 0) {
P9_DPRINTK(P9_DEBUG_TRANS,
"9p debug: virtio rpc deserialize returned %d\n", err);
if ((p9_debug_level&P9_DEBUG_FCALL) == P9_DEBUG_FCALL) {
char buf[150];
- p9_printfcall(buf, sizeof(buf), *rc, dotu);
+ p9_printfcall(buf, sizeof(buf), *rc, t->extended);
printk(KERN_NOTICE ">>> %p %s\n", t, buf);
}
#endif
* alternate channels by matching devname versus a virtio_config entry.
* We use a simple reference count mechanism to ensure that only a single
* mount has a channel open at a time. */
-static struct p9_trans *p9_virtio_create(const char *devname, char *args)
+static struct p9_trans *
+p9_virtio_create(const char *devname, char *args, int msize,
+ unsigned char extended)
{
struct p9_trans *trans;
struct virtio_chan *chan = channels;
printk(KERN_ERR "9p: couldn't allocate transport\n");
return ERR_PTR(-ENOMEM);
}
-
- trans->write = p9_virtio_write;
- trans->read = p9_virtio_read;
+ trans->extended = extended;
+ trans->msize = msize;
trans->close = p9_virtio_close;
- trans->poll = p9_virtio_poll;
trans->rpc = p9_virtio_rpc;
trans->priv = chan;
return trans;
}
+static void p9_virtio_remove(struct virtio_device *vdev)
+{
+ struct virtio_chan *chan = vdev->priv;
+
+ BUG_ON(chan->inuse);
+
+ if (chan->initialized) {
+ vdev->config->del_vq(chan->vq);
+ chan->initialized = false;
+ }
+}
+
#define VIRTIO_ID_9P 9
static struct virtio_device_id id_table[] = {
.driver.owner = THIS_MODULE,
.id_table = id_table,
.probe = p9_virtio_probe,
+ .remove = p9_virtio_remove,
};
static struct p9_trans_module p9_virtio_trans = {
return register_virtio_driver(&p9_virtio_drv);
}
+static void __exit p9_virtio_cleanup(void)
+{
+ unregister_virtio_driver(&p9_virtio_drv);
+}
+
module_init(p9_virtio_init);
+module_exit(p9_virtio_cleanup);
MODULE_DEVICE_TABLE(virtio, id_table);
MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");