|
@@ -2543,19 +2543,27 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc);
|
|
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 = -EINVAL;
|
|
|
|
|
|
+ int status = 0;
|
|
|
|
|
|
VALIDATE_DESC(desc);
|
|
VALIDATE_DESC(desc);
|
|
chip = desc->gdev->chip;
|
|
chip = desc->gdev->chip;
|
|
|
|
|
|
- if (!chip->get || !chip->direction_input) {
|
|
|
|
|
|
+ if (!chip->get && chip->direction_input) {
|
|
gpiod_warn(desc,
|
|
gpiod_warn(desc,
|
|
- "%s: missing get() or direction_input() operations\n",
|
|
|
|
|
|
+ "%s: missing get() and direction_input() operations\n",
|
|
__func__);
|
|
__func__);
|
|
return -EIO;
|
|
return -EIO;
|
|
}
|
|
}
|
|
|
|
|
|
- status = chip->direction_input(chip, gpio_chip_hwgpio(desc));
|
|
|
|
|
|
+ if (chip->direction_input) {
|
|
|
|
+ status = chip->direction_input(chip, gpio_chip_hwgpio(desc));
|
|
|
|
+ } else if (chip->get_direction &&
|
|
|
|
+ (chip->get_direction(chip, gpio_chip_hwgpio(desc)) != 1)) {
|
|
|
|
+ gpiod_warn(desc,
|
|
|
|
+ "%s: missing direction_input() operation\n",
|
|
|
|
+ __func__);
|
|
|
|
+ return -EIO;
|
|
|
|
+ }
|
|
if (status == 0)
|
|
if (status == 0)
|
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
|
clear_bit(FLAG_IS_OUT, &desc->flags);
|
|
|
|
|
|
@@ -2577,16 +2585,28 @@ static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
|
|
{
|
|
{
|
|
struct gpio_chip *gc = desc->gdev->chip;
|
|
struct gpio_chip *gc = desc->gdev->chip;
|
|
int val = !!value;
|
|
int val = !!value;
|
|
- int ret;
|
|
|
|
|
|
+ int ret = 0;
|
|
|
|
|
|
- if (!gc->set || !gc->direction_output) {
|
|
|
|
|
|
+ if (!gc->set && !gc->direction_output) {
|
|
gpiod_warn(desc,
|
|
gpiod_warn(desc,
|
|
- "%s: missing set() or direction_output() operations\n",
|
|
|
|
|
|
+ "%s: missing set() and direction_output() operations\n",
|
|
__func__);
|
|
__func__);
|
|
return -EIO;
|
|
return -EIO;
|
|
}
|
|
}
|
|
|
|
|
|
- ret = gc->direction_output(gc, gpio_chip_hwgpio(desc), val);
|
|
|
|
|
|
+ if (gc->direction_output) {
|
|
|
|
+ ret = gc->direction_output(gc, gpio_chip_hwgpio(desc), val);
|
|
|
|
+ } else {
|
|
|
|
+ if (gc->get_direction &&
|
|
|
|
+ gc->get_direction(gc, gpio_chip_hwgpio(desc))) {
|
|
|
|
+ gpiod_warn(desc,
|
|
|
|
+ "%s: missing direction_output() operation\n",
|
|
|
|
+ __func__);
|
|
|
|
+ return -EIO;
|
|
|
|
+ }
|
|
|
|
+ gc->set(gc, gpio_chip_hwgpio(desc), val);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!ret)
|
|
if (!ret)
|
|
set_bit(FLAG_IS_OUT, &desc->flags);
|
|
set_bit(FLAG_IS_OUT, &desc->flags);
|
|
trace_gpio_value(desc_to_gpio(desc), 0, val);
|
|
trace_gpio_value(desc_to_gpio(desc), 0, val);
|