1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-integrator/lm.c
5 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
7 #include <linux/module.h>
8 #include <linux/init.h>
9 #include <linux/device.h>
10 #include <linux/slab.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
)
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
);
40 static struct bus_type lm_bustype
= {
41 .name
= "logicmodule",
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
);
74 int lm_device_register(struct lm_device
*dev
)
78 dev
->dev
.release
= lm_device_release
;
79 dev
->dev
.bus
= &lm_bustype
;
81 ret
= dev_set_name(&dev
->dev
, "lm%d", dev
->id
);
84 dev
->resource
.name
= dev_name(&dev
->dev
);
86 ret
= request_resource(&iomem_resource
, &dev
->resource
);
88 ret
= device_register(&dev
->dev
);
90 release_resource(&dev
->resource
);
95 EXPORT_SYMBOL(lm_driver_register
);
96 EXPORT_SYMBOL(lm_driver_unregister
);