]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - arch/arm/mach-integrator/lm.c
UBUNTU: Ubuntu-5.3.0-29.31
[mirror_ubuntu-eoan-kernel.git] / arch / arm / mach-integrator / lm.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/arch/arm/mach-integrator/lm.c
4 *
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>
11
12 #include "lm.h"
13
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)
16
17 static int lm_match(struct device *dev, struct device_driver *drv)
18 {
19 return 1;
20 }
21
22 static int lm_bus_probe(struct device *dev)
23 {
24 struct lm_device *lmdev = to_lm_device(dev);
25 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
26
27 return lmdrv->probe(lmdev);
28 }
29
30 static int lm_bus_remove(struct device *dev)
31 {
32 struct lm_device *lmdev = to_lm_device(dev);
33 struct lm_driver *lmdrv = to_lm_driver(dev->driver);
34
35 if (lmdrv->remove)
36 lmdrv->remove(lmdev);
37 return 0;
38 }
39
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,
47 };
48
49 static int __init lm_init(void)
50 {
51 return bus_register(&lm_bustype);
52 }
53
54 postcore_initcall(lm_init);
55
56 int lm_driver_register(struct lm_driver *drv)
57 {
58 drv->drv.bus = &lm_bustype;
59 return driver_register(&drv->drv);
60 }
61
62 void lm_driver_unregister(struct lm_driver *drv)
63 {
64 driver_unregister(&drv->drv);
65 }
66
67 static void lm_device_release(struct device *dev)
68 {
69 struct lm_device *d = to_lm_device(dev);
70
71 kfree(d);
72 }
73
74 int lm_device_register(struct lm_device *dev)
75 {
76 int ret;
77
78 dev->dev.release = lm_device_release;
79 dev->dev.bus = &lm_bustype;
80
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);
85
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);
91 }
92 return ret;
93 }
94
95 EXPORT_SYMBOL(lm_driver_register);
96 EXPORT_SYMBOL(lm_driver_unregister);