aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ipack/bridges/tpci200.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 11:14:49 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-26 11:14:49 -0700
commitb13bc8dda81c54a66a1c84e66f60b8feba659f28 (patch)
tree100a26eada424fa5d9b0e5eaaf4e23b8fa036fc8 /drivers/staging/ipack/bridges/tpci200.c
parentMerge tag 'usb-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb (diff)
parentstaging: csr: delete a bunch of unused library functions (diff)
downloadlinux-dev-b13bc8dda81c54a66a1c84e66f60b8feba659f28.tar.xz
linux-dev-b13bc8dda81c54a66a1c84e66f60b8feba659f28.zip
Merge tag 'staging-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging tree patches from Greg Kroah-Hartman: "Here's the big staging tree merge for the 3.6-rc1 merge window. There are some patches in here outside of drivers/staging/, notibly the iio code (which is still stradeling the staging / not staging boundry), the pstore code, and the tracing code. All of these have gotten acks from the various subsystem maintainers to be included in this tree. The pstore and tracing patches are related, and are coming here as they replace one of the android staging drivers. Otherwise, the normal staging mess. Lots of cleanups and a few new drivers (some iio drivers, and the large csr wireless driver abomination.) Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" Fixed up trivial conflicts in drivers/staging/comedi/drivers/s626.h and drivers/staging/gdm72xx/netlink_k.c * tag 'staging-3.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1108 commits) staging: csr: delete a bunch of unused library functions staging: csr: remove csr_utf16.c staging: csr: remove csr_pmem.h staging: csr: remove CsrPmemAlloc staging: csr: remove CsrPmemFree() staging: csr: remove CsrMemAllocDma() staging: csr: remove CsrMemCalloc() staging: csr: remove CsrMemAlloc() staging: csr: remove CsrMemFree() and CsrMemFreeDma() staging: csr: remove csr_util.h staging: csr: remove CsrOffSetOf() stating: csr: remove unneeded #includes in csr_util.c staging: csr: make CsrUInt16ToHex static staging: csr: remove CsrMemCpy() staging: csr: remove CsrStrLen() staging: csr: remove CsrVsnprintf() staging: csr: remove CsrStrDup staging: csr: remove CsrStrChr() staging: csr: remove CsrStrNCmp staging: csr: remove CsrStrCmp ...
Diffstat (limited to 'drivers/staging/ipack/bridges/tpci200.c')
-rw-r--r--drivers/staging/ipack/bridges/tpci200.c473
1 files changed, 117 insertions, 356 deletions
diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index ad2870750235..2b83fa8e550a 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -11,8 +11,6 @@
* Software Foundation; version 2 of the License.
*/
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
#include <linux/module.h>
#include "tpci200.h"
@@ -36,10 +34,8 @@ static struct tpci200_board *check_slot(struct ipack_device *dev)
struct tpci200_board *tpci200;
int found = 0;
- if (dev == NULL) {
- pr_info("Slot doesn't exist.\n");
+ if (dev == NULL)
return NULL;
- }
list_for_each_entry(tpci200, &tpci200_list, list) {
if (tpci200->number == dev->bus_nr) {
@@ -49,20 +45,14 @@ static struct tpci200_board *check_slot(struct ipack_device *dev)
}
if (!found) {
- pr_err("Carrier not found\n");
+ dev_err(&dev->dev, "Carrier not found\n");
return NULL;
}
if (dev->slot >= TPCI200_NB_SLOT) {
- pr_info("Slot [%d:%d] doesn't exist! Last tpci200 slot is %d.\n",
- dev->bus_nr, dev->slot, TPCI200_NB_SLOT-1);
- return NULL;
- }
-
- BUG_ON(tpci200->slots == NULL);
- if (tpci200->slots[dev->slot].dev == NULL) {
- pr_info("Slot [%d:%d] is not registered !\n", dev->bus_nr,
- dev->slot);
+ dev_info(&dev->dev,
+ "Slot [%d:%d] doesn't exist! Last tpci200 slot is %d.\n",
+ dev->bus_nr, dev->slot, TPCI200_NB_SLOT-1);
return NULL;
}
@@ -123,14 +113,15 @@ static struct ipack_addr_space *get_slot_address_space(struct ipack_device *dev,
addr = &dev->mem_space;
break;
default:
- pr_err("Slot [%d:%d] space number %d doesn't exist !\n",
- dev->bus_nr, dev->slot, space);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] space number %d doesn't exist !\n",
+ dev->bus_nr, dev->slot, space);
return NULL;
break;
}
if ((addr->size == 0) || (addr->address == NULL)) {
- pr_err("Error, slot space not mapped !\n");
+ dev_err(&dev->dev, "Error, slot space not mapped !\n");
return NULL;
}
@@ -152,7 +143,7 @@ static int tpci200_read8(struct ipack_device *dev, int space,
return -EINVAL;
if (offset >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
@@ -176,7 +167,7 @@ static int tpci200_read16(struct ipack_device *dev, int space,
return -EINVAL;
if ((offset+2) >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
*value = __tpci200_read16(addr->address, offset);
@@ -199,7 +190,7 @@ static int tpci200_read32(struct ipack_device *dev, int space,
return -EINVAL;
if ((offset+4) >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
@@ -223,7 +214,7 @@ static int tpci200_write8(struct ipack_device *dev, int space,
return -EINVAL;
if (offset >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
@@ -247,7 +238,7 @@ static int tpci200_write16(struct ipack_device *dev, int space,
return -EINVAL;
if ((offset+2) >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
@@ -271,7 +262,7 @@ static int tpci200_write32(struct ipack_device *dev, int space,
return -EINVAL;
if ((offset+4) >= addr->size) {
- pr_err("Error, slot space offset error !\n");
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
return -EFAULT;
}
@@ -297,8 +288,6 @@ static void tpci200_unregister(struct tpci200_board *tpci200)
pci_disable_device(tpci200->info->pdev);
pci_dev_put(tpci200->info->pdev);
- kfree(tpci200->info);
-
for (i = 0; i < TPCI200_NB_SLOT; i++) {
tpci200->slots[i].io_phys.address = NULL;
tpci200->slots[i].io_phys.size = 0;
@@ -313,13 +302,10 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
{
struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id;
int i;
- unsigned long flags;
unsigned short status_reg, reg_value;
unsigned short unhandled_ints = 0;
irqreturn_t ret = IRQ_NONE;
- spin_lock_irqsave(&tpci200->info->access_lock, flags);
-
/* Read status register */
status_reg = readw(tpci200->info->interface_regs +
TPCI200_STATUS_REG);
@@ -347,8 +333,9 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
if (unhandled_ints) {
for (i = 0; i < TPCI200_NB_SLOT; i++) {
if (unhandled_ints & ((TPCI200_INT0_EN | TPCI200_INT1_EN) << (2*i))) {
- pr_info("No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n",
- tpci200->number, i);
+ dev_info(&tpci200->slots[i].dev->dev,
+ "No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n",
+ tpci200->number, i);
reg_value = readw(
tpci200->info->interface_regs +
control_reg[i]);
@@ -361,211 +348,12 @@ static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
}
}
- spin_unlock_irqrestore(&tpci200->info->access_lock, flags);
return ret;
}
-#ifdef CONFIG_SYSFS
-
-static struct ipack_device *tpci200_slot_register(unsigned int tpci200_number,
- unsigned int slot_position)
-{
- int found = 0;
- struct ipack_device *dev;
- struct tpci200_board *tpci200;
-
- list_for_each_entry(tpci200, &tpci200_list, list) {
- if (tpci200->number == tpci200_number) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- pr_err("carrier board not found for the device\n");
- return NULL;
- }
-
- if (slot_position >= TPCI200_NB_SLOT) {
- pr_info("Slot [%d:%d] doesn't exist!\n", tpci200_number,
- slot_position);
- return NULL;
- }
-
- if (mutex_lock_interruptible(&tpci200->mutex))
- return NULL;
-
- if (tpci200->slots[slot_position].dev != NULL) {
- pr_err("Slot [%d:%d] already installed !\n", tpci200_number,
- slot_position);
- goto err_unlock;
- }
-
- /*
- * Give the same IRQ number as the slot number.
- * The TPCI200 has assigned his own two IRQ by PCI bus driver
- */
- dev = ipack_device_register(tpci200->info->ipack_bus,
- slot_position, slot_position);
- if (dev == NULL) {
- pr_info("Slot [%d:%d] Unable to register an ipack device\n",
- tpci200_number, slot_position);
- goto err_unlock;
- }
-
- tpci200->slots[slot_position].dev = dev;
- mutex_unlock(&tpci200->mutex);
- return dev;
-
-err_unlock:
- mutex_unlock(&tpci200->mutex);
- return NULL;
-}
-
-static ssize_t tpci200_store_board(struct device *pdev, const char *buf,
- size_t count, int slot)
-{
- struct tpci200_board *card = dev_get_drvdata(pdev);
- struct ipack_device *dev = card->slots[slot].dev;
-
- if (dev != NULL)
- return -EBUSY;
-
- dev = tpci200_slot_register(card->number, slot);
- if (dev == NULL)
- return -ENODEV;
-
- return count;
-}
-
-static ssize_t tpci200_show_board(struct device *pdev, char *buf, int slot)
-{
- struct tpci200_board *card = dev_get_drvdata(pdev);
- struct ipack_device *dev = card->slots[slot].dev;
-
- if (dev != NULL)
- return snprintf(buf, PAGE_SIZE, "%s\n", dev_name(&dev->dev));
- else
- return snprintf(buf, PAGE_SIZE, "none\n");
-}
-
-static ssize_t tpci200_show_description(struct device *pdev,
- struct device_attribute *attr,
- char *buf)
-{
- return snprintf(buf, PAGE_SIZE,
- "TEWS tpci200 carrier PCI for Industry-pack mezzanines.\n");
-}
-
-static ssize_t tpci200_show_board_slot0(struct device *pdev,
- struct device_attribute *attr,
- char *buf)
-{
- return tpci200_show_board(pdev, buf, 0);
-}
-
-static ssize_t tpci200_store_board_slot0(struct device *pdev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return tpci200_store_board(pdev, buf, count, 0);
-}
-
-static ssize_t tpci200_show_board_slot1(struct device *pdev,
- struct device_attribute *attr,
- char *buf)
-{
- return tpci200_show_board(pdev, buf, 1);
-}
-
-static ssize_t tpci200_store_board_slot1(struct device *pdev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return tpci200_store_board(pdev, buf, count, 1);
-}
-
-static ssize_t tpci200_show_board_slot2(struct device *pdev,
- struct device_attribute *attr,
- char *buf)
-{
- return tpci200_show_board(pdev, buf, 2);
-}
-
-static ssize_t tpci200_store_board_slot2(struct device *pdev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return tpci200_store_board(pdev, buf, count, 2);
-}
-
-
-static ssize_t tpci200_show_board_slot3(struct device *pdev,
- struct device_attribute *attr,
- char *buf)
-{
- return tpci200_show_board(pdev, buf, 3);
-}
-
-static ssize_t tpci200_store_board_slot3(struct device *pdev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return tpci200_store_board(pdev, buf, count, 3);
-}
-
-/* Declaration of the device attributes for the TPCI200 */
-static DEVICE_ATTR(description, S_IRUGO,
- tpci200_show_description, NULL);
-static DEVICE_ATTR(board_slot0, S_IRUGO | S_IWUSR,
- tpci200_show_board_slot0, tpci200_store_board_slot0);
-static DEVICE_ATTR(board_slot1, S_IRUGO | S_IWUSR,
- tpci200_show_board_slot1, tpci200_store_board_slot1);
-static DEVICE_ATTR(board_slot2, S_IRUGO | S_IWUSR,
- tpci200_show_board_slot2, tpci200_store_board_slot2);
-static DEVICE_ATTR(board_slot3, S_IRUGO | S_IWUSR,
- tpci200_show_board_slot3, tpci200_store_board_slot3);
-
-static struct attribute *tpci200_attrs[] = {
- &dev_attr_description.attr,
- &dev_attr_board_slot0.attr,
- &dev_attr_board_slot1.attr,
- &dev_attr_board_slot2.attr,
- &dev_attr_board_slot3.attr,
- NULL,
-};
-
-static struct attribute_group tpci200_attr_group = {
- .attrs = tpci200_attrs,
-};
-
-static int tpci200_create_sysfs_files(struct tpci200_board *card)
-{
- return sysfs_create_group(&card->info->pdev->dev.kobj,
- &tpci200_attr_group);
-}
-
-static void tpci200_remove_sysfs_files(struct tpci200_board *card)
-{
- sysfs_remove_group(&card->info->pdev->dev.kobj, &tpci200_attr_group);
-}
-
-#else
-
-static int tpci200_create_sysfs_files(struct tpci200_board *card)
-{
- return 0;
-}
-
-static void tpci200_remove_sysfs_files(struct tpci200_board *card)
-{
-}
-
-#endif /* CONFIG_SYSFS */
-
static int tpci200_register(struct tpci200_board *tpci200)
{
- int i;
+ int i;
int res;
unsigned long ioidint_base;
unsigned long mem_base;
@@ -574,20 +362,15 @@ static int tpci200_register(struct tpci200_board *tpci200)
if (pci_enable_device(tpci200->info->pdev) < 0)
return -ENODEV;
- if (tpci200_create_sysfs_files(tpci200) < 0) {
- pr_err("failed creating sysfs files\n");
- res = -EFAULT;
- goto out_disable_pci;
- }
-
/* Request IP interface register (Bar 2) */
res = pci_request_region(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR,
"Carrier IP interface registers");
if (res) {
- pr_err("(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 2 !",
- tpci200->info->pdev->bus->number,
- tpci200->info->pdev->devfn);
- goto out_remove_sysfs;
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 2 !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_disable_pci;
}
/* Request IO ID INT space (Bar 3) */
@@ -595,9 +378,10 @@ static int tpci200_register(struct tpci200_board *tpci200)
TPCI200_IO_ID_INT_SPACES_BAR,
"Carrier IO ID INT space");
if (res) {
- pr_err("(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 3 !",
- tpci200->info->pdev->bus->number,
- tpci200->info->pdev->devfn);
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 3 !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
goto out_release_ip_space;
}
@@ -605,9 +389,10 @@ static int tpci200_register(struct tpci200_board *tpci200)
res = pci_request_region(tpci200->info->pdev, TPCI200_MEM8_SPACE_BAR,
"Carrier MEM space");
if (res) {
- pr_err("(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 4!",
- tpci200->info->pdev->bus->number,
- tpci200->info->pdev->devfn);
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 4!",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
goto out_release_ioid_int_space;
}
@@ -625,7 +410,6 @@ static int tpci200_register(struct tpci200_board *tpci200)
TPCI200_MEM8_SPACE_BAR),
TPCI200_MEM8_SIZE);
- spin_lock_init(&tpci200->info->access_lock);
ioidint_base = pci_resource_start(tpci200->info->pdev,
TPCI200_IO_ID_INT_SPACES_BAR);
mem_base = pci_resource_start(tpci200->info->pdev,
@@ -665,11 +449,11 @@ static int tpci200_register(struct tpci200_board *tpci200)
tpci200_interrupt, IRQF_SHARED,
KBUILD_MODNAME, (void *) tpci200);
if (res) {
- pr_err("(bn 0x%X, sn 0x%X) unable to register IRQ !",
- tpci200->info->pdev->bus->number,
- tpci200->info->pdev->devfn);
- tpci200_unregister(tpci200);
- goto out_err;
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) unable to register IRQ !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_release_ioid_int_space;
}
return 0;
@@ -678,11 +462,8 @@ out_release_ioid_int_space:
pci_release_region(tpci200->info->pdev, TPCI200_IO_ID_INT_SPACES_BAR);
out_release_ip_space:
pci_release_region(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR);
-out_remove_sysfs:
- tpci200_remove_sysfs_files(tpci200);
out_disable_pci:
pci_disable_device(tpci200->info->pdev);
-out_err:
return res;
}
@@ -726,24 +507,19 @@ static void __tpci200_free_irq(struct tpci200_board *tpci200,
static int tpci200_free_irq(struct ipack_device *dev)
{
- int res;
struct slot_irq *slot_irq;
struct tpci200_board *tpci200;
tpci200 = check_slot(dev);
- if (tpci200 == NULL) {
- res = -EINVAL;
- goto out;
- }
+ if (tpci200 == NULL)
+ return -EINVAL;
- if (mutex_lock_interruptible(&tpci200->mutex)) {
- res = -ERESTARTSYS;
- goto out;
- }
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
if (tpci200->slots[dev->slot].irq == NULL) {
- res = -EINVAL;
- goto out_unlock;
+ mutex_unlock(&tpci200->mutex);
+ return -EINVAL;
}
__tpci200_free_irq(tpci200, dev);
@@ -751,60 +527,56 @@ static int tpci200_free_irq(struct ipack_device *dev)
tpci200->slots[dev->slot].irq = NULL;
kfree(slot_irq);
-out_unlock:
mutex_unlock(&tpci200->mutex);
-out:
- return res;
+ return 0;
}
static int tpci200_slot_unmap_space(struct ipack_device *dev, int space)
{
- int res;
struct ipack_addr_space *virt_addr_space;
struct tpci200_board *tpci200;
tpci200 = check_slot(dev);
- if (tpci200 == NULL) {
- res = -EINVAL;
- goto out;
- }
+ if (tpci200 == NULL)
+ return -EINVAL;
- if (mutex_lock_interruptible(&tpci200->mutex)) {
- res = -ERESTARTSYS;
- goto out;
- }
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
switch (space) {
case IPACK_IO_SPACE:
if (dev->io_space.address == NULL) {
- pr_info("Slot [%d:%d] IO space not mapped !\n",
- dev->bus_nr, dev->slot);
+ dev_info(&dev->dev,
+ "Slot [%d:%d] IO space not mapped !\n",
+ dev->bus_nr, dev->slot);
goto out_unlock;
}
virt_addr_space = &dev->io_space;
break;
case IPACK_ID_SPACE:
if (dev->id_space.address == NULL) {
- pr_info("Slot [%d:%d] ID space not mapped !\n",
- dev->bus_nr, dev->slot);
+ dev_info(&dev->dev,
+ "Slot [%d:%d] ID space not mapped !\n",
+ dev->bus_nr, dev->slot);
goto out_unlock;
}
virt_addr_space = &dev->id_space;
break;
case IPACK_MEM_SPACE:
if (dev->mem_space.address == NULL) {
- pr_info("Slot [%d:%d] MEM space not mapped !\n",
- dev->bus_nr, dev->slot);
- goto out_unlock;
+ dev_info(&dev->dev,
+ "Slot [%d:%d] MEM space not mapped !\n",
+ dev->bus_nr, dev->slot);
+ goto out_unlock;
}
virt_addr_space = &dev->mem_space;
break;
default:
- pr_err("Slot [%d:%d] space number %d doesn't exist !\n",
- dev->bus_nr, dev->slot, space);
- res = -EINVAL;
- goto out_unlock;
- break;
+ dev_err(&dev->dev,
+ "Slot [%d:%d] space number %d doesn't exist !\n",
+ dev->bus_nr, dev->slot, space);
+ mutex_unlock(&tpci200->mutex);
+ return -EINVAL;
}
iounmap(virt_addr_space->address);
@@ -813,8 +585,7 @@ static int tpci200_slot_unmap_space(struct ipack_device *dev, int space)
virt_addr_space->size = 0;
out_unlock:
mutex_unlock(&tpci200->mutex);
-out:
- return res;
+ return 0;
}
static int tpci200_slot_unregister(struct ipack_device *dev)
@@ -843,28 +614,25 @@ static int tpci200_slot_unregister(struct ipack_device *dev)
static int tpci200_slot_map_space(struct ipack_device *dev,
unsigned int memory_size, int space)
{
- int res;
+ int res = 0;
unsigned int size_to_map;
void __iomem *phys_address;
struct ipack_addr_space *virt_addr_space;
struct tpci200_board *tpci200;
tpci200 = check_slot(dev);
- if (tpci200 == NULL) {
- res = -EINVAL;
- goto out;
- }
+ if (tpci200 == NULL)
+ return -EINVAL;
- if (mutex_lock_interruptible(&tpci200->mutex)) {
- res = -ERESTARTSYS;
- goto out;
- }
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
switch (space) {
case IPACK_IO_SPACE:
if (dev->io_space.address != NULL) {
- pr_err("Slot [%d:%d] IO space already mapped !\n",
- tpci200->number, dev->slot);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] IO space already mapped !\n",
+ tpci200->number, dev->slot);
res = -EINVAL;
goto out_unlock;
}
@@ -875,8 +643,9 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
break;
case IPACK_ID_SPACE:
if (dev->id_space.address != NULL) {
- pr_err("Slot [%d:%d] ID space already mapped !\n",
- tpci200->number, dev->slot);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] ID space already mapped !\n",
+ tpci200->number, dev->slot);
res = -EINVAL;
goto out_unlock;
}
@@ -887,17 +656,19 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
break;
case IPACK_MEM_SPACE:
if (dev->mem_space.address != NULL) {
- pr_err("Slot [%d:%d] MEM space already mapped !\n",
- tpci200->number, dev->slot);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] MEM space already mapped !\n",
+ tpci200->number, dev->slot);
res = -EINVAL;
goto out_unlock;
}
virt_addr_space = &dev->mem_space;
if (memory_size > tpci200->slots[dev->slot].mem_phys.size) {
- pr_err("Slot [%d:%d] request is 0x%X memory, only 0x%X available !\n",
- dev->bus_nr, dev->slot, memory_size,
- tpci200->slots[dev->slot].mem_phys.size);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] request is 0x%X memory, only 0x%X available !\n",
+ dev->bus_nr, dev->slot, memory_size,
+ tpci200->slots[dev->slot].mem_phys.size);
res = -EINVAL;
goto out_unlock;
}
@@ -906,11 +677,10 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
size_to_map = memory_size;
break;
default:
- pr_err("Slot [%d:%d] space %d doesn't exist !\n",
- tpci200->number, dev->slot, space);
+ dev_err(&dev->dev, "Slot [%d:%d] space %d doesn't exist !\n",
+ tpci200->number, dev->slot, space);
res = -EINVAL;
goto out_unlock;
- break;
}
virt_addr_space->size = size_to_map;
@@ -919,7 +689,6 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
out_unlock:
mutex_unlock(&tpci200->mutex);
-out:
return res;
}
@@ -931,27 +700,25 @@ static int tpci200_request_irq(struct ipack_device *dev, int vector,
struct tpci200_board *tpci200;
tpci200 = check_slot(dev);
- if (tpci200 == NULL) {
- res = -EINVAL;
- goto out;
- }
+ if (tpci200 == NULL)
+ return -EINVAL;
- if (mutex_lock_interruptible(&tpci200->mutex)) {
- res = -ERESTARTSYS;
- goto out;
- }
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
if (tpci200->slots[dev->slot].irq != NULL) {
- pr_err("Slot [%d:%d] IRQ already registered !\n", dev->bus_nr,
- dev->slot);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] IRQ already registered !\n", dev->bus_nr,
+ dev->slot);
res = -EINVAL;
goto out_unlock;
}
slot_irq = kzalloc(sizeof(struct slot_irq), GFP_KERNEL);
if (slot_irq == NULL) {
- pr_err("Slot [%d:%d] unable to allocate memory for IRQ !\n",
- dev->bus_nr, dev->slot);
+ dev_err(&dev->dev,
+ "Slot [%d:%d] unable to allocate memory for IRQ !\n",
+ dev->bus_nr, dev->slot);
res = -ENOMEM;
goto out_unlock;
}
@@ -965,32 +732,21 @@ static int tpci200_request_irq(struct ipack_device *dev, int vector,
slot_irq->vector = vector;
slot_irq->handler = handler;
slot_irq->arg = arg;
- slot_irq->name = dev_name(&dev->dev);
tpci200->slots[dev->slot].irq = slot_irq;
res = __tpci200_request_irq(tpci200, dev);
out_unlock:
mutex_unlock(&tpci200->mutex);
-out:
return res;
}
-static void tpci200_slot_remove(struct tpci200_slot *slot)
-{
- if ((slot->dev == NULL) ||
- (slot->dev->driver->ops->remove == NULL))
- return;
-
- slot->dev->driver->ops->remove(slot->dev);
-}
-
static void tpci200_uninstall(struct tpci200_board *tpci200)
{
int i;
for (i = 0; i < TPCI200_NB_SLOT; i++)
- tpci200_slot_remove(&tpci200->slots[i]);
+ tpci200_slot_unregister(tpci200->slots[i].dev);
tpci200_unregister(tpci200);
kfree(tpci200->slots);
@@ -1016,29 +772,24 @@ static int tpci200_install(struct tpci200_board *tpci200)
tpci200->slots = kzalloc(
TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL);
- if (tpci200->slots == NULL) {
- res = -ENOMEM;
- goto out_err;
- }
+ if (tpci200->slots == NULL)
+ return -ENOMEM;
res = tpci200_register(tpci200);
- if (res)
- goto out_free;
+ if (res) {
+ kfree(tpci200->slots);
+ tpci200->slots = NULL;
+ return res;
+ }
mutex_init(&tpci200->mutex);
return 0;
-
-out_free:
- kfree(tpci200->slots);
- tpci200->slots = NULL;
-out_err:
- return res;
}
static int tpci200_pciprobe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
- int ret;
+ int ret, i;
struct tpci200_board *tpci200;
tpci200 = kzalloc(sizeof(struct tpci200_board), GFP_KERNEL);
@@ -1058,7 +809,7 @@ static int tpci200_pciprobe(struct pci_dev *pdev,
/* register the device and initialize it */
ret = tpci200_install(tpci200);
if (ret) {
- pr_err("Error during tpci200 install !\n");
+ dev_err(&pdev->dev, "Error during tpci200 install !\n");
kfree(tpci200->info);
kfree(tpci200);
return -ENODEV;
@@ -1069,7 +820,8 @@ static int tpci200_pciprobe(struct pci_dev *pdev,
TPCI200_NB_SLOT,
&tpci200_bus_ops);
if (!tpci200->info->ipack_bus) {
- pr_err("error registering the carrier on ipack driver\n");
+ dev_err(&pdev->dev,
+ "error registering the carrier on ipack driver\n");
tpci200_uninstall(tpci200);
kfree(tpci200->info);
kfree(tpci200);
@@ -1081,13 +833,20 @@ static int tpci200_pciprobe(struct pci_dev *pdev,
dev_set_drvdata(&pdev->dev, tpci200);
/* add the registered device in an internal linked list */
list_add_tail(&tpci200->list, &tpci200_list);
+
+ /*
+ * Give the same IRQ number as the slot number.
+ * The TPCI200 has assigned his own two IRQ by PCI bus driver
+ */
+ for (i = 0; i < TPCI200_NB_SLOT; i++)
+ tpci200->slots[i].dev =
+ ipack_device_register(tpci200->info->ipack_bus, i, i);
return ret;
}
static void __tpci200_pci_remove(struct tpci200_board *tpci200)
{
tpci200_uninstall(tpci200);
- tpci200_remove_sysfs_files(tpci200);
list_del(&tpci200->list);
ipack_bus_unregister(tpci200->info->ipack_bus);
kfree(tpci200->info);
@@ -1107,12 +866,14 @@ static void __devexit tpci200_pci_remove(struct pci_dev *dev)
}
}
-static struct pci_device_id tpci200_idtable[2] = {
+static DEFINE_PCI_DEVICE_TABLE(tpci200_idtable) = {
{ TPCI200_VENDOR_ID, TPCI200_DEVICE_ID, TPCI200_SUBVENDOR_ID,
TPCI200_SUBDEVICE_ID },
{ 0, },
};
+MODULE_DEVICE_TABLE(pci, tpci200_idtable);
+
static struct pci_driver tpci200_pci_drv = {
.name = "tpci200",
.id_table = tpci200_idtable,