Skip to contentSkip to conversation

intel_mid_powerbtn: add power button driver for Medfield platform

PATCH In review Alan Cox 2 participants 2 messages Jan 26, 2011 x86 platform drivers

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 intel_mid_powerbtn: add power button driver for Medfield platform

From: Hong Liu <[email protected]>

The power button is connected to MSIC on Medfield, we will get two interrupts from IOAPIC when pressing or releasing the power button.

[Minor fixes as noted by Dmitry]

---

 drivers/platform/x86/Kconfig              |    8 ++
 drivers/platform/x86/Makefile             |    2 
 drivers/platform/x86/intel_mid_powerbtn.c |  143 +++++++++++++++++++++++++++++
 3 files changed, 153 insertions(+), 0 deletions(-)
 create mode 100644 drivers/platform/x86/intel_mid_powerbtn.c
drivers/platform/x86/Kconfig +8 -0
index d163bc2..95817b0 100644
@@ -654,4 +654,12 @@ config XO1_RFKILL
 	  Support for enabling/disabling the WLAN interface on the OLPC XO-1
 	  laptop.
 
+config INTEL_MID_POWER_BUTTON
+	tristate "power button driver for Intel MID platforms"
+	depends on INTEL_SCU_IPC
+	help
+	  This driver handles the power button on the Intel MID platforms.
+
+	  If unsure, say N.
+
 endif # X86_PLATFORM_DEVICES
drivers/platform/x86/Makefile +2 -0
index 4ec4ff8..a24cd62 100644
@@ -34,3 +34,5 @@ obj-$(CONFIG_INTEL_IPS)		+= intel_ips.o
 obj-$(CONFIG_GPIO_INTEL_PMIC)	+= intel_pmic_gpio.o
 obj-$(CONFIG_XO1_RFKILL)	+= xo1-rfkill.o
 obj-$(CONFIG_IBM_RTL)		+= ibm_rtl.o
+obj-$(CONFIG_INTEL_MID_POWER_BUTTON)	+= intel_mid_powerbtn.o
+
drivers/platform/x86/intel_mid_powerbtn.c new file +143 -0

143 lines not on this page · raw message

#1 lore raw
Quoted 14 lines · Alan Cox
drivers/platform/x86/intel_mid_powerbtn.c new file +14 -0
+
+	ret = request_threaded_irq(priv->irq, NULL, mfld_pb_isr,
+				   0, DRIVER_NAME, priv);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"unable to request irq %d for mfld power button\n",
+									irq);
+		goto fail;
+	}
+
+	ret = input_register_device(input);
+	if (ret == 0)
+		return 0;
+

drivers/platform/x86/intel_mid_powerbtn.c line 107

Quoted 10 lines
drivers/platform/x86/intel_mid_powerbtn.c new file +10 -0
+	dev_err(&pdev->dev, "unable to register input dev, error %d\n", ret);
+	free_irq(priv->irq, priv);
+
+fail:
+	platform_set_drvdata(pdev, NULL);
+	input_free_device(input);
+	kfree(priv);
+	return ret;
+}
+

Ugh, mixing 2 styles of error handling like this is not the best idea IMO. Could you please adjust so that all error handling branches out of line, like virtually every other driver we have in the tree?

Thanks.

Signature · 1 line
Dmitry