include: replace linux/module.h with "struct module" wherever possible
[linux-2.6/next.git] / drivers / platform / x86 / xo1-rfkill.c
blobe549eeeda121fb28829807899307ace2491a0e4f
1 /*
2 * Support for rfkill through the OLPC XO-1 laptop embedded controller
4 * Copyright (C) 2010 One Laptop per Child
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/module.h>
13 #include <linux/platform_device.h>
14 #include <linux/rfkill.h>
16 #include <asm/olpc.h>
18 static int rfkill_set_block(void *data, bool blocked)
20 unsigned char cmd;
21 if (blocked)
22 cmd = EC_WLAN_ENTER_RESET;
23 else
24 cmd = EC_WLAN_LEAVE_RESET;
26 return olpc_ec_cmd(cmd, NULL, 0, NULL, 0);
29 static const struct rfkill_ops rfkill_ops = {
30 .set_block = rfkill_set_block,
33 static int __devinit xo1_rfkill_probe(struct platform_device *pdev)
35 struct rfkill *rfk;
36 int r;
38 rfk = rfkill_alloc(pdev->name, &pdev->dev, RFKILL_TYPE_WLAN,
39 &rfkill_ops, NULL);
40 if (!rfk)
41 return -ENOMEM;
43 r = rfkill_register(rfk);
44 if (r) {
45 rfkill_destroy(rfk);
46 return r;
49 platform_set_drvdata(pdev, rfk);
50 return 0;
53 static int __devexit xo1_rfkill_remove(struct platform_device *pdev)
55 struct rfkill *rfk = platform_get_drvdata(pdev);
56 rfkill_unregister(rfk);
57 rfkill_destroy(rfk);
58 return 0;
61 static struct platform_driver xo1_rfkill_driver = {
62 .driver = {
63 .name = "xo1-rfkill",
64 .owner = THIS_MODULE,
66 .probe = xo1_rfkill_probe,
67 .remove = __devexit_p(xo1_rfkill_remove),
70 static int __init xo1_rfkill_init(void)
72 return platform_driver_register(&xo1_rfkill_driver);
75 static void __exit xo1_rfkill_exit(void)
77 platform_driver_unregister(&xo1_rfkill_driver);
80 MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>");
81 MODULE_LICENSE("GPL");
82 MODULE_ALIAS("platform:xo1-rfkill");
84 module_init(xo1_rfkill_init);
85 module_exit(xo1_rfkill_exit);