*
*/
+#include <linux/kernel.h>
+#include <linux/module.h>
#include <linux/init.h>
+
+#include <linux/input.h>
#include <linux/input-polldev.h>
#include <linux/ioport.h>
-#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/gpio_buttons.h>
#include <asm/gpio.h>
#define DRV_NAME "gpio-buttons"
-#define DRV_VERSION "0.1.0"
+#define DRV_VERSION "0.1.1"
#define PFX DRV_NAME ": "
struct gpio_buttons_dev {
bdev = kzalloc(sizeof(*bdev), GFP_KERNEL);
if (!bdev) {
- pr_err(DRV_NAME "no memory for device\n");
+ printk(KERN_ERR DRV_NAME "no memory for device\n");
return -ENOMEM;
}
poll_dev = input_allocate_polled_device();
if (!poll_dev) {
- pr_err(DRV_NAME "no memory for polled device\n");
+ printk(KERN_ERR DRV_NAME "no memory for polled device\n");
error = -ENOMEM;
goto err_free_bdev;
}
input = poll_dev->input;
- input->evbit[0] = BIT_MASK(EV_KEY);
+ input->evbit[0] = BIT(EV_KEY);
input->name = pdev->name;
input->phys = "gpio-buttons/input0";
input->dev.parent = &pdev->dev;
error = gpio_request(gpio, button->desc ?
button->desc : DRV_NAME);
if (error) {
- pr_err(PFX "unable to claim gpio %u, error %d\n",
- gpio, error);
+ printk(KERN_ERR PFX "unable to claim gpio %u, "
+ "error %d\n", gpio, error);
goto err_free_gpio;
}
error = gpio_direction_input(gpio);
if (error) {
- pr_err(PFX "unable to set direction on gpio %u, "
- "error %d\n", gpio, error);
+ printk(KERN_ERR PFX "unable to set direction on "
+ "gpio %u, error %d\n", gpio, error);
goto err_free_gpio;
}
error = input_register_polled_device(poll_dev);
if (error) {
- pr_err(PFX "unable to register polled device, error %d\n",
- error);
+ printk(KERN_ERR PFX "unable to register polled device, "
+ "error %d\n", error);
goto err_free_gpio;
}
err_free_bdev:
kfree(bdev);
-err:
+
platform_set_drvdata(pdev, NULL);
return error;
}
static int __init gpio_buttons_init(void)
{
- pr_info(DRV_NAME " driver version " DRV_VERSION "\n");
+ printk(KERN_INFO DRV_NAME " driver version " DRV_VERSION "\n");
return platform_driver_register(&gpio_buttons_driver);
}