diff options
Diffstat (limited to 'drivers/pinctrl/vt8500/pinctrl-wmt.c')
| -rw-r--r-- | drivers/pinctrl/vt8500/pinctrl-wmt.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index c207e60b734f..7213a8d4bf09 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c @@ -1,16 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Pinctrl driver for the Wondermedia SoC's * * Copyright (c) 2013 Tony Prisk <linux@prisktech.co.nz> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. */ #include <linux/err.h> @@ -163,7 +155,7 @@ static int wmt_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, return 0; } -static struct pinmux_ops wmt_pinmux_ops = { +static const struct pinmux_ops wmt_pinmux_ops = { .get_functions_count = wmt_pmx_get_functions_count, .get_function_name = wmt_pmx_get_function_name, .get_function_groups = wmt_pmx_get_function_groups, @@ -352,7 +344,7 @@ static int wmt_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, if (num_pulls) maps_per_pin++; - cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps), + cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps), GFP_KERNEL); if (!maps) return -ENOMEM; @@ -409,7 +401,7 @@ fail: return err; } -static struct pinctrl_ops wmt_pctl_ops = { +static const struct pinctrl_ops wmt_pctl_ops = { .get_groups_count = wmt_get_groups_count, .get_group_name = wmt_get_group_name, .get_group_pins = wmt_get_group_pins, @@ -472,7 +464,7 @@ static int wmt_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin, return 0; } -static struct pinconf_ops wmt_pinconf_ops = { +static const struct pinconf_ops wmt_pinconf_ops = { .pin_config_get = wmt_pinconf_get, .pin_config_set = wmt_pinconf_set, }; @@ -495,9 +487,9 @@ static int wmt_gpio_get_direction(struct gpio_chip *chip, unsigned offset) val = readl_relaxed(data->base + reg_dir); if (val & BIT(bit)) - return GPIOF_DIR_OUT; - else - return GPIOF_DIR_IN; + return GPIO_LINE_DIRECTION_OUT; + + return GPIO_LINE_DIRECTION_IN; } static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) @@ -515,8 +507,8 @@ static int wmt_gpio_get_value(struct gpio_chip *chip, unsigned offset) return !!(readl_relaxed(data->base + reg_data_in) & BIT(bit)); } -static void wmt_gpio_set_value(struct gpio_chip *chip, unsigned offset, - int val) +static int wmt_gpio_set_value(struct gpio_chip *chip, unsigned int offset, + int val) { struct wmt_pinctrl_data *data = gpiochip_get_data(chip); u32 bank = WMT_BANK_FROM_PIN(offset); @@ -525,34 +517,36 @@ static void wmt_gpio_set_value(struct gpio_chip *chip, unsigned offset, if (reg_data_out == NO_REG) { dev_err(data->dev, "no data out register defined\n"); - return; + return -EINVAL; } if (val) wmt_setbits(data, reg_data_out, BIT(bit)); else wmt_clearbits(data, reg_data_out, BIT(bit)); -} -static int wmt_gpio_direction_input(struct gpio_chip *chip, unsigned offset) -{ - return pinctrl_gpio_direction_input(chip->base + offset); + return 0; } static int wmt_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int value) { - wmt_gpio_set_value(chip, offset, value); - return pinctrl_gpio_direction_output(chip->base + offset); + int ret; + + ret = wmt_gpio_set_value(chip, offset, value); + if (ret) + return ret; + + return pinctrl_gpio_direction_output(chip, offset); } -static struct gpio_chip wmt_gpio_chip = { +static const struct gpio_chip wmt_gpio_chip = { .label = "gpio-wmt", .owner = THIS_MODULE, .request = gpiochip_generic_request, .free = gpiochip_generic_free, .get_direction = wmt_gpio_get_direction, - .direction_input = wmt_gpio_direction_input, + .direction_input = pinctrl_gpio_direction_input, .direction_output = wmt_gpio_direction_output, .get = wmt_gpio_get_value, .set = wmt_gpio_set_value, @@ -563,10 +557,8 @@ int wmt_pinctrl_probe(struct platform_device *pdev, struct wmt_pinctrl_data *data) { int err; - struct resource *res; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->base = devm_ioremap_resource(&pdev->dev, res); + data->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(data->base)) return PTR_ERR(data->base); @@ -575,7 +567,6 @@ int wmt_pinctrl_probe(struct platform_device *pdev, data->gpio_chip = wmt_gpio_chip; data->gpio_chip.parent = &pdev->dev; - data->gpio_chip.of_node = pdev->dev.of_node; data->gpio_chip.ngpio = data->nbanks * 32; platform_set_drvdata(pdev, data); |
