Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83b423c8 authored by Lee Jones's avatar Lee Jones Committed by Linus Walleij
Browse files

pinctrl/abx500: beautify the ABX500 pin control driver



This patch provides some superficial changes to the driver to
aid with readability and maintainability. We're mostly fixing
things like white-space errors, spreading out code which as
been clumped together impeding readability and comment layout,
such as using the new "/**" comment start for function headers
etc. No code semantics were harmed in the making of this patch.

Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 1abeebea
Loading
Loading
Loading
Loading
+59 −35
Original line number Diff line number Diff line
@@ -160,8 +160,10 @@ static int abx500_gpio_set_bits(struct gpio_chip *chip, u8 reg,
				AB8500_MISC, reg, BIT(pos), val << pos);
	if (ret < 0)
		dev_err(pct->dev, "%s write failed\n", __func__);

	return ret;
}

/**
 * abx500_gpio_get() - Get the particular GPIO value
 * @chip:	Gpio device
@@ -179,6 +181,7 @@ static int abx500_gpio_get(struct gpio_chip *chip, unsigned offset)
		dev_err(pct->dev, "%s failed\n", __func__);
		return ret;
	}

	return bit;
}

@@ -223,6 +226,7 @@ static int abx500_config_pull_updown(struct abx500_pinctrl *pct,
out:
	if (ret < 0)
		dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);

	return ret;
}

@@ -234,6 +238,7 @@ static int abx500_gpio_direction_output(struct gpio_chip *chip,
	struct pullud *pullud = pct->soc->pullud;
	unsigned gpio;
	int ret;

	/* set direction as output */
	ret = abx500_gpio_set_bits(chip, AB8500_GPIO_DIR1_REG, offset, 1);
	if (ret < 0)
@@ -253,6 +258,7 @@ static int abx500_gpio_direction_output(struct gpio_chip *chip,
		if (ret < 0)
			return ret;
	}

	/* set the output as 1 or 0 */
	return abx500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val);
}
@@ -291,6 +297,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
	int ret;
	int val;
	unsigned offset;

	const char *modes[] = {
		[ABX500_DEFAULT]	= "default",
		[ABX500_ALT_A]		= "altA",
@@ -309,6 +316,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,

	/* on ABx5xx, there is no GPIO0, so adjust the offset */
	offset = gpio - 1;

	switch (alt_setting) {
	case ABX500_DEFAULT:
		/*
@@ -324,6 +332,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
		ret = abx500_gpio_set_bits(chip, AB8500_GPIO_SEL1_REG,
					   offset, val);
		break;

	case ABX500_ALT_A:
		/*
		 * for ABx5xx family, alt_a mode is always selected by
@@ -348,6 +357,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
			ret = abx500_gpio_set_bits(chip, AB8500_GPIO_SEL1_REG,
					offset, 1);
		break;

	case ABX500_ALT_B:
		ret = abx500_gpio_set_bits(chip, AB8500_GPIO_SEL1_REG,
				offset, 0);
@@ -359,6 +369,7 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
					af.alt_bit2,
					!!(af.altb_val && BIT(1)));
		break;

	case ABX500_ALT_C:
		ret = abx500_gpio_set_bits(chip, AB8500_GPIO_SEL1_REG,
				offset, 0);
@@ -370,8 +381,10 @@ static int abx500_set_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,

	default:
		dev_dbg(pct->dev, "unknow alt_setting %d\n", alt_setting);

		return -EINVAL;
	}

	return ret;
}

@@ -404,6 +417,7 @@ static u8 abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
			"alt_bitX value not in correct range (-1 to 7)\n");
		return -EINVAL;
	}

	/* if alt_bit2 is used, alt_bit1 must be used too */
	if ((af.alt_bit2 != UNUSED) && (af.alt_bit1 == UNUSED)) {
		dev_err(pct->dev,
@@ -420,6 +434,7 @@ static u8 abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
	 */
	if (mode)
		return ABX500_DEFAULT;

	/*
	 * pin use the AlternatFunction register
	 * read alt_bit1 value
@@ -448,7 +463,8 @@ static u8 abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
#include <linux/seq_file.h>

static void abx500_gpio_dbg_show_one(struct seq_file *s,
	struct pinctrl_dev *pctldev, struct gpio_chip *chip,
				     struct pinctrl_dev *pctldev,
				     struct gpio_chip *chip,
				     unsigned offset, unsigned gpio)
{
	struct abx500_pinctrl *pct = to_abx500_pinctrl(chip);
@@ -457,6 +473,7 @@ static void abx500_gpio_dbg_show_one(struct seq_file *s,
	int mode = -1;
	bool is_out;
	bool pull;

	const char *modes[] = {
		[ABX500_DEFAULT]	= "default",
		[ABX500_ALT_A]		= "altA",
@@ -851,6 +868,7 @@ static int abx500_pmx_enable(struct pinctrl_dev *pctldev, unsigned function,
		abx500_disable_lazy_irq(chip, g->pins[i]);
		ret = abx500_set_mode(pctldev, chip, g->pins[i], g->altsetting);
	}

	return ret;
}

@@ -947,6 +965,7 @@ static int abx500_get_group_pins(struct pinctrl_dev *pctldev,

	*pins = pct->soc->groups[selector].pins;
	*num_pins = pct->soc->groups[selector].npins;

	return 0;
}

@@ -990,6 +1009,7 @@ int abx500_pin_config_set(struct pinctrl_dev *pctldev,
		pin, config, (param == PIN_CONFIG_OUTPUT) ? "output " : "input",
		(param == PIN_CONFIG_OUTPUT) ? (argument ? "high" : "low") :
		(argument ? "pull up" : "pull down"));

	/* on ABx500, there is no GPIO0, so adjust the offset */
	offset = pin - 1;

@@ -1018,13 +1038,18 @@ int abx500_pin_config_set(struct pinctrl_dev *pctldev,
			ret = abx500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG,
				offset, argument ? 0 : 1);
		break;

	case PIN_CONFIG_OUTPUT:
		ret = abx500_gpio_direction_output(chip, offset, argument);

		break;

	default:
		dev_err(chip->dev, "illegal configuration requested\n");

		return -EINVAL;
	}

	return ret;
}

@@ -1150,8 +1175,7 @@ static int abx500_gpio_probe(struct platform_device *pdev)
		goto out_free;
	ret = gpiochip_add(&pct->chip);
	if (ret) {
		dev_err(&pdev->dev, "unable to add gpiochip: %d\n",
				ret);
		dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
		goto out_rem_irq;
	}
	dev_info(&pdev->dev, "added gpiochip\n");
@@ -1193,7 +1217,7 @@ out_free:
	return ret;
}

/*
/**
 * abx500_gpio_remove() - remove Ab8500-gpio driver
 * @pdev:	Platform device registered
 */