gpio: gpiolib: Normalize return code variable name
It is confusing to name return variables mixedly "status", "err" or "ret". I just changed them all to "ret", by personal preference, to lower cognitive stress. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20190716091145.8235-1-linus.walleij@linaro.org
This commit is contained in:
parent
d2b0919615
commit
d377f56f34
1 changed files with 110 additions and 110 deletions
|
@ -214,7 +214,7 @@ int gpiod_get_direction(struct gpio_desc *desc)
|
||||||
{
|
{
|
||||||
struct gpio_chip *chip;
|
struct gpio_chip *chip;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
int status;
|
int ret;
|
||||||
|
|
||||||
chip = gpiod_to_chip(desc);
|
chip = gpiod_to_chip(desc);
|
||||||
offset = gpio_chip_hwgpio(desc);
|
offset = gpio_chip_hwgpio(desc);
|
||||||
|
@ -222,17 +222,17 @@ int gpiod_get_direction(struct gpio_desc *desc)
|
||||||
if (!chip->get_direction)
|
if (!chip->get_direction)
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
status = chip->get_direction(chip, offset);
|
ret = chip->get_direction(chip, offset);
|
||||||
if (status > 0) {
|
if (ret > 0) {
|
||||||
/* GPIOF_DIR_IN, or other positive */
|
/* GPIOF_DIR_IN, or other positive */
|
||||||
status = 1;
|
ret = 1;
|
||||||
clear_bit(FLAG_IS_OUT, &desc->flags);
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
}
|
}
|
||||||
if (status == 0) {
|
if (ret == 0) {
|
||||||
/* GPIOF_DIR_OUT */
|
/* GPIOF_DIR_OUT */
|
||||||
set_bit(FLAG_IS_OUT, &desc->flags);
|
set_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
}
|
}
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gpiod_get_direction);
|
EXPORT_SYMBOL_GPL(gpiod_get_direction);
|
||||||
|
|
||||||
|
@ -1166,21 +1166,21 @@ static void gpiodevice_release(struct device *dev)
|
||||||
|
|
||||||
static int gpiochip_setup_dev(struct gpio_device *gdev)
|
static int gpiochip_setup_dev(struct gpio_device *gdev)
|
||||||
{
|
{
|
||||||
int status;
|
int ret;
|
||||||
|
|
||||||
cdev_init(&gdev->chrdev, &gpio_fileops);
|
cdev_init(&gdev->chrdev, &gpio_fileops);
|
||||||
gdev->chrdev.owner = THIS_MODULE;
|
gdev->chrdev.owner = THIS_MODULE;
|
||||||
gdev->dev.devt = MKDEV(MAJOR(gpio_devt), gdev->id);
|
gdev->dev.devt = MKDEV(MAJOR(gpio_devt), gdev->id);
|
||||||
|
|
||||||
status = cdev_device_add(&gdev->chrdev, &gdev->dev);
|
ret = cdev_device_add(&gdev->chrdev, &gdev->dev);
|
||||||
if (status)
|
if (ret)
|
||||||
return status;
|
return ret;
|
||||||
|
|
||||||
chip_dbg(gdev->chip, "added GPIO chardev (%d:%d)\n",
|
chip_dbg(gdev->chip, "added GPIO chardev (%d:%d)\n",
|
||||||
MAJOR(gpio_devt), gdev->id);
|
MAJOR(gpio_devt), gdev->id);
|
||||||
|
|
||||||
status = gpiochip_sysfs_register(gdev);
|
ret = gpiochip_sysfs_register(gdev);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_device;
|
goto err_remove_device;
|
||||||
|
|
||||||
/* From this point, the .release() function cleans up gpio_device */
|
/* From this point, the .release() function cleans up gpio_device */
|
||||||
|
@ -1193,7 +1193,7 @@ static int gpiochip_setup_dev(struct gpio_device *gdev)
|
||||||
|
|
||||||
err_remove_device:
|
err_remove_device:
|
||||||
cdev_device_del(&gdev->chrdev, &gdev->dev);
|
cdev_device_del(&gdev->chrdev, &gdev->dev);
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gpiochip_machine_hog(struct gpio_chip *chip, struct gpiod_hog *hog)
|
static void gpiochip_machine_hog(struct gpio_chip *chip, struct gpiod_hog *hog)
|
||||||
|
@ -1234,13 +1234,13 @@ static void machine_gpiochip_add(struct gpio_chip *chip)
|
||||||
static void gpiochip_setup_devs(void)
|
static void gpiochip_setup_devs(void)
|
||||||
{
|
{
|
||||||
struct gpio_device *gdev;
|
struct gpio_device *gdev;
|
||||||
int err;
|
int ret;
|
||||||
|
|
||||||
list_for_each_entry(gdev, &gpio_devices, list) {
|
list_for_each_entry(gdev, &gpio_devices, list) {
|
||||||
err = gpiochip_setup_dev(gdev);
|
ret = gpiochip_setup_dev(gdev);
|
||||||
if (err)
|
if (ret)
|
||||||
pr_err("%s: Failed to initialize gpio device (%d)\n",
|
pr_err("%s: Failed to initialize gpio device (%d)\n",
|
||||||
dev_name(&gdev->dev), err);
|
dev_name(&gdev->dev), ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,7 +1249,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
struct lock_class_key *request_key)
|
struct lock_class_key *request_key)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int status = 0;
|
int ret = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int base = chip->base;
|
int base = chip->base;
|
||||||
struct gpio_device *gdev;
|
struct gpio_device *gdev;
|
||||||
|
@ -1279,7 +1279,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
|
|
||||||
gdev->id = ida_simple_get(&gpio_ida, 0, 0, GFP_KERNEL);
|
gdev->id = ida_simple_get(&gpio_ida, 0, 0, GFP_KERNEL);
|
||||||
if (gdev->id < 0) {
|
if (gdev->id < 0) {
|
||||||
status = gdev->id;
|
ret = gdev->id;
|
||||||
goto err_free_gdev;
|
goto err_free_gdev;
|
||||||
}
|
}
|
||||||
dev_set_name(&gdev->dev, "gpiochip%d", gdev->id);
|
dev_set_name(&gdev->dev, "gpiochip%d", gdev->id);
|
||||||
|
@ -1295,13 +1295,13 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
|
|
||||||
gdev->descs = kcalloc(chip->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
|
gdev->descs = kcalloc(chip->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
|
||||||
if (!gdev->descs) {
|
if (!gdev->descs) {
|
||||||
status = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_free_ida;
|
goto err_free_ida;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip->ngpio == 0) {
|
if (chip->ngpio == 0) {
|
||||||
chip_err(chip, "tried to insert a GPIO chip with zero lines\n");
|
chip_err(chip, "tried to insert a GPIO chip with zero lines\n");
|
||||||
status = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err_free_descs;
|
goto err_free_descs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,7 +1311,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
|
|
||||||
gdev->label = kstrdup_const(chip->label ?: "unknown", GFP_KERNEL);
|
gdev->label = kstrdup_const(chip->label ?: "unknown", GFP_KERNEL);
|
||||||
if (!gdev->label) {
|
if (!gdev->label) {
|
||||||
status = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err_free_descs;
|
goto err_free_descs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,7 +1330,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
if (base < 0) {
|
if (base < 0) {
|
||||||
base = gpiochip_find_base(chip->ngpio);
|
base = gpiochip_find_base(chip->ngpio);
|
||||||
if (base < 0) {
|
if (base < 0) {
|
||||||
status = base;
|
ret = base;
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
goto err_free_label;
|
goto err_free_label;
|
||||||
}
|
}
|
||||||
|
@ -1344,8 +1344,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
}
|
}
|
||||||
gdev->base = base;
|
gdev->base = base;
|
||||||
|
|
||||||
status = gpiodev_add_to_list(gdev);
|
ret = gpiodev_add_to_list(gdev);
|
||||||
if (status) {
|
if (ret) {
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
goto err_free_label;
|
goto err_free_label;
|
||||||
}
|
}
|
||||||
|
@ -1359,28 +1359,28 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
INIT_LIST_HEAD(&gdev->pin_ranges);
|
INIT_LIST_HEAD(&gdev->pin_ranges);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = gpiochip_set_desc_names(chip);
|
ret = gpiochip_set_desc_names(chip);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_from_list;
|
goto err_remove_from_list;
|
||||||
|
|
||||||
status = gpiochip_irqchip_init_valid_mask(chip);
|
ret = gpiochip_irqchip_init_valid_mask(chip);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_from_list;
|
goto err_remove_from_list;
|
||||||
|
|
||||||
status = gpiochip_alloc_valid_mask(chip);
|
ret = gpiochip_alloc_valid_mask(chip);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_irqchip_mask;
|
goto err_remove_irqchip_mask;
|
||||||
|
|
||||||
status = gpiochip_add_irqchip(chip, lock_key, request_key);
|
ret = gpiochip_add_irqchip(chip, lock_key, request_key);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_free_gpiochip_mask;
|
goto err_free_gpiochip_mask;
|
||||||
|
|
||||||
status = of_gpiochip_add(chip);
|
ret = of_gpiochip_add(chip);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_chip;
|
goto err_remove_chip;
|
||||||
|
|
||||||
status = gpiochip_init_valid_mask(chip);
|
ret = gpiochip_init_valid_mask(chip);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_of_chip;
|
goto err_remove_of_chip;
|
||||||
|
|
||||||
for (i = 0; i < chip->ngpio; i++) {
|
for (i = 0; i < chip->ngpio; i++) {
|
||||||
|
@ -1407,8 +1407,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data,
|
||||||
* Otherwise, defer until later.
|
* Otherwise, defer until later.
|
||||||
*/
|
*/
|
||||||
if (gpiolib_initialized) {
|
if (gpiolib_initialized) {
|
||||||
status = gpiochip_setup_dev(gdev);
|
ret = gpiochip_setup_dev(gdev);
|
||||||
if (status)
|
if (ret)
|
||||||
goto err_remove_acpi_chip;
|
goto err_remove_acpi_chip;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1438,9 +1438,9 @@ err_free_gdev:
|
||||||
/* failures here can mean systems won't boot... */
|
/* failures here can mean systems won't boot... */
|
||||||
pr_err("%s: GPIOs %d..%d (%s) failed to register, %d\n", __func__,
|
pr_err("%s: GPIOs %d..%d (%s) failed to register, %d\n", __func__,
|
||||||
gdev->base, gdev->base + gdev->ngpio - 1,
|
gdev->base, gdev->base + gdev->ngpio - 1,
|
||||||
chip->label ? : "generic", status);
|
chip->label ? : "generic", ret);
|
||||||
kfree(gdev);
|
kfree(gdev);
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gpiochip_add_data_with_key);
|
EXPORT_SYMBOL_GPL(gpiochip_add_data_with_key);
|
||||||
|
|
||||||
|
@ -2001,7 +2001,7 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
|
||||||
irq_hw_number_t hwirq)
|
irq_hw_number_t hwirq)
|
||||||
{
|
{
|
||||||
struct gpio_chip *chip = d->host_data;
|
struct gpio_chip *chip = d->host_data;
|
||||||
int err = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!gpiochip_irqchip_irq_valid(chip, hwirq))
|
if (!gpiochip_irqchip_irq_valid(chip, hwirq))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
@ -2019,12 +2019,12 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
|
||||||
irq_set_noprobe(irq);
|
irq_set_noprobe(irq);
|
||||||
|
|
||||||
if (chip->irq.num_parents == 1)
|
if (chip->irq.num_parents == 1)
|
||||||
err = irq_set_parent(irq, chip->irq.parents[0]);
|
ret = irq_set_parent(irq, chip->irq.parents[0]);
|
||||||
else if (chip->irq.map)
|
else if (chip->irq.map)
|
||||||
err = irq_set_parent(irq, chip->irq.map[hwirq]);
|
ret = irq_set_parent(irq, chip->irq.map[hwirq]);
|
||||||
|
|
||||||
if (err < 0)
|
if (ret < 0)
|
||||||
return err;
|
return ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No set-up of the hardware will happen if IRQ_TYPE_NONE
|
* No set-up of the hardware will happen if IRQ_TYPE_NONE
|
||||||
|
@ -2611,7 +2611,7 @@ EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges);
|
||||||
static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||||
{
|
{
|
||||||
struct gpio_chip *chip = desc->gdev->chip;
|
struct gpio_chip *chip = desc->gdev->chip;
|
||||||
int status;
|
int ret;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
|
|
||||||
|
@ -2629,10 +2629,10 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||||
|
|
||||||
if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
|
if (test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0) {
|
||||||
desc_set_label(desc, label ? : "?");
|
desc_set_label(desc, label ? : "?");
|
||||||
status = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
kfree_const(label);
|
kfree_const(label);
|
||||||
status = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2641,12 +2641,12 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
offset = gpio_chip_hwgpio(desc);
|
offset = gpio_chip_hwgpio(desc);
|
||||||
if (gpiochip_line_is_valid(chip, offset))
|
if (gpiochip_line_is_valid(chip, offset))
|
||||||
status = chip->request(chip, offset);
|
ret = chip->request(chip, offset);
|
||||||
else
|
else
|
||||||
status = -EINVAL;
|
ret = -EINVAL;
|
||||||
spin_lock_irqsave(&gpio_lock, flags);
|
spin_lock_irqsave(&gpio_lock, flags);
|
||||||
|
|
||||||
if (status < 0) {
|
if (ret < 0) {
|
||||||
desc_set_label(desc, NULL);
|
desc_set_label(desc, NULL);
|
||||||
kfree_const(label);
|
kfree_const(label);
|
||||||
clear_bit(FLAG_REQUESTED, &desc->flags);
|
clear_bit(FLAG_REQUESTED, &desc->flags);
|
||||||
|
@ -2661,7 +2661,7 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2704,24 +2704,24 @@ static int validate_desc(const struct gpio_desc *desc, const char *func)
|
||||||
|
|
||||||
int gpiod_request(struct gpio_desc *desc, const char *label)
|
int gpiod_request(struct gpio_desc *desc, const char *label)
|
||||||
{
|
{
|
||||||
int status = -EPROBE_DEFER;
|
int ret = -EPROBE_DEFER;
|
||||||
struct gpio_device *gdev;
|
struct gpio_device *gdev;
|
||||||
|
|
||||||
VALIDATE_DESC(desc);
|
VALIDATE_DESC(desc);
|
||||||
gdev = desc->gdev;
|
gdev = desc->gdev;
|
||||||
|
|
||||||
if (try_module_get(gdev->owner)) {
|
if (try_module_get(gdev->owner)) {
|
||||||
status = gpiod_request_commit(desc, label);
|
ret = gpiod_request_commit(desc, label);
|
||||||
if (status < 0)
|
if (ret < 0)
|
||||||
module_put(gdev->owner);
|
module_put(gdev->owner);
|
||||||
else
|
else
|
||||||
get_device(&gdev->dev);
|
get_device(&gdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status)
|
if (ret)
|
||||||
gpiod_dbg(desc, "%s: status %d\n", __func__, status);
|
gpiod_dbg(desc, "%s: status %d\n", __func__, ret);
|
||||||
|
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gpiod_free_commit(struct gpio_desc *desc)
|
static bool gpiod_free_commit(struct gpio_desc *desc)
|
||||||
|
@ -2823,22 +2823,22 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum,
|
||||||
enum gpiod_flags dflags)
|
enum gpiod_flags dflags)
|
||||||
{
|
{
|
||||||
struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum);
|
struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum);
|
||||||
int err;
|
int ret;
|
||||||
|
|
||||||
if (IS_ERR(desc)) {
|
if (IS_ERR(desc)) {
|
||||||
chip_err(chip, "failed to get GPIO descriptor\n");
|
chip_err(chip, "failed to get GPIO descriptor\n");
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = gpiod_request_commit(desc, label);
|
ret = gpiod_request_commit(desc, label);
|
||||||
if (err < 0)
|
if (ret < 0)
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
err = gpiod_configure_flags(desc, label, lflags, dflags);
|
ret = gpiod_configure_flags(desc, label, lflags, dflags);
|
||||||
if (err) {
|
if (ret) {
|
||||||
chip_err(chip, "setup of own GPIO %s failed\n", label);
|
chip_err(chip, "setup of own GPIO %s failed\n", label);
|
||||||
gpiod_free_commit(desc);
|
gpiod_free_commit(desc);
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
|
@ -2901,7 +2901,7 @@ static int gpio_set_config(struct gpio_chip *gc, unsigned offset,
|
||||||
int gpiod_direction_input(struct gpio_desc *desc)
|
int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
{
|
{
|
||||||
struct gpio_chip *chip;
|
struct gpio_chip *chip;
|
||||||
int status = 0;
|
int ret = 0;
|
||||||
|
|
||||||
VALIDATE_DESC(desc);
|
VALIDATE_DESC(desc);
|
||||||
chip = desc->gdev->chip;
|
chip = desc->gdev->chip;
|
||||||
|
@ -2925,7 +2925,7 @@ int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
* assume we are in input mode after this.
|
* assume we are in input mode after this.
|
||||||
*/
|
*/
|
||||||
if (chip->direction_input) {
|
if (chip->direction_input) {
|
||||||
status = chip->direction_input(chip, gpio_chip_hwgpio(desc));
|
ret = chip->direction_input(chip, gpio_chip_hwgpio(desc));
|
||||||
} else if (chip->get_direction &&
|
} else if (chip->get_direction &&
|
||||||
(chip->get_direction(chip, gpio_chip_hwgpio(desc)) != 1)) {
|
(chip->get_direction(chip, gpio_chip_hwgpio(desc)) != 1)) {
|
||||||
gpiod_warn(desc,
|
gpiod_warn(desc,
|
||||||
|
@ -2933,7 +2933,7 @@ int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
__func__);
|
__func__);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if (status == 0)
|
if (ret == 0)
|
||||||
clear_bit(FLAG_IS_OUT, &desc->flags);
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
|
|
||||||
if (test_bit(FLAG_PULL_UP, &desc->flags))
|
if (test_bit(FLAG_PULL_UP, &desc->flags))
|
||||||
|
@ -2943,9 +2943,9 @@ int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
gpio_set_config(chip, gpio_chip_hwgpio(desc),
|
gpio_set_config(chip, gpio_chip_hwgpio(desc),
|
||||||
PIN_CONFIG_BIAS_PULL_DOWN);
|
PIN_CONFIG_BIAS_PULL_DOWN);
|
||||||
|
|
||||||
trace_gpio_direction(desc_to_gpio(desc), 1, status);
|
trace_gpio_direction(desc_to_gpio(desc), 1, ret);
|
||||||
|
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(gpiod_direction_input);
|
EXPORT_SYMBOL_GPL(gpiod_direction_input);
|
||||||
|
|
||||||
|
@ -3217,7 +3217,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
|
||||||
struct gpio_array *array_info,
|
struct gpio_array *array_info,
|
||||||
unsigned long *value_bitmap)
|
unsigned long *value_bitmap)
|
||||||
{
|
{
|
||||||
int err, i = 0;
|
int ret, i = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate array_info against desc_array and its size.
|
* Validate array_info against desc_array and its size.
|
||||||
|
@ -3230,11 +3230,11 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
|
||||||
if (!can_sleep)
|
if (!can_sleep)
|
||||||
WARN_ON(array_info->chip->can_sleep);
|
WARN_ON(array_info->chip->can_sleep);
|
||||||
|
|
||||||
err = gpio_chip_get_multiple(array_info->chip,
|
ret = gpio_chip_get_multiple(array_info->chip,
|
||||||
array_info->get_mask,
|
array_info->get_mask,
|
||||||
value_bitmap);
|
value_bitmap);
|
||||||
if (err)
|
if (ret)
|
||||||
return err;
|
return ret;
|
||||||
|
|
||||||
if (!raw && !bitmap_empty(array_info->invert_mask, array_size))
|
if (!raw && !bitmap_empty(array_info->invert_mask, array_size))
|
||||||
bitmap_xor(value_bitmap, value_bitmap,
|
bitmap_xor(value_bitmap, value_bitmap,
|
||||||
|
@ -3422,24 +3422,24 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value);
|
||||||
*/
|
*/
|
||||||
static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value)
|
static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int ret = 0;
|
||||||
struct gpio_chip *chip = desc->gdev->chip;
|
struct gpio_chip *chip = desc->gdev->chip;
|
||||||
int offset = gpio_chip_hwgpio(desc);
|
int offset = gpio_chip_hwgpio(desc);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
err = chip->direction_input(chip, offset);
|
ret = chip->direction_input(chip, offset);
|
||||||
if (!err)
|
if (!ret)
|
||||||
clear_bit(FLAG_IS_OUT, &desc->flags);
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
} else {
|
} else {
|
||||||
err = chip->direction_output(chip, offset, 0);
|
ret = chip->direction_output(chip, offset, 0);
|
||||||
if (!err)
|
if (!ret)
|
||||||
set_bit(FLAG_IS_OUT, &desc->flags);
|
set_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
}
|
}
|
||||||
trace_gpio_direction(desc_to_gpio(desc), value, err);
|
trace_gpio_direction(desc_to_gpio(desc), value, ret);
|
||||||
if (err < 0)
|
if (ret < 0)
|
||||||
gpiod_err(desc,
|
gpiod_err(desc,
|
||||||
"%s: Error in set_value for open drain err %d\n",
|
"%s: Error in set_value for open drain err %d\n",
|
||||||
__func__, err);
|
__func__, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3449,24 +3449,24 @@ static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value)
|
||||||
*/
|
*/
|
||||||
static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value)
|
static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int ret = 0;
|
||||||
struct gpio_chip *chip = desc->gdev->chip;
|
struct gpio_chip *chip = desc->gdev->chip;
|
||||||
int offset = gpio_chip_hwgpio(desc);
|
int offset = gpio_chip_hwgpio(desc);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
err = chip->direction_output(chip, offset, 1);
|
ret = chip->direction_output(chip, offset, 1);
|
||||||
if (!err)
|
if (!ret)
|
||||||
set_bit(FLAG_IS_OUT, &desc->flags);
|
set_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
} else {
|
} else {
|
||||||
err = chip->direction_input(chip, offset);
|
ret = chip->direction_input(chip, offset);
|
||||||
if (!err)
|
if (!ret)
|
||||||
clear_bit(FLAG_IS_OUT, &desc->flags);
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
||||||
}
|
}
|
||||||
trace_gpio_direction(desc_to_gpio(desc), !value, err);
|
trace_gpio_direction(desc_to_gpio(desc), !value, ret);
|
||||||
if (err < 0)
|
if (ret < 0)
|
||||||
gpiod_err(desc,
|
gpiod_err(desc,
|
||||||
"%s: Error in set_value for open source err %d\n",
|
"%s: Error in set_value for open source err %d\n",
|
||||||
__func__, err);
|
__func__, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gpiod_set_raw_value_commit(struct gpio_desc *desc, bool value)
|
static void gpiod_set_raw_value_commit(struct gpio_desc *desc, bool value)
|
||||||
|
@ -4377,7 +4377,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional);
|
||||||
int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
|
int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
|
||||||
unsigned long lflags, enum gpiod_flags dflags)
|
unsigned long lflags, enum gpiod_flags dflags)
|
||||||
{
|
{
|
||||||
int status;
|
int ret;
|
||||||
|
|
||||||
if (lflags & GPIO_ACTIVE_LOW)
|
if (lflags & GPIO_ACTIVE_LOW)
|
||||||
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
|
set_bit(FLAG_ACTIVE_LOW, &desc->flags);
|
||||||
|
@ -4410,9 +4410,9 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
|
||||||
else if (lflags & GPIO_PULL_DOWN)
|
else if (lflags & GPIO_PULL_DOWN)
|
||||||
set_bit(FLAG_PULL_DOWN, &desc->flags);
|
set_bit(FLAG_PULL_DOWN, &desc->flags);
|
||||||
|
|
||||||
status = gpiod_set_transitory(desc, (lflags & GPIO_TRANSITORY));
|
ret = gpiod_set_transitory(desc, (lflags & GPIO_TRANSITORY));
|
||||||
if (status < 0)
|
if (ret < 0)
|
||||||
return status;
|
return ret;
|
||||||
|
|
||||||
/* No particular flag request, return here... */
|
/* No particular flag request, return here... */
|
||||||
if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
|
if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
|
||||||
|
@ -4422,12 +4422,12 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
|
||||||
|
|
||||||
/* Process flags */
|
/* Process flags */
|
||||||
if (dflags & GPIOD_FLAGS_BIT_DIR_OUT)
|
if (dflags & GPIOD_FLAGS_BIT_DIR_OUT)
|
||||||
status = gpiod_direction_output(desc,
|
ret = gpiod_direction_output(desc,
|
||||||
!!(dflags & GPIOD_FLAGS_BIT_DIR_VAL));
|
!!(dflags & GPIOD_FLAGS_BIT_DIR_VAL));
|
||||||
else
|
else
|
||||||
status = gpiod_direction_input(desc);
|
ret = gpiod_direction_input(desc);
|
||||||
|
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4451,7 +4451,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
|
||||||
{
|
{
|
||||||
unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;
|
unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;
|
||||||
struct gpio_desc *desc = NULL;
|
struct gpio_desc *desc = NULL;
|
||||||
int status;
|
int ret;
|
||||||
/* Maybe we have a device name, maybe not */
|
/* Maybe we have a device name, maybe not */
|
||||||
const char *devname = dev ? dev_name(dev) : "?";
|
const char *devname = dev ? dev_name(dev) : "?";
|
||||||
|
|
||||||
|
@ -4486,9 +4486,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
|
||||||
* If a connection label was passed use that, else attempt to use
|
* If a connection label was passed use that, else attempt to use
|
||||||
* the device name as label
|
* the device name as label
|
||||||
*/
|
*/
|
||||||
status = gpiod_request(desc, con_id ? con_id : devname);
|
ret = gpiod_request(desc, con_id ? con_id : devname);
|
||||||
if (status < 0) {
|
if (ret < 0) {
|
||||||
if (status == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
|
if (ret == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
|
||||||
/*
|
/*
|
||||||
* This happens when there are several consumers for
|
* This happens when there are several consumers for
|
||||||
* the same GPIO line: we just return here without
|
* the same GPIO line: we just return here without
|
||||||
|
@ -4501,15 +4501,15 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
|
||||||
con_id ? con_id : devname);
|
con_id ? con_id : devname);
|
||||||
return desc;
|
return desc;
|
||||||
} else {
|
} else {
|
||||||
return ERR_PTR(status);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = gpiod_configure_flags(desc, con_id, lookupflags, flags);
|
ret = gpiod_configure_flags(desc, con_id, lookupflags, flags);
|
||||||
if (status < 0) {
|
if (ret < 0) {
|
||||||
dev_dbg(dev, "setup of GPIO %s failed\n", con_id);
|
dev_dbg(dev, "setup of GPIO %s failed\n", con_id);
|
||||||
gpiod_put(desc);
|
gpiod_put(desc);
|
||||||
return ERR_PTR(status);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
|
@ -4624,7 +4624,7 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
|
||||||
struct gpio_chip *chip;
|
struct gpio_chip *chip;
|
||||||
struct gpio_desc *local_desc;
|
struct gpio_desc *local_desc;
|
||||||
int hwnum;
|
int hwnum;
|
||||||
int status;
|
int ret;
|
||||||
|
|
||||||
chip = gpiod_to_chip(desc);
|
chip = gpiod_to_chip(desc);
|
||||||
hwnum = gpio_chip_hwgpio(desc);
|
hwnum = gpio_chip_hwgpio(desc);
|
||||||
|
@ -4632,10 +4632,10 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
|
||||||
local_desc = gpiochip_request_own_desc(chip, hwnum, name,
|
local_desc = gpiochip_request_own_desc(chip, hwnum, name,
|
||||||
lflags, dflags);
|
lflags, dflags);
|
||||||
if (IS_ERR(local_desc)) {
|
if (IS_ERR(local_desc)) {
|
||||||
status = PTR_ERR(local_desc);
|
ret = PTR_ERR(local_desc);
|
||||||
pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n",
|
pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n",
|
||||||
name, chip->label, hwnum, status);
|
name, chip->label, hwnum, ret);
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark GPIO as hogged so it can be identified and removed later */
|
/* Mark GPIO as hogged so it can be identified and removed later */
|
||||||
|
|
Loading…
Add table
Reference in a new issue