From e4ea886ee0f45c54e28d276d638054d88d45eaa7 Mon Sep 17 00:00:00 2001 From: Russ Meyerriecks Date: Mon, 16 Dec 2013 18:09:59 -0600 Subject: [PATCH] wcte13xp: wcaxx: Fix broken devicetype attributes struct dahdi_device.devicetype was set incorrectly in both drivers. This caused the vpm module to not show up after the device name when reading this field from a spanstat. Reported-by: Charles Moye Signed-off-by: Russ Meyerriecks --- drivers/dahdi/wcaxx-base.c | 7 ++++++- drivers/dahdi/wcte13xp-base.c | 32 +++++++------------------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/drivers/dahdi/wcaxx-base.c b/drivers/dahdi/wcaxx-base.c index b0fa8c6..5faf442 100644 --- a/drivers/dahdi/wcaxx-base.c +++ b/drivers/dahdi/wcaxx-base.c @@ -4299,7 +4299,12 @@ __wcaxx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) return -ENOMEM; } - wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s", wc->desc->name); + if (wc->vpm) + wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s (%s)", + wc->desc->name, "VPMOCT032"); + else + wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s", + wc->desc->name); if (!wc->ddev->devicetype) { wcaxx_back_out_gracefully(wc); diff --git a/drivers/dahdi/wcte13xp-base.c b/drivers/dahdi/wcte13xp-base.c index 40e9134..2270e6b 100644 --- a/drivers/dahdi/wcte13xp-base.c +++ b/drivers/dahdi/wcte13xp-base.c @@ -1252,25 +1252,6 @@ static void t13x_framer_start(struct t13x *wc) set_bit(DAHDI_FLAGBIT_RUNNING, &wc->span.flags); } -static void set_span_devicetype(struct t13x *wc) -{ - const char *olddevicetype; - olddevicetype = wc->ddev->devicetype; - -#ifndef VPM_SUPPORT - wc->ddev->devicetype = kasprintf(GFP_KERNEL, - "%s (VPMOCT032)", wc->devtype->name); -#else - wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s", wc->devtype->name); -#endif /* VPM_SUPPORT */ - - /* On the off chance that we were able to allocate it previously. */ - if (!wc->ddev->devicetype) - wc->ddev->devicetype = olddevicetype; - else - kfree(olddevicetype); -} - /** * te13xp_check_for_interrupts - Return 0 if the card is generating interrupts. * @wc: The card to check. @@ -1308,8 +1289,6 @@ static int t13x_startup(struct file *file, struct dahdi_span *span) unsigned long flags; int ret; - set_span_devicetype(wc); - /* Stop the DMA since the clock source may have changed. */ wcxb_stop_dma(&wc->xb); ret = wcxb_wait_for_stop(&wc->xb, 50); @@ -1727,8 +1706,6 @@ static int t13x_software_init(struct t13x *wc, enum linemode type) goto error_exit; } - set_span_devicetype(wc); - /* Because the interrupt handler is running, we need to atomically * swap the channel arrays. */ spin_lock_irqsave(&wc->reglock, flags); @@ -1780,8 +1757,6 @@ static int t13x_software_init(struct t13x *wc, enum linemode type) wc->chans[x]->chanpos = x + 1; } - set_span_devicetype(wc); - return 0; error_exit: @@ -2594,6 +2569,13 @@ static int __devinit te13xp_init_one(struct pci_dev *pdev, t13x_vpm_init(wc); #endif + if (wc->vpm) + wc->ddev->devicetype = kasprintf(GFP_KERNEL, + "%s (VPMOCT032)", wc->devtype->name); + else + wc->ddev->devicetype = kasprintf(GFP_KERNEL, "%s", + wc->devtype->name); + wc->span.ops = &t13x_span_ops; list_add_tail(&wc->span.device_node, &wc->ddev->spans);