Linux 5.7.7
[linux/fpc-iii.git] / arch / arm / mach-integrator / lm.c
blob55cd173d1d763ef91ea7b64823357d5db7ea23ad
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/arch/arm/mach-integrator/lm.c
5 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
6 */
7 #include <linux/module.h>
8 #include <linux/init.h>
9 #include <linux/device.h>
10 #include <linux/slab.h>
12 #include "lm.h"
14 #define to_lm_device(d) container_of(d, struct lm_device, dev)
15 #define to_lm_driver(d) container_of(d, struct lm_driver, drv)
17 static int lm_match(struct device *dev, struct device_driver *drv)
19 return 1;
22 static int lm_bus_probe(struct device *dev)
24 struct lm_device *lmdev = to_lm_device(dev);
25 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
27 return lmdrv->probe(lmdev);
30 static int lm_bus_remove(struct device *dev)
32 struct lm_device *lmdev = to_lm_device(dev);
33 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
35 if (lmdrv->remove)
36 lmdrv->remove(lmdev);
37 return 0;
40 static struct bus_type lm_bustype = {
41 .name = "logicmodule",
42 .match = lm_match,
43 .probe = lm_bus_probe,
44 .remove = lm_bus_remove,
45 // .suspend = lm_bus_suspend,
46 // .resume = lm_bus_resume,
49 static int __init lm_init(void)
51 return bus_register(&lm_bustype);
54 postcore_initcall(lm_init);
56 int lm_driver_register(struct lm_driver *drv)
58 drv->drv.bus = &lm_bustype;
59 return driver_register(&drv->drv);
62 void lm_driver_unregister(struct lm_driver *drv)
64 driver_unregister(&drv->drv);
67 static void lm_device_release(struct device *dev)
69 struct lm_device *d = to_lm_device(dev);
71 kfree(d);
74 int lm_device_register(struct lm_device *dev)
76 int ret;
78 dev->dev.release = lm_device_release;
79 dev->dev.bus = &lm_bustype;
81 ret = dev_set_name(&dev->dev, "lm%d", dev->id);
82 if (ret)
83 return ret;
84 dev->resource.name = dev_name(&dev->dev);
86 ret = request_resource(&iomem_resource, &dev->resource);
87 if (ret == 0) {
88 ret = device_register(&dev->dev);
89 if (ret)
90 release_resource(&dev->resource);
92 return ret;
95 EXPORT_SYMBOL(lm_driver_register);
96 EXPORT_SYMBOL(lm_driver_unregister);