}
 
 #ifdef CONFIG_GPIOLIB
-static int cp210x_gpio_request(struct gpio_chip *gc, unsigned int offset)
-{
-       struct usb_serial *serial = gpiochip_get_data(gc);
-       struct cp210x_serial_private *priv = usb_get_serial_data(serial);
-
-       if (priv->gpio_altfunc & BIT(offset))
-               return -ENODEV;
-
-       return 0;
-}
-
 static int cp210x_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
        struct usb_serial *serial = gpiochip_get_data(gc);
        return -ENOTSUPP;
 }
 
+static int cp210x_gpio_init_valid_mask(struct gpio_chip *gc,
+               unsigned long *valid_mask, unsigned int ngpios)
+{
+       struct usb_serial *serial = gpiochip_get_data(gc);
+       struct cp210x_serial_private *priv = usb_get_serial_data(serial);
+       unsigned long altfunc_mask = priv->gpio_altfunc;
+
+       bitmap_complement(valid_mask, &altfunc_mask, ngpios);
+
+       return 0;
+}
+
 /*
  * This function is for configuring GPIO using shared pins, where other signals
  * are made unavailable by configuring the use of GPIO. This is believed to be
                return result;
 
        priv->gc.label = "cp210x";
-       priv->gc.request = cp210x_gpio_request;
        priv->gc.get_direction = cp210x_gpio_direction_get;
        priv->gc.direction_input = cp210x_gpio_direction_input;
        priv->gc.direction_output = cp210x_gpio_direction_output;
        priv->gc.get = cp210x_gpio_get;
        priv->gc.set = cp210x_gpio_set;
        priv->gc.set_config = cp210x_gpio_set_config;
+       priv->gc.init_valid_mask = cp210x_gpio_init_valid_mask;
        priv->gc.owner = THIS_MODULE;
        priv->gc.parent = &serial->interface->dev;
        priv->gc.base = -1;