@@ -3,12 +3,12 @@
#include <linux/acpi.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -520,14 +520,13 @@ static int max98373_i2c_probe(struct i2c_client *i2c)
int ret = 0;
int reg = 0;
int i;
- struct max98373_priv *max98373 = NULL;
+ struct max98373_priv *max98373;
+ struct gpio_desc *reset_gpio;
max98373 = devm_kzalloc(&i2c->dev, sizeof(*max98373), GFP_KERNEL);
+ if (!max98373)
+ return -ENOMEM;
- if (!max98373) {
- ret = -ENOMEM;
- return ret;
- }
i2c_set_clientdata(i2c, max98373);
/* update interleave mode info */
@@ -557,17 +556,23 @@ static int max98373_i2c_probe(struct i2c_client *i2c)
max98373_slot_config(&i2c->dev, max98373);
/* Power on device */
- if (gpio_is_valid(max98373->reset_gpio)) {
- ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio,
- "MAX98373_RESET");
- if (ret) {
- dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
- __func__, max98373->reset_gpio);
- return -EINVAL;
- }
- gpio_direction_output(max98373->reset_gpio, 0);
+ /* Acquire and assert reset line */
+ reset_gpio = devm_gpiod_get_optional(&i2c->dev, "maxim,reset",
+ GPIOD_OUT_HIGH);
+ ret = PTR_ERR_OR_ZERO(reset_gpio);
+ if (ret) {
+ dev_err(&i2c->dev, "%s: Failed to request reset gpio: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ gpiod_set_consumer_name(reset_gpio, "MAX98373_RESET");
+
+ if (reset_gpio) {
+ /* Keep line asserted to reset device */
msleep(50);
- gpio_direction_output(max98373->reset_gpio, 1);
+ /* Deassert reset line */
+ gpiod_set_value_cansleep(reset_gpio, 0);
msleep(20);
}
@@ -12,9 +12,6 @@
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
-#include <linux/gpio.h>
-#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <sound/tlv.h>
#include "max98373.h"
@@ -478,21 +475,6 @@ void max98373_slot_config(struct device *dev,
max98373->i_slot = value & 0xF;
else
max98373->i_slot = 1;
- if (dev->of_node) {
- max98373->reset_gpio = of_get_named_gpio(dev->of_node,
- "maxim,reset-gpio", 0);
- if (!gpio_is_valid(max98373->reset_gpio)) {
- dev_err(dev, "Looking up %s property in node %s failed %d\n",
- "maxim,reset-gpio", dev->of_node->full_name,
- max98373->reset_gpio);
- } else {
- dev_dbg(dev, "maxim,reset-gpio=%d",
- max98373->reset_gpio);
- }
- } else {
- /* this makes reset_gpio as invalid */
- max98373->reset_gpio = -1;
- }
if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
max98373->spkfb_slot = value & 0xF;
@@ -213,7 +213,6 @@ struct max98373_cache {
struct max98373_priv {
struct regmap *regmap;
- int reset_gpio;
unsigned int v_slot;
unsigned int i_slot;
unsigned int spkfb_slot;
Switch the driver from legacy gpio API that is deprecated to the newer gpiod API that respects line polarities described in ACPI/DT. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> --- sound/soc/codecs/max98373-i2c.c | 39 +++++++++++++++++++-------------- sound/soc/codecs/max98373.c | 18 --------------- sound/soc/codecs/max98373.h | 1 - 3 files changed, 22 insertions(+), 36 deletions(-)