[alsa-devel] [PATCH 3/4] ASoC: ts3a227e: add platform data for ts3a227e driver

yang.a.fang at intel.com yang.a.fang at intel.com
Thu Apr 30 03:43:57 CEST 2015


From: "Fang, Yang A" <yang.a.fang at intel.com>

make irq flag part of platform data

Signed-off-by: Fang, Yang A <yang.a.fang at intel.com>
---
 include/sound/ts3a227e.h    |   19 +++++++++++++++++++
 sound/soc/codecs/ts3a227e.c |    9 ++++++++-
 sound/soc/codecs/ts3a227e.h |    2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 include/sound/ts3a227e.h

diff --git a/include/sound/ts3a227e.h b/include/sound/ts3a227e.h
new file mode 100644
index 0000000..c005084
--- /dev/null
+++ b/include/sound/ts3a227e.h
@@ -0,0 +1,19 @@
+/*
+ * Platform data for TS3A227E
+ *
+ * Copyright (C) 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_TS3A227E_H
+#define __LINUX_SND_TS3A227E_H
+
+struct ts3a227e_platform_data {
+
+	unsigned long irqflag;
+};
+
+#endif
diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 9fd80ac..422f66f 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -25,6 +25,7 @@
 struct ts3a227e {
 	struct regmap *regmap;
 	struct snd_soc_jack *jack;
+	struct ts3a227e_platform_data pdata;
 	bool plugged;
 	bool mic_present;
 	unsigned int buttons_held;
@@ -274,6 +275,7 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 {
 	struct ts3a227e *ts3a227e;
 	struct device *dev = &i2c->dev;
+	struct ts3a227e_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	int ret;
 	unsigned int acc_reg;
 
@@ -283,6 +285,11 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, ts3a227e);
 
+	ts3a227e->pdata.irqflag = IRQF_TRIGGER_LOW | IRQF_ONESHOT;
+
+	if (pdata)
+		ts3a227e->pdata = *pdata;
+
 	ts3a227e->regmap = devm_regmap_init_i2c(i2c, &ts3a227e_regmap_config);
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
@@ -296,7 +303,7 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
-					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+					ts3a227e->pdata.irqflag,
 					"TS3A227E", ts3a227e);
 	if (ret) {
 		dev_err(dev, "Cannot request irq %d (%d)\n", i2c->irq, ret);
diff --git a/sound/soc/codecs/ts3a227e.h b/sound/soc/codecs/ts3a227e.h
index e2acf9c..a587a72 100644
--- a/sound/soc/codecs/ts3a227e.h
+++ b/sound/soc/codecs/ts3a227e.h
@@ -11,6 +11,8 @@
 #ifndef _TS3A227E_H
 #define _TS3A227E_H
 
+#include <sound/ts3a227e.h>
+
 int ts3a227e_enable_jack_detect(struct snd_soc_component *component,
 				struct snd_soc_jack *jack);
 
-- 
1.7.9.5



More information about the Alsa-devel mailing list