static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
 {
-       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       struct max7301 *ts = gpiochip_get_data(chip);
        u8 *config;
        u8 offset_bits, pin_config;
        int ret;
 static int max7301_direction_output(struct gpio_chip *chip, unsigned offset,
                                    int value)
 {
-       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       struct max7301 *ts = gpiochip_get_data(chip);
        u8 *config;
        u8 offset_bits;
        int ret;
 
 static int max7301_get(struct gpio_chip *chip, unsigned offset)
 {
-       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       struct max7301 *ts = gpiochip_get_data(chip);
        int config, level = -EINVAL;
 
        /* First 4 pins are unused in the controller */
 
 static void max7301_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       struct max7301 *ts = gpiochip_get_data(chip);
 
        /* First 4 pins are unused in the controller */
        offset += 4;
                }
        }
 
-       ret = gpiochip_add(&ts->chip);
+       ret = gpiochip_add_data(&ts->chip, ts);
        if (ret)
                goto exit_destroy;