Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31485
b: refs/heads/master
c: 0db6095
h: refs/heads/master
i:
  31483: cbc6fb1
v: v3
  • Loading branch information
David Brownell authored and Dominik Brodowski committed Jun 30, 2006
1 parent ed6c263 commit b2b774b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 17 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: 5040cb8b7e61b7a03e8837920b9eb2c839bb1947
refs/heads/master: 0db6095d4ff8918350797dfe299d572980e82fa0
75 changes: 59 additions & 16 deletions trunk/drivers/pcmcia/at91_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,10 @@ static struct pccard_operations at91_cf_ops = {

/*--------------------------------------------------------------------------*/

static int __init at91_cf_probe(struct device *dev)
static int __init at91_cf_probe(struct platform_device *pdev)
{
struct at91_cf_socket *cf;
struct at91_cf_data *board = dev->platform_data;
struct platform_device *pdev = to_platform_device(dev);
struct at91_cf_data *board = pdev->dev.platform_data;
struct resource *io;
unsigned int csa;
int status;
Expand All @@ -236,7 +235,7 @@ static int __init at91_cf_probe(struct device *dev)

cf->board = board;
cf->pdev = pdev;
dev_set_drvdata(dev, cf);
platform_set_drvdata(pdev, cf);

/* CF takes over CS4, CS5, CS6 */
csa = at91_sys_read(AT91_EBI_CSA);
Expand Down Expand Up @@ -271,6 +270,7 @@ static int __init at91_cf_probe(struct device *dev)
SA_SAMPLE_RANDOM, driver_name, cf);
if (status < 0)
goto fail0;
device_init_wakeup(&pdev->dev, 1);

/*
* The card driver will request this irq later as needed.
Expand Down Expand Up @@ -301,7 +301,7 @@ static int __init at91_cf_probe(struct device *dev)
board->det_pin, board->irq_pin);

cf->socket.owner = THIS_MODULE;
cf->socket.dev.dev = dev;
cf->socket.dev.dev = &pdev->dev;
cf->socket.ops = &at91_cf_ops;
cf->socket.resource_ops = &pccard_static_ops;
cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
Expand All @@ -323,21 +323,25 @@ static int __init at91_cf_probe(struct device *dev)
free_irq(board->irq_pin, cf);
fail0a:
free_irq(board->det_pin, cf);
device_init_wakeup(&pdev->dev, 0);
fail0:
at91_sys_write(AT91_EBI_CSA, csa);
kfree(cf);
return status;
}

static int __exit at91_cf_remove(struct device *dev)
static int __exit at91_cf_remove(struct platform_device *pdev)
{
struct at91_cf_socket *cf = dev_get_drvdata(dev);
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
struct at91_cf_data *board = cf->board;
struct resource *io = cf->socket.io[0].res;
unsigned int csa;

pcmcia_unregister_socket(&cf->socket);
free_irq(cf->board->irq_pin, cf);
free_irq(cf->board->det_pin, cf);
if (board->irq_pin)
free_irq(board->irq_pin, cf);
free_irq(board->det_pin, cf);
device_init_wakeup(&pdev->dev, 0);
iounmap((void __iomem *) cf->socket.io_offset);
release_mem_region(io->start, io->end + 1 - io->start);

Expand All @@ -348,26 +352,65 @@ static int __exit at91_cf_remove(struct device *dev)
return 0;
}

static struct device_driver at91_cf_driver = {
.name = (char *) driver_name,
.bus = &platform_bus_type,
#ifdef CONFIG_PM

static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
{
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
struct at91_cf_data *board = cf->board;

pcmcia_socket_dev_suspend(&pdev->dev, mesg);
if (device_may_wakeup(&pdev->dev))
enable_irq_wake(board->det_pin);
else {
disable_irq_wake(board->det_pin);
disable_irq(board->det_pin);
}
if (board->irq_pin)
disable_irq(board->irq_pin);
return 0;
}

static int at91_cf_resume(struct platform_device *pdev)
{
struct at91_cf_socket *cf = platform_get_drvdata(pdev);
struct at91_cf_data *board = cf->board;

if (board->irq_pin)
enable_irq(board->irq_pin);
if (!device_may_wakeup(&pdev->dev))
enable_irq(board->det_pin);
pcmcia_socket_dev_resume(&pdev->dev);
return 0;
}

#else
#define at91_cf_suspend NULL
#define at91_cf_resume NULL
#endif

static struct platform_driver at91_cf_driver = {
.driver = {
.name = (char *) driver_name,
.owner = THIS_MODULE,
},
.probe = at91_cf_probe,
.remove = __exit_p(at91_cf_remove),
.suspend = pcmcia_socket_dev_suspend,
.resume = pcmcia_socket_dev_resume,
.suspend = at91_cf_suspend,
.resume = at91_cf_resume,
};

/*--------------------------------------------------------------------------*/

static int __init at91_cf_init(void)
{
return driver_register(&at91_cf_driver);
return platform_driver_register(&at91_cf_driver);
}
module_init(at91_cf_init);

static void __exit at91_cf_exit(void)
{
driver_unregister(&at91_cf_driver);
platform_driver_unregister(&at91_cf_driver);
}
module_exit(at91_cf_exit);

Expand Down

0 comments on commit b2b774b

Please sign in to comment.