Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1708940rdb; Sat, 10 Feb 2024 13:56:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgECFfYOR10bh/4ht4VR/hARIlLMntIaTGgE5W0k7OJYcfCeldMjJW4NgdNTNzowzwrUGtrJJPp85X9LVAVLmkKMwW7HnJG8UIzu5eVA== X-Google-Smtp-Source: AGHT+IH2NF58OTAx0Rekcl4xwVaJJvo+FrCoWsFKjjJG9wC6Uzw6vF+jNaOKdwYe7ZVYL9c0DSmF X-Received: by 2002:a05:622a:1a90:b0:42b:e5e0:5db with SMTP id s16-20020a05622a1a9000b0042be5e005dbmr4001095qtc.11.1707602216208; Sat, 10 Feb 2024 13:56:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707602216; cv=pass; d=google.com; s=arc-20160816; b=okIN4CadOnCBfNyJP0vyYMIwBfMaHO1YD6qfdtrysH023T2Z5e2EerDNIsejs0c7rC 4iwwnyAlN4XmXQe71WSljGoJMFXaOYFezZMYiLWLvL6NdrCkALz3ZqB+z3wiFenR3Z9i VLIdXmQYMTbRVMbtWyop5/gRG/LCU9weQ8RkDO0LoiuerFjPTlkiWSPZsCBmHKxEo+WN tOqHnMUPI09CeBo34C9Z2/f3hPMIaLYVdlXRQ2Y5+x3/kGib6GPzGEGJYz14KHh0zfgw W9X9Qh116GuhWK+1y6dQhzERte63LMvQYGZ1LaUr5pYLl6uFt8bd1LVJpB3binb2VDa2 FJog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9Fkky7a9eT7SBkGtnfLXUQcC5w2wTxfnvBE3rXTwzAA=; fh=bFMWJasjpO6k4znUWusKATJ5rbyUa8a/WyLE5kekRuI=; b=brN/jMdtsUxHdM7L7AVOeKCL/lqXqT5R9oVpBJSB6OjvAaioKoP1mlFSFCrHlPDZjG PxRGLUc/yyvHDd8qAW61a9VL5I/B1exetIXkp01VT5/x5iM/w8jDrMnCVbeioFBvRRC3 WhhrjhXqp8HQr4A9Vi7KPIaD1829baiTwaRxTjD9featYNwa81dy/H/ZD8rhxNWGWAWt 3/fgsXN8nZDImBx0CDIRwTHFCdYRsJM7vqpgStiyp8UZHMuaQzVuMrLhcixs9fFRtBT1 1I9stfaGaRqkCEIELDMb12XDfFPb38mpDbTuklzcePd8z40xa4znA9zeitRz51T1+M3s aCgw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NoYi3Gv2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCW5Eqo2sgPTJva5MZ1Z9AEo+97OwVp0oBzpxzUQpNpO3KjC+fPcBmCKzSFBqYGqkHye68vsgwqeZeso2SFIaJvRZLm0U97VtgRoDBDttA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c6-20020a05622a024600b0042c0d9112cesi4923654qtx.566.2024.02.10.13.56.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:56:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NoYi3Gv2; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60560-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60560-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6E5871C223D4 for ; Sat, 10 Feb 2024 21:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EE276088F; Sat, 10 Feb 2024 21:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NoYi3Gv2" Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C285060884; Sat, 10 Feb 2024 21:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602020; cv=none; b=C+8VFLmLIyWSU0hIXnEjXX1/YrUg2jm+Ste2TOn5C6Q0v1TibD2AybLl4+t4W2lNaOOKHNh3aapAC2rQVED0v4/nghUai+fJj+kBzOzRmHoGwulv97qgykHr6CxEZBlmBnQY82cAdqtMNU4i/rIf+S/sGHi/uvCUpVOcDkefF7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707602020; c=relaxed/simple; bh=bxc8EJBTU97uaAgMzrUDFX/3ZhRiWUNfsRvqcbGs/6c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rdic3ixZ/7C5ualGvZxnQkxP17nGMhRF8puwaHG9kRQEu2Ko+Y0BDZGNTG4U9xy++M2SPagdcdyBy3j+wwIcT5S9sYjFF77TtmC7UGLbxb5Cj+fS7uou2ASowjRgZEVlQDQLjFnvW6bHLtYdE4XvEWFjbTk9JGWMEeuv5THdQ0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NoYi3Gv2; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so2465771e87.0; Sat, 10 Feb 2024 13:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707602017; x=1708206817; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Fkky7a9eT7SBkGtnfLXUQcC5w2wTxfnvBE3rXTwzAA=; b=NoYi3Gv2+8slDlMv3RhL/qHd31BUlLKnVRzF+qv2auZpvD7lmwCvVUIv05HuT5SSK/ DElsuwHLJSV4OKK6H4auehMVXfNPDbblZSlrTinsTNDm+jxElpfAEQQnDl98FAgX8mEK 8lCcMg0AqTBqf4sJM8HecszL9/1NL8cTtOFEiQqEIz2jQ4PbKZwfjoCo+KrqeG4gRlBA 1jXUNElXaQaTAkxarKj2C1t6xcyOPJVmkM+CLdgbRO5zFN2SETjaxLdVty5+8o5JB1F9 jPpcWZ5/mSK411hw3LYJkLNo7zS1EHWUWGUBpXPNEGePQFNKT3IHxoNuBMqaHR9fvRHq 8vGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707602017; x=1708206817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Fkky7a9eT7SBkGtnfLXUQcC5w2wTxfnvBE3rXTwzAA=; b=hY/RhWEuWjRpQ1iwZ/343kpYidMVeTaiaBuluyi45BOAdIvfoThNY6B0dz7MPLiMhf U+qynUeq6FiWyvP6v6c+wzLzEM9Re005gNvO4d0ZZJJXw1ywA0OF9T5SwyquutE3QQIG 6lXiEtifpspja6Fed8R80RmgOmAiAB1YMnxtNClYKp202EhmixtY8lvJluQLDn9eBdwo EnzB5bBMNXH4jtEhBZ8JnBKLdtUAETE7zPwklKDo4sR726Xr8nJ3XTwahW1yRe5b7oMI NkT+boRooISU6eWDFkQy13a4G4Iv5nMXuIkKR5uIQXknaKDj1QddsRvlG3UsYI7qiStt iBpw== X-Forwarded-Encrypted: i=1; AJvYcCWlDUnsa9pK9pyz7Mr4d11xvyi4uwm+XO6tswwbZ03Z2Fsdhga3GkTY/3SU/U4TVaABLSOhvDH3AQjMbXkHkaAvOi0T9Mm2wQfSEJSupH8SEoTanNOm5/VXYI6mgxnNjWSQe2QVJ1RRbLo= X-Gm-Message-State: AOJu0YzHBPJWM5ta7d6P/b1cgnOAaJiz23dHIpu3x+3BS3jl4JAFtLkE 3fIBUZcXvKGzkugXLnyDrQXs7ejwD5v+jgZhWZWNQ5dLHmpjOdyP X-Received: by 2002:a05:6512:3994:b0:511:76e6:e0f9 with SMTP id j20-20020a056512399400b0051176e6e0f9mr2693656lfu.20.1707602016878; Sat, 10 Feb 2024 13:53:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVLG+/0Sw+CxnHF8MX7j3iHqX+zPcGBaAxanzd5wx681sDEwNPArqysdIikDA+56j+wQl8/Sp1Psjc4tku6NgNJXyPeK4odAhY/2KvLaM3D1JWWFH8hASgDdsRMwus1FgLFjXCr1uXkNKMTGvNsDMpqxRbvIoMGCv+p89+cVcECbc66j6cTgrfodOLjs0Jy90IZBE5JfiaXqwJpZ64TYXh2EVTAc0VmeB9MVGKIjACkQuGb6TjsToPO7k3xihSiHqWsyvaafyzDfdC+bP4WvoiuU/J3OITE0ShldqBjCYDfVIjDKPKi563wMRSZR8W4E4zkW23r5K8ojposWyFg9M6U281Qui9SteWaLVDWmLoly9Pch5SGGw== Received: from m2.. (89-139-223-180.bb.netvision.net.il. [89.139.223.180]) by smtp.googlemail.com with ESMTPSA id a7-20020a19ca07000000b0051189b53f93sm24005lfg.302.2024.02.10.13.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 13:53:36 -0800 (PST) From: Michael Zaidman 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 Message-Id: <20240210215147.77629-14-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240210215147.77629-1-michael.zaidman@gmail.com> References: <20240210215147.77629-1-michael.zaidman@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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