summaryrefslogtreecommitdiff
path: root/drivers/dahdi/vpmadt032_loader
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2010-01-08 20:48:02 +0000
committerShaun Ruffell <sruffell@digium.com>2010-01-08 20:48:02 +0000
commit4d3c52e9fa00c3f18744a08a15df24907129effb (patch)
treed11dd39820dea77726af5f860967e904c8cf7b5d /drivers/dahdi/vpmadt032_loader
parent6fb9c465e19b1eba4aa300de3f1e4902c2fb82b6 (diff)
voicebus: Make 'struct voicebus' embeddable by the client driver strutures.
In addition to making 'struct voicebus' embeddable, also add an 'voicebus_operations' structure. This was done so that a) remove the "context" pointer from struct voicebus, and also to show that handle_recieve/transmit are to be managed together. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7778 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/vpmadt032_loader')
-rw-r--r--drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c b/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
index ad1871b..d64931f 100644
--- a/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
+++ b/drivers/dahdi/vpmadt032_loader/dahdi_vpmadt032_loader.c
@@ -66,55 +66,59 @@ vpmlinkage static void memfree(void *ptr)
struct private_context {
struct voicebus *vb;
- void *old_rx;
- void *old_tx;
- void *old_context;
void *pvt;
struct completion done;
};
static void init_private_context(struct private_context *ctx)
{
- memset(ctx, 0, sizeof(ctx));
init_completion(&ctx->done);
}
-static void handle_receive(void *vbb, void *context)
+static void handle_receive(struct voicebus *vb, void *vbb)
{
- struct private_context *ctx = context;
+ struct private_context *ctx = pci_get_drvdata(vb->pdev);
__vpmadt032_receive(ctx->pvt, vbb);
if (__vpmadt032_done(ctx->pvt))
complete(&ctx->done);
}
-static void handle_transmit(void *vbb, void *context)
+static void handle_transmit(struct voicebus *vb, void *vbb)
{
- struct private_context *ctx = context;
+ struct private_context *ctx = pci_get_drvdata(vb->pdev);
__vpmadt032_transmit(ctx->pvt, vbb);
voicebus_transmit(ctx->vb, vbb);
}
+static const struct voicebus_operations loader_operations = {
+ .handle_receive = handle_receive,
+ .handle_transmit = handle_transmit,
+};
+
static int vpmadt032_load_firmware(struct voicebus *vb)
{
int ret = 0;
struct private_context *ctx;
- struct pci_dev *pdev = voicebus_get_pci_dev(vb);
+ const struct voicebus_operations *old;
+ void *old_drvdata;
might_sleep();
- ctx = kmalloc(sizeof(struct private_context), GFP_KERNEL);
+ ctx = kzalloc(sizeof(struct private_context), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
init_private_context(ctx);
ctx->vb = vb;
ret = __vpmadt032_start_load(
- 0, pdev->vendor << 16 | pdev->device,
+ 0, vb->pdev->vendor << 16 | vb->pdev->device,
&ctx->pvt);
if (ret)
goto error_exit;
- voicebus_get_handlers(vb, &ctx->old_rx, &ctx->old_tx,
- &ctx->old_context);
- voicebus_set_handlers(vb, handle_receive, handle_transmit, ctx);
+ old_drvdata = pci_get_drvdata(vb->pdev);
+ pci_set_drvdata(vb->pdev, ctx);
+ old = vb->ops;
+ vb->ops = &loader_operations;
wait_for_completion(&ctx->done);
- voicebus_set_handlers(vb, ctx->old_rx, ctx->old_tx, ctx->old_context);
+ vb->ops = old;
+ pci_set_drvdata(vb->pdev, old_drvdata);
__vpmadt032_cleanup(ctx->pvt);
error_exit:
kfree(ctx);