From: Michael Zaidman <michael.zaidman@gmail.com>
To: chrysh@christina-quast.de, daniel.beer@igorinstitute.com,
jikos@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
linux-serial@vger.kernel.org, ilpo.jarvinen@linux.intel.com,
johan@kernel.org, gregkh@linuxfoundation.org, equinox@diac24.net,
michael.zaidman@gmail.com
Subject: [PATCH v1 13/19] hid-ft260: improve usb interface type detection logic
Date: Sat, 10 Feb 2024 23:51:41 +0200 [thread overview]
Message-ID: <20240210215147.77629-14-michael.zaidman@gmail.com> (raw)
In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com>
This commit simplifies the ft260_get_interface_type routine by
replacing the ft260_is_serial with iface_type and making use of
its return value as it's in the mainline ft260 driver code.
Signed-off-by: Michael Zaidman <michael.zaidman@gmail.com>
---
drivers/hid/hid-ft260.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c
index 3d1a9ec88cb9..9ecd91d173d2 100644
--- a/drivers/hid/hid-ft260.c
+++ b/drivers/hid/hid-ft260.c
@@ -309,7 +309,7 @@ struct ft260_device {
struct i2c_adapter adap;
struct hid_device *hdev;
- bool ft260_is_serial;
+ int iface_type;
struct list_head device_list;
/* tty_port lifetime is equal to device lifetime */
@@ -889,28 +889,25 @@ static int ft260_get_interface_type(struct hid_device *hdev, struct ft260_device
ft260_dbg("i2c_enable: 0x%02x\n", cfg.i2c_enable);
ft260_dbg("uart_mode: 0x%02x\n", cfg.uart_mode);
- dev->ft260_is_serial = false;
dev->power_saving_en = cfg.power_saving_en;
switch (cfg.chip_mode) {
case FT260_MODE_ALL:
case FT260_MODE_BOTH:
- if (interface == 1) {
+ if (interface == 1)
ret = FT260_IFACE_UART;
- dev->ft260_is_serial = true;
- } else {
+ else
ret = FT260_IFACE_I2C;
- }
break;
case FT260_MODE_UART:
ret = FT260_IFACE_UART;
- dev->ft260_is_serial = true;
break;
case FT260_MODE_I2C:
ret = FT260_IFACE_I2C;
break;
}
+ dev->iface_type = ret;
return ret;
}
@@ -1713,15 +1710,12 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id)
mutex_init(&dev->lock);
init_completion(&dev->wait);
- if (!dev->ft260_is_serial) {
+ if (ret == FT260_IFACE_I2C)
ret = ft260_i2c_probe(hdev, dev);
- if (ret)
- goto err_hid_close;
- } else {
+ else
ret = ft260_uart_probe(hdev, dev);
- if (ret)
- goto err_hid_close;
- }
+ if (ret)
+ goto err_hid_close;
return 0;
@@ -1742,7 +1736,7 @@ static void ft260_remove(struct hid_device *hdev)
if (!dev)
return;
- if (dev->ft260_is_serial) {
+ if (dev->iface_type == FT260_IFACE_UART) {
// FIXME:
cancel_work_sync(&dev->wakeup_work);
tty_port_unregister_device(&dev->port, ft260_tty_driver,
--
2.40.1
next prev parent reply other threads:[~2024-02-10 21:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-10 21:51 [PATCH v1 00/19] hid-ft260: Fixes for serial driver patch v4 Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 01/19] hid-ft260: fix incompatible-pointer-types error Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 02/19] hid-ft260: fix Wformat warning Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 03/19] hid-ft260: fix i2c driver regression in ft260_raw_event Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 04/19] hid-ft260: remove dead code in ft260_uart_receive_chars Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 05/19] hid-ft260: fix unprotected write_buf concurrent access Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 06/19] hid-ft260: uart: enable wakeup workaround Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 07/19] hid-ft260: depend wakeup workaround activation on uart baud rate Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 08/19] hid-ft260: depend wakeup workaround activation on eeprom config Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 09/19] hid-ft260: uart: wakeup device early to not lose rx data Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 10/19] hid-ft260: uart: do not configure baud rate twice Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 11/19] hid-ft260: uart: do not disable wakeup workaround twice Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 12/19] hid-ft260: uart: use kfifo_avail for fifo write room check Michael Zaidman
2024-02-10 21:51 ` Michael Zaidman [this message]
2024-02-10 21:51 ` [PATCH v1 14/19] hid-ft260: uart: cleanup and refactoring Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 15/19] hid-ft260: uart: remove FIXME for wake-up workaround Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 16/19] hid-ft260: uart: suppress unhandled report 0xb1 dmesg Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 17/19] hid-ft260: uart: arm wake-up timer unconditionally on tty session start Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 18/19] hid-ft260: uart: fix rx data loss after device reopening Michael Zaidman
2024-02-10 21:51 ` [PATCH v1 19/19] hid-ft260: uart: improve write performance Michael Zaidman
2024-02-23 21:22 ` Michael Zaidman
2024-02-13 10:20 ` [PATCH v1 00/19] hid-ft260: Fixes for serial driver patch v4 Jiri Kosina
2024-02-23 13:07 ` Christina Quast
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=20240210215147.77629-14-michael.zaidman@gmail.com \
--to=michael.zaidman@gmail.com \
--cc=chrysh@christina-quast.de \
--cc=daniel.beer@igorinstitute.com \
--cc=equinox@diac24.net \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jikos@kernel.org \
--cc=johan@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@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;
as well as URLs for NNTP newsgroup(s).