From: Maarten Brock <m.brock@vanmierlo.com>
To: linux-usb@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: CP2105 gives kernel error -22 when in modem mode
Date: Thu, 25 Nov 2021 16:42:27 +0100 [thread overview]
Message-ID: <5eb560c81d2ea1a2b4602a92d9f48a89@vanmierlo.com> (raw)
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
next reply other threads:[~2021-11-25 16:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 15:42 Maarten Brock [this message]
2021-11-26 9:47 ` CP2105 gives kernel error -22 when in modem mode Johan Hovold
2021-11-26 12:53 ` Maarten Brock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5eb560c81d2ea1a2b4602a92d9f48a89@vanmierlo.com \
--to=m.brock@vanmierlo.com \
--cc=johan@kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox