summaryrefslogtreecommitdiff
path: root/drivers/misc/tifm_core.c
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2007-04-12 10:59:18 +0400
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 15:04:13 +0400
commit2428a8fe2261e901e058d9ea8b6ed7e1b4268b79 (patch)
tree8ef8c59c65ad192434abad416f53918198e6a1ec /drivers/misc/tifm_core.c
parent6113ed73e61a13db9da48831e1b35788b7f837cc (diff)
downloadlinux-2428a8fe2261e901e058d9ea8b6ed7e1b4268b79.tar.xz
tifm: move common device management tasks from tifm_7xx1 to tifm_core
Some details of the device management (create, add, remove) are really belong to the tifm_core, as they are not hardware specific. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/misc/tifm_core.c')
-rw-r--r--drivers/misc/tifm_core.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index f0cce2a642df..1e591989835d 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -232,25 +232,40 @@ EXPORT_SYMBOL(tifm_free_adapter);
void tifm_free_device(struct device *dev)
{
- struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
- kfree(fm_dev);
+ struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
+ kfree(sock);
}
EXPORT_SYMBOL(tifm_free_device);
-struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm)
+struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm, unsigned int id,
+ unsigned char type)
{
- struct tifm_dev *dev = kzalloc(sizeof(struct tifm_dev), GFP_KERNEL);
+ struct tifm_dev *sock = NULL;
+
+ if (!tifm_media_type_name(type, 0))
+ return sock;
- if (dev) {
- spin_lock_init(&dev->lock);
+ sock = kzalloc(sizeof(struct tifm_dev), GFP_KERNEL);
+ if (sock) {
+ spin_lock_init(&sock->lock);
+ sock->type = type;
+ sock->socket_id = id;
+ sock->card_event = tifm_dummy_event;
+ sock->data_event = tifm_dummy_event;
- dev->dev.parent = fm->cdev.dev;
- dev->dev.bus = &tifm_bus_type;
- dev->dev.release = tifm_free_device;
- dev->card_event = tifm_dummy_event;
- dev->data_event = tifm_dummy_event;
+ sock->dev.parent = fm->cdev.dev;
+ sock->dev.bus = &tifm_bus_type;
+ sock->dev.dma_mask = fm->cdev.dev->dma_mask;
+ sock->dev.release = tifm_free_device;
+
+ snprintf(sock->dev.bus_id, BUS_ID_SIZE,
+ "tifm_%s%u:%u", tifm_media_type_name(type, 2),
+ fm->id, id);
+ printk(KERN_INFO DRIVER_NAME
+ ": %s card detected in socket %u:%u\n",
+ tifm_media_type_name(type, 0), fm->id, id);
}
- return dev;
+ return sock;
}
EXPORT_SYMBOL(tifm_alloc_device);