[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RESEND1 02/12] ALSA: vsnd: Implement driver's probe/remove



From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>

Add essential driver private info structure, initialize
locks and implement probe/remove of the Xen frontend
driver.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
---
 sound/drivers/xen-front.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/sound/drivers/xen-front.c b/sound/drivers/xen-front.c
index 61779c36cae3..8c5de7b0e7b5 100644
--- a/sound/drivers/xen-front.c
+++ b/sound/drivers/xen-front.c
@@ -26,6 +26,16 @@
 
 #include <xen/interface/io/sndif.h>
 
+struct xdrv_info {
+       struct xenbus_device *xb_dev;
+       spinlock_t io_lock;
+       struct mutex mutex;
+};
+
+static void xdrv_remove_internal(struct xdrv_info *drv_info)
+{
+}
+
 static void xdrv_be_on_changed(struct xenbus_device *xb_dev,
        enum xenbus_state backend_state)
 {
@@ -34,11 +44,28 @@ static void xdrv_be_on_changed(struct xenbus_device *xb_dev,
 static int xdrv_probe(struct xenbus_device *xb_dev,
        const struct xenbus_device_id *id)
 {
+       struct xdrv_info *drv_info;
+
+       drv_info = devm_kzalloc(&xb_dev->dev, sizeof(*drv_info), GFP_KERNEL);
+       if (!drv_info) {
+               xenbus_dev_fatal(xb_dev, -ENOMEM, "allocating device memory");
+               return -ENOMEM;
+       }
+
+       drv_info->xb_dev = xb_dev;
+       spin_lock_init(&drv_info->io_lock);
+       mutex_init(&drv_info->mutex);
+       dev_set_drvdata(&xb_dev->dev, drv_info);
        return 0;
 }
 
 static int xdrv_remove(struct xenbus_device *dev)
 {
+       struct xdrv_info *drv_info = dev_get_drvdata(&dev->dev);
+
+       mutex_lock(&drv_info->mutex);
+       xdrv_remove_internal(drv_info);
+       mutex_unlock(&drv_info->mutex);
        return 0;
 }
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.