CP2105 gives kernel error -22 when in modem mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

When a uart of the CP2105 USB-serial chip is programmed to be in modem mode, all its gpio pins are in alternate use and none are available for gpio. Still the cp210x driver tries to add a gpiochip unconditionally, which results in an error.

cp210x 1-1.4.4:1.0: cp210x converter detected
usb 1-1.4.4: cp210x converter now attached to ttyUSB0
cp210x 1-1.4.4:1.1: cp210x converter detected
gpio gpiochip2: (cp210x): tried to insert a GPIO chip with zero lines
gpiochip_add_data_with_key: GPIOs 0..-1 (cp210x) failed to register, -22
cp210x 1-1.4.4:1.1: GPIO initialisation failed: -22
usb 1-1.4.4: cp210x converter now attached to ttyUSB1

I propose to add something like the following to cp210x_gpio_init

+	unsigned long valid_mask, altfunc_mask;
...
+	altfunc_mask = priv->gpio_altfunc;
+	bitmap_complement(&valid_mask, &altfunc_mask, priv->gc.ngpio);
+	if (bitmap_empty(&valid_mask, priv->gc.ngpio))
+		return 0;
+
 	priv->gc.label = "cp210x";
 	priv->gc.request = cp210x_gpio_request;
 	priv->gc.get_direction = cp210x_gpio_direction_get;

I can write a proper patch, but am unsure if and what the Fixes tag should be.

Maarten




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux