]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpio/gpio-max732x.c
gpio: max732x: Be sure to clamp return value
[karo-tx-linux.git] / drivers / gpio / gpio-max732x.c
index 8c5252c6c327764cb6fc4ae99f321e2cdf830537..880ce94e607782f80f8f0c74f5f4b165e3cb6755 100644 (file)
@@ -207,9 +207,9 @@ static int max732x_gpio_get_value(struct gpio_chip *gc, unsigned off)
 
        ret = max732x_readb(chip, is_group_a(chip, off), &reg_val);
        if (ret < 0)
-               return 0;
+               return ret;
 
-       return reg_val & (1u << (off & 0x7));
+       return !!(reg_val & (1u << (off & 0x7)));
 }
 
 static void max732x_gpio_set_mask(struct gpio_chip *gc, unsigned off, int mask,
@@ -603,7 +603,7 @@ static int max732x_setup_gpio(struct max732x_chip *chip,
        gc->base = gpio_start;
        gc->ngpio = port;
        gc->label = chip->client->name;
-       gc->dev = &chip->client->dev;
+       gc->parent = &chip->client->dev;
        gc->owner = THIS_MODULE;
 
        return port;
@@ -649,7 +649,7 @@ static int max732x_probe(struct i2c_client *client,
        chip->client = client;
 
        nr_port = max732x_setup_gpio(chip, id, pdata->gpio_base);
-       chip->gpio_chip.dev = &client->dev;
+       chip->gpio_chip.parent = &client->dev;
 
        addr_a = (client->addr & 0x0f) | 0x60;
        addr_b = (client->addr & 0x0f) | 0x50;
@@ -749,7 +749,6 @@ static int max732x_remove(struct i2c_client *client)
 static struct i2c_driver max732x_driver = {
        .driver = {
                .name           = "max732x",
-               .owner          = THIS_MODULE,
                .of_match_table = of_match_ptr(max732x_of_table),
        },
        .probe          = max732x_probe,