Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 53555
b: refs/heads/master
c: 6113ed7
h: refs/heads/master
i:
  53553: 6f619aa
  53551: 0bdaf96
v: v3
  • Loading branch information
Alex Dubov authored and Pierre Ossman committed May 1, 2007
1 parent 4f81fee commit 2ded6bd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 342c0ec4859446140c0dc5d7d903bb3b3f0577cd
refs/heads/master: 6113ed73e61a13db9da48831e1b35788b7f837cc
28 changes: 10 additions & 18 deletions trunk/drivers/misc/tifm_7xx1.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
#define TIFM_IRQ_SETALL 0xffffffff

static void tifm_7xx1_dummy_eject(struct tifm_adapter *fm,
struct tifm_dev *sock)
{
}

static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
{
unsigned long flags;
Expand Down Expand Up @@ -140,7 +145,7 @@ static void tifm_7xx1_switch_media(struct work_struct *work)
socket_change_set = fm->socket_change_set;
fm->socket_change_set = 0;

dev_dbg(fm->dev, "checking media set %x\n",
dev_dbg(fm->cdev.dev, "checking media set %x\n",
socket_change_set);

if (!socket_change_set) {
Expand Down Expand Up @@ -328,20 +333,13 @@ static int tifm_7xx1_probe(struct pci_dev *dev,

pci_intx(dev, 1);

fm = tifm_alloc_adapter();
fm = tifm_alloc_adapter(dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM
? 4 : 2, &dev->dev);
if (!fm) {
rc = -ENOMEM;
goto err_out_int;
}

fm->dev = &dev->dev;
fm->num_sockets = (dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM)
? 4 : 2;
fm->sockets = kzalloc(sizeof(struct tifm_dev*) * fm->num_sockets,
GFP_KERNEL);
if (!fm->sockets)
goto err_out_free;

INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
fm->eject = tifm_7xx1_eject;
pci_set_drvdata(dev, fm);
Expand All @@ -351,18 +349,16 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
if (!fm->addr)
goto err_out_free;

rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm);
rc = request_irq(dev->irq, tifm_7xx1_isr, SA_SHIRQ, DRIVER_NAME, fm);
if (rc)
goto err_out_unmap;

rc = tifm_add_adapter(fm);
if (rc)
goto err_out_irq;

writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
fm->addr + FM_SET_INTERRUPT_ENABLE);

return 0;

err_out_irq:
Expand All @@ -384,16 +380,12 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
static void tifm_7xx1_remove(struct pci_dev *dev)
{
struct tifm_adapter *fm = pci_get_drvdata(dev);
unsigned long flags;

fm->eject = tifm_7xx1_dummy_eject;
writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
mmiowb();
free_irq(dev->irq, fm);

spin_lock_irqsave(&fm->lock, flags);
fm->socket_change_set = (1 << fm->num_sockets) - 1;
spin_unlock_irqrestore(&fm->lock, flags);

tifm_remove_adapter(fm);

pci_set_drvdata(dev, NULL);
Expand Down
52 changes: 31 additions & 21 deletions trunk/drivers/misc/tifm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ static void tifm_free(struct class_device *cdev)
{
struct tifm_adapter *fm = container_of(cdev, struct tifm_adapter, cdev);

kfree(fm->sockets);
kfree(fm);
}

Expand All @@ -165,26 +164,24 @@ static struct class tifm_adapter_class = {
.release = tifm_free
};

struct tifm_adapter *tifm_alloc_adapter(void)
struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
struct device *dev)
{
struct tifm_adapter *fm;

fm = kzalloc(sizeof(struct tifm_adapter), GFP_KERNEL);
fm = kzalloc(sizeof(struct tifm_adapter)
+ sizeof(struct tifm_dev*) * num_sockets, GFP_KERNEL);
if (fm) {
fm->cdev.class = &tifm_adapter_class;
spin_lock_init(&fm->lock);
fm->cdev.dev = dev;
class_device_initialize(&fm->cdev);
spin_lock_init(&fm->lock);
fm->num_sockets = num_sockets;
}
return fm;
}
EXPORT_SYMBOL(tifm_alloc_adapter);

void tifm_free_adapter(struct tifm_adapter *fm)
{
class_device_put(&fm->cdev);
}
EXPORT_SYMBOL(tifm_free_adapter);

int tifm_add_adapter(struct tifm_adapter *fm)
{
int rc;
Expand All @@ -195,31 +192,44 @@ int tifm_add_adapter(struct tifm_adapter *fm)
spin_lock(&tifm_adapter_lock);
rc = idr_get_new(&tifm_adapter_idr, fm, &fm->id);
spin_unlock(&tifm_adapter_lock);
if (!rc) {
snprintf(fm->cdev.class_id, BUS_ID_SIZE, "tifm%u", fm->id);
rc = class_device_add(&fm->cdev);

if (rc) {
spin_lock(&tifm_adapter_lock);
idr_remove(&tifm_adapter_idr, fm->id);
spin_unlock(&tifm_adapter_lock);
}
if (rc)
return rc;

snprintf(fm->cdev.class_id, BUS_ID_SIZE, "tifm%u", fm->id);
rc = class_device_add(&fm->cdev);
if (rc) {
spin_lock(&tifm_adapter_lock);
idr_remove(&tifm_adapter_idr, fm->id);
spin_unlock(&tifm_adapter_lock);
}

return rc;
}
EXPORT_SYMBOL(tifm_add_adapter);

void tifm_remove_adapter(struct tifm_adapter *fm)
{
unsigned int cnt;

flush_workqueue(workqueue);
class_device_del(&fm->cdev);
for (cnt = 0; cnt < fm->num_sockets; ++cnt) {
if (fm->sockets[cnt])
device_unregister(&fm->sockets[cnt]->dev);
}

spin_lock(&tifm_adapter_lock);
idr_remove(&tifm_adapter_idr, fm->id);
spin_unlock(&tifm_adapter_lock);
class_device_del(&fm->cdev);
}
EXPORT_SYMBOL(tifm_remove_adapter);

void tifm_free_adapter(struct tifm_adapter *fm)
{
class_device_put(&fm->cdev);
}
EXPORT_SYMBOL(tifm_free_adapter);

void tifm_free_device(struct device *dev)
{
struct tifm_dev *fm_dev = container_of(dev, struct tifm_dev, dev);
Expand All @@ -234,7 +244,7 @@ struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm)
if (dev) {
spin_lock_init(&dev->lock);

dev->dev.parent = fm->dev;
dev->dev.parent = fm->cdev.dev;
dev->dev.bus = &tifm_bus_type;
dev->dev.release = tifm_free_device;
dev->card_event = tifm_dummy_event;
Expand Down
16 changes: 10 additions & 6 deletions trunk/include/linux/tifm.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,23 @@ struct tifm_adapter {
unsigned int id;
unsigned int num_sockets;
struct completion *finish_me;
struct tifm_dev **sockets;

struct work_struct media_switcher;
struct class_device cdev;
struct device *dev;

void (*eject)(struct tifm_adapter *fm, struct tifm_dev *sock);
void (*eject)(struct tifm_adapter *fm,
struct tifm_dev *sock);

struct tifm_dev *sockets[0];
};

struct tifm_adapter *tifm_alloc_adapter(void);
void tifm_free_device(struct device *dev);
void tifm_free_adapter(struct tifm_adapter *fm);
struct tifm_adapter *tifm_alloc_adapter(unsigned int num_sockets,
struct device *dev);
int tifm_add_adapter(struct tifm_adapter *fm);
void tifm_remove_adapter(struct tifm_adapter *fm);
void tifm_free_adapter(struct tifm_adapter *fm);

void tifm_free_device(struct device *dev);
struct tifm_dev *tifm_alloc_device(struct tifm_adapter *fm);
int tifm_register_driver(struct tifm_driver *drv);
void tifm_unregister_driver(struct tifm_driver *drv);
Expand Down

0 comments on commit 2ded6bd

Please sign in to comment.