???????豸???
????1 int platform_device_register(struct platform_device *pdev);
????platform_device_register()??????豸???????????????????platform_device_register()?????????????????С?
???????豸?????
????1 void platform_device_unregister(struct platform_device *pdev);
????platform_device_unregister()????????豸????????????н????????
???????豸??壺
1staticstructresourcexxx_resource=
2{
3[0]=
4{
5.start=...??
6.end=...??
7.flags=...??
8}??
9[1]=
10{
11...
12}
13...
14};
15
16staticstructxxx_plat_dataxxx_data=
17{
18...
19};
20
21staticstructplatform_devicexxx_platform_device=
22{
23.name=NAME??
24.num_resources=ARRAY_SIZE(xxx_resource)??
25.resource=xxx_resource??
26.dev=
27{
28.platform_data=&xxx_data??
29}
30};
31
32staticint__initxxx_device_init(void)
33{
34...
35/*??????豸*/
36platform_device_register(&xxx_platform_device);
37...
38}
39
40staticvoid__exitxxx_device_exit(void)
41{
42...
43/*??????豸*/
44platform_device_unregister(&xxx_platform_device);
45...
46}
??????????????
?????????????壺
????1 struct platform_driver {
????2     int (*probe)(struct platform_device *);
????3     int (*remove)(struct platform_device *);
????4     void (*shutdown)(struct platform_device *);
????5     int (*suspend)(struct platform_device *?? pm_message_t state);
????6     int (*resume)(struct platform_device *);
????7     struct device_driver driver;
????8     const struct platform_device_id *id_table;
????9 };
??????????????driver????????name?????????豸?????????name?????£????????????豸???????????豸?????????name???????????driver?????name??????????????????????????probe??????
?????????probe?????л?????豸????????????????????豸????????
????????豸?????
????1 struct resource *platform_get_resource(struct platform_device *dev?? unsigned int type?? unsigned int num);
????platform_get_resource()?????????????豸???????dev?????豸??type????豸????????num????????(?????????????????????????0??1)??
?????????????
????1 int platform_driver_register(struct platform_driver *drv);
????platform_driver_register()??????????????????????????????????á?
???????????????
????1 void platform_driver_unregister(struct platform_driver *drv);
????platform_driver_unregister()?????????????????????????????ж??????á?
????????????壺
1 static int __devinit xxx_probe(struct platform_device *pdev)
2 {
3     struct xxx_plat_data *pdata = pdev->dev.platform_data;    /* ?????????? */
4     platform_get_resource(pdev??xxx??x);                        /* ????豸??? */
5     ...
6 }
7
8 static struct platform_driver xxx_platform_driver =
9 {
10     .probe = xxx_probe??
11     .remove = __devexit_p(xxx_remove)??
12     .driver =
13     {
14         .name = NAME??    /* ?????豸????? */
15         ...
16     }??
17     ...
18 };
19
20 static int __init xxx_driver_init(void)
21 {
22     ...
23     /* ??????? */
24     platform_driver_register(&xxx_platform_driver);
25     ...
26 }
27
28 static void __exit xxx_driver_exit(void)
29 {
30     ...
31     /* ??????? */
32     platform_driver_unregister(&xxx_platform_driver);
33     ...
34 }