source: GPL/trunk/include/linux/platform_device.h

Last change on this file was 679, checked in by David Azarewicz, 4 years ago

Merge changes from Paul's uniaud32next branch.

File size: 3.2 KB
Line 
1/* $Id: platform_device.h,v 1.1.1.1 2003/07/02 13:57:00 eleph Exp $ */
2
3#ifndef _LINUX_PLATFORM_DEVICE_H
4#define _LINUX_PLATFORM_DEVICE_H
5#include <linux/device.h>
6
7#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
8
9struct platform_device {
10 struct device dev;
11 const char *name;
12 int id;
13 struct list_head list;
14};
15
16#define to_platform_device(dev) ((struct platform_device *)(dev))
17
18extern struct bus_type snd_platform_bus_type;
19#define platform_device_register_simple snd_platform_device_register_simple
20#define platform_device_unregister snd_platform_device_unregister
21#define platform_bus_type snd_platform_bus_type
22
23struct platform_device *snd_platform_device_register_simple(const char *name, int id,
24 struct resource *res, int nres);
25
26static inline void snd_platform_device_unregister(struct platform_device *pdev)
27{
28 /* pdev gets freed in snd_compat_driver_unregister() */
29}
30
31#endif /* < 2.6.0 */
32
33struct platform_driver {
34 struct device_driver driver;
35 int (*probe)(struct platform_device *);
36 int (*remove)(struct platform_device *);
37 void (*shutdown)(struct platform_device *);
38 int (*suspend)(struct platform_device *, pm_message_t state);
39 int (*resume)(struct platform_device *);
40};
41
42static int snd_platform_driver_probe(struct device *dev)
43{
44 struct platform_driver *drv;
45 drv = (struct platform_driver *)dev->driver;
46 return drv->probe(to_platform_device(dev));
47}
48
49static int snd_platform_driver_remove(struct device *dev)
50{
51 struct platform_driver *drv;
52 drv = (struct platform_driver *)dev->driver;
53 return drv->remove(to_platform_device(dev));
54}
55
56static int snd_platform_driver_suspend(struct device *dev, pm_message_t state
57#ifdef CONFIG_SND_OLD_DRIVER_SUSPEND
58 , u32 level
59#endif
60 )
61{
62 struct platform_driver *drv;
63#ifdef CONFIG_SND_OLD_DRIVER_SUSPEND
64 if (level != SUSPEND_DISABLE)
65 return 0;
66#endif
67 drv = (struct platform_driver *)dev->driver;
68 return drv->suspend(to_platform_device(dev), state);
69}
70
71static int snd_platform_driver_resume(struct device *dev
72#ifdef CONFIG_SND_OLD_DRIVER_SUSPEND
73 , u32 level
74#endif
75 )
76{
77 struct platform_driver *drv;
78#ifdef CONFIG_SND_OLD_DRIVER_SUSPEND
79 if (level != RESUME_ENABLE)
80 return 0;
81#endif
82 drv = (struct platform_driver *)dev->driver;
83 return drv->resume(to_platform_device(dev));
84}
85
86static inline int platform_driver_register(struct platform_driver *drv)
87{
88#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
89 drv->driver.bus = &platform_bus_type;
90#endif
91 if (drv->probe)
92 drv->driver.probe = snd_platform_driver_probe;
93 if (drv->remove)
94 drv->driver.remove = snd_platform_driver_remove;
95 if (drv->suspend)
96 drv->driver.suspend = (int(*)(struct device *,unsigned int))snd_platform_driver_suspend;
97 if (drv->resume)
98 drv->driver.resume = snd_platform_driver_resume;
99 return driver_register(&drv->driver);
100}
101
102static inline void platform_driver_unregister(struct platform_driver *drv)
103{
104 driver_unregister(&drv->driver);
105}
106
107#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
108#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data))
109
110#endif /* _LINUX_PLATFORM_DEVICE_H */
Note: See TracBrowser for help on using the repository browser.