Skip to contentSkip to conversation

ONKEY: OnKey module for DA9052/53 PMIC v1

PATCH In review Ashish Jangam 2 participants 2 messages Jan 17, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 7/7 ONKEY: OnKey module for DA9052/53 PMIC v1

On-key Driver for Dialog Semiconductor DA9052 PMICs.

---
 drivers/input/misc/Kconfig        |   10 ++
 drivers/input/misc/Makefile       |    1 +
 drivers/input/misc/da9052_onkey.c |  180 +++++++++++++++++++++++++++++++++++++
 3 files changed, 191 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/misc/da9052_onkey.c
drivers/input/misc/Kconfig +10 -0
index 7b46781..c123fbe 100644
@@ -455,6 +455,16 @@ config INPUT_RB532_BUTTON
 	  To compile this driver as a module, choose M here: the
 	  module will be called rb532_button.
 
+config INPUT_DA9052_ONKEY
+	tristate "Dialog DA9052 Onkey"
+	depends on PMIC_DA9052
+	help
+	  Support the ONKEY of Dialog DA9052 PMICs as an input device
+	  reporting power button status.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called da9052_onkey.
+
 config INPUT_DM355EVM
 	tristate "TI DaVinci DM355 EVM Keypad and IR Remote"
 	depends on MFD_DM355EVM_MSP
drivers/input/misc/Makefile +1 -0
index 46671a8..a6d8de0 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_CM109)		+= cm109.o
 obj-$(CONFIG_INPUT_CMA3000)		+= cma3000_d0x.o
 obj-$(CONFIG_INPUT_CMA3000_I2C)		+= cma3000_d0x_i2c.o
 obj-$(CONFIG_INPUT_COBALT_BTNS)		+= cobalt_btns.o
+obj-$(CONFIG_INPUT_DA9052_ONKEY)	+= da9052_onkey.o
 obj-$(CONFIG_INPUT_DM355EVM)		+= dm355evm_keys.o
 obj-$(CONFIG_INPUT_GP2A)		+= gp2ap002a00f.o
 obj-$(CONFIG_INPUT_GPIO_TILT_POLLED)	+= gpio_tilt_polled.o
drivers/input/misc/da9052_onkey.c new file +180 -0

180 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Ashish Jangam
drivers/input/misc/da9052_onkey.c new file +4 -0
+	ret = da9052_reg_read(onkey->da9052, DA9052_EVENT_B_REG);
+	if (ret < 0) {
+		dev_err(onkey->da9052->dev,
+			"da9052_onkey_report_event da9052_reg_read error %d\n",

drivers/input/misc/da9052_onkey.c line 47

Quoted 10 lines
drivers/input/misc/da9052_onkey.c new file +10 -0
+			ret);
+		ret = 1;
+	} else {
+		ret = ret & DA9052_EVENTB_ENONKEY;
+		input_report_key(onkey->input, KEY_POWER, ret);
+		input_sync(onkey->input);
+	}
+
+	if (ret)
+		schedule_delayed_work(&onkey->work, msecs_to_jiffies(50));

Why not just schedule the work directly? The use of ret took a bit of thinking about to follow.

drivers/input/misc/da9052_onkey.c line 76

Quoted 11 lines
drivers/input/misc/da9052_onkey.c new file +11 -0
+
+static int __devinit da9052_onkey_probe(struct platform_device *pdev)
+{
+	struct da9052_onkey *onkey;
+	int error;
+
+	onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
+	if (!onkey) {
+		dev_err(&pdev->dev, "Failed to allocate memory\n");
+		return -ENOMEM;
+	}

devm_kzalloc()

drivers/input/misc/da9052_onkey.c line 96

Quoted 3 lines
drivers/input/misc/da9052_onkey.c new file +3 -0
+	onkey->irq = platform_get_irq_byname(pdev, "ONKEY");
+	if (onkey->irq < 0) {
+		error = -ENXIO;

platform_get_irq_byname() returned an error code, you should normallypass it back.

drivers/input/misc/da9052_onkey.c line 112

Quoted 2 lines
drivers/input/misc/da9052_onkey.c new file +2 -0
+	error = request_threaded_irq(onkey->da9052->irq_base + onkey->irq, NULL,
+				     da9052_onkey_irq,

This looks buggy, the resource should have the IRQ you need directly in it. The MFD core can do this for the chip core driver when it registers children.

drivers/input/misc/da9052_onkey.c line 175

Quoted 11 lines
drivers/input/misc/da9052_onkey.c new file +11 -0
+static int __init da9052_onkey_init(void)
+{
+	return platform_driver_register(&da9052_onkey_driver);
+}
+module_init(da9052_onkey_init);
+
+static void __exit da9052_onkey_exit(void)
+{
+	platform_driver_unregister(&da9052_onkey_driver);
+}
+module_exit(da9052_onkey_exit);

Use module_platform_driver.