m68knommu: move ColdFire pit.c to its own coldfire directory
[wrt350n-kernel.git] / arch / arm / mach-integrator / lm.c
blob622cdc4212dd6f096ca7880f85d42334f0581da1
1 /*
2 * linux/arch/arm/mach-integrator/lm.c
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/device.h>
13 #include <linux/slab.h>
15 #include <asm/arch/lm.h>
17 #define to_lm_device(d) container_of(d, struct lm_device, dev)
18 #define to_lm_driver(d) container_of(d, struct lm_driver, drv)
20 static int lm_match(struct device *dev, struct device_driver *drv)
22 return 1;
25 static int lm_bus_probe(struct device *dev)
27 struct lm_device *lmdev = to_lm_device(dev);
28 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
30 return lmdrv->probe(lmdev);
33 static int lm_bus_remove(struct device *dev)
35 struct lm_device *lmdev = to_lm_device(dev);
36 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
38 if (lmdrv->remove)
39 lmdrv->remove(lmdev);
40 return 0;
43 static struct bus_type lm_bustype = {
44 .name = "logicmodule",
45 .match = lm_match,
46 .probe = lm_bus_probe,
47 .remove = lm_bus_remove,
48 // .suspend = lm_bus_suspend,
49 // .resume = lm_bus_resume,
52 static int __init lm_init(void)
54 return bus_register(&lm_bustype);
57 postcore_initcall(lm_init);
59 int lm_driver_register(struct lm_driver *drv)
61 drv->drv.bus = &lm_bustype;
62 return driver_register(&drv->drv);
65 void lm_driver_unregister(struct lm_driver *drv)
67 driver_unregister(&drv->drv);
70 static void lm_device_release(struct device *dev)
72 struct lm_device *d = to_lm_device(dev);
74 kfree(d);
77 int lm_device_register(struct lm_device *dev)
79 int ret;
81 dev->dev.release = lm_device_release;
82 dev->dev.bus = &lm_bustype;
84 snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id);
85 dev->resource.name = dev->dev.bus_id;
87 ret = request_resource(&iomem_resource, &dev->resource);
88 if (ret == 0) {
89 ret = device_register(&dev->dev);
90 if (ret)
91 release_resource(&dev->resource);
93 return ret;
96 EXPORT_SYMBOL(lm_driver_register);
97 EXPORT_SYMBOL(lm_driver_unregister);