Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4629643pxv; Tue, 20 Jul 2021 08:07:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7MdsqdtHgsBNJX4G7lSs4fpQTiJJDJR1fdekmawuE6NnTm6W7lHJuJXbmkYsqGPqP0KWw X-Received: by 2002:a92:d251:: with SMTP id v17mr20277663ilg.283.1626793678397; Tue, 20 Jul 2021 08:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626793678; cv=none; d=google.com; s=arc-20160816; b=H+5jQbFbN/xuE0S6m3UakGDlbEkAtkQkkkfu+iHjmwDliDEq1oFKebt4Jna/RSZKAS WBzXTzQvsPdo3IiG54RcZ3JEy7rlp5YS8PHYt3ool9j35G7v8rRebVpVgQzAncpnxmEL equKgnjH7tU6R0AKWYcUwB1IqrQrDWWkZOeauwG9EiQUe1XmUO49xSU7coNH/uBMmUfH 8UDzzqO4clC2000k3othJ1pj0w9KwTjZK1Cihm6sWFVFKgc70fhyDmdJ5Iq+0HZE3CNW Q/6skcOwPxm5oj46Ql8Mg7aSDWjVCEjacvqFHeHjvyV+0hrWc9q1XsydAD9aoLOa6QuL /YsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DfaYjaAQWD7iw8jrijr5uZKZKd1db+DgTG/cmZm1AoU=; b=DD+LFd7hAUtk6EDGZ2FAIHSBcUyMPUrlJPVkMkrFq9ax+q/6O/WpCtDYxMLuoiJMoG JS1ZC3fuRJjmiEebF4CPCikMamC97WQjvchDxliryJkRLPpZPmdXXQ9SmUh7/WvSQgbS 3i32jULv6hPTr6jb4upBjNqfYBs1xwCRtL+UcJv/yoxMDWMC35yyWSD0PYDN9olpxIf4 enfMs4NlxwAwsmusYqbQs0TpbNhuMbIj3JipN1GXyauBdv4Rggom31NxRN9qc+AEic3e 19JHkYVrrPjCP2Li7qyGKT3PyXMnvhOwxqmcgXJmLE3vSkmcMlkZFBQPzQqsrg8M/1YH 3neA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rfezC5dL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si22744952ils.118.2021.07.20.08.07.46; Tue, 20 Jul 2021 08:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rfezC5dL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238978AbhGTOYI (ORCPT + 99 others); Tue, 20 Jul 2021 10:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239272AbhGTONr (ORCPT ); Tue, 20 Jul 2021 10:13:47 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56FD2C061786; Tue, 20 Jul 2021 07:50:07 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id ee25so28755990edb.5; Tue, 20 Jul 2021 07:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DfaYjaAQWD7iw8jrijr5uZKZKd1db+DgTG/cmZm1AoU=; b=rfezC5dL7JwoDTyXVJMplYPp7NimB1xesQl2PaOTxXk13s7kDmCnCAfywwPd28wZX2 9TDa9akJR/eMHMFiK/5mLlNHDwS1bQzlQ8xC9OmmyPlVX6d2V2afKWOpLJrThSQorLHT 7WvJ0klPF7M7MUUDqRA/Df/N7n4BWJkAwgt6pqcdfOfMJd5wqfnfYHFZZjBl8LWSIp0t 6o1jCMxWs1Vwkzhj3seqgKcSOUdRpzgSgqQP3JdBA00eJO1lafaxKX+5cVZjTersw+h8 U0ylwPPLZaZ4dUYs8FnLlYZTiluTNNHGc3nz4IviEafuIuEsaNJmQGwYijfe7VJWJcFQ kENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DfaYjaAQWD7iw8jrijr5uZKZKd1db+DgTG/cmZm1AoU=; b=X3MHt1QdFKtgsyZYg+ceU8aUcEMRHKEcJXVvnI2XGYBIrAd2YMmPQj+sQ7XdDHnvLZ 0sXZF49gMYJyBpwC1G3l+lAXwqWPdvp7LLVNBUqzWnU+xRWgq5RlJ5zKgA4nVonO3+kQ hVZfxR5IRbiZpv5uOTUPk9/1IPllUQJk80rzGKnaaiprxiVSKgdm4Z53U69sMBtSfCdw cbk6+++VpvH+zaUFRZdZdcD34V0DSOjEQGW1sb84fjTqc+W6UbM3shRr7ri3Ixc5pYzH ulz7/Y7odqiFV/JNY1x5UPwTrxf9h3sb/fKuXAS+y5acYDDPbszxRzsIkWuMgdSmaveJ qVqg== X-Gm-Message-State: AOAM532HRe6xRaAhLwjxfWyrOBCyuhncn7L9ahL9R0ZJ+GHqkxsELMXE BcTBKYtnWHWqFLVdCCIUg1VD0mWpB76c6P0FYQc= X-Received: by 2002:a05:6402:1011:: with SMTP id c17mr13780157edu.144.1626792605965; Tue, 20 Jul 2021 07:50:05 -0700 (PDT) Received: from localhost.localdomain (cbl217-132-240-31.bb.netvision.net.il. [217.132.240.31]) by smtp.googlemail.com with ESMTPSA id n13sm4876600eda.36.2021.07.20.07.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 07:50:05 -0700 (PDT) From: Michael Zaidman To: jikos@kernel.org, benjamin.tissoires@redhat.com, aaron.jones@ftdichip.com Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-i2c@vger.kernel.org, Michael Zaidman Subject: [PATCH v1] HID: ft260: fix device removal due to USB disconnect Date: Tue, 20 Jul 2021 17:49:54 +0300 Message-Id: <20210720144954.5392-1-michael.zaidman@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit fixes a regression introduced by the commit 82f09a637dd3 ("HID: ft260: improve error handling of ft260_hid_feature_report_get()") when upon USB disconnect, the ft260 i2c device is still available within the /dev folder. Signed-off-by: Michael Zaidman Acked-by: Aaron Jones (FTDI-UK) --- drivers/hid/hid-ft260.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index f43a8406cb9a..fa73a35aaf98 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -742,8 +742,8 @@ static int ft260_is_interface_enabled(struct hid_device *hdev) int ret; ret = ft260_get_system_config(hdev, &cfg); - if (ret) - return ret; + if (ret < 0) + return 0; ft260_dbg("interface: 0x%02x\n", interface); ft260_dbg("chip mode: 0x%02x\n", cfg.chip_mode); @@ -754,23 +754,16 @@ static int ft260_is_interface_enabled(struct hid_device *hdev) switch (cfg.chip_mode) { case FT260_MODE_ALL: case FT260_MODE_BOTH: - if (interface == 1) { + if (interface == 1) hid_info(hdev, "uart interface is not supported\n"); - return 0; - } - ret = 1; + else + ret = 1; break; case FT260_MODE_UART: - if (interface == 0) { - hid_info(hdev, "uart is unsupported on interface 0\n"); - ret = 0; - } + hid_info(hdev, "uart interface is not supported\n"); break; case FT260_MODE_I2C: - if (interface == 1) { - hid_info(hdev, "i2c is unsupported on interface 1\n"); - ret = 0; - } + ret = 1; break; } return ret; @@ -1004,11 +997,9 @@ static int ft260_probe(struct hid_device *hdev, const struct hid_device_id *id) static void ft260_remove(struct hid_device *hdev) { - int ret; struct ft260_device *dev = hid_get_drvdata(hdev); - ret = ft260_is_interface_enabled(hdev); - if (ret <= 0) + if (!dev) return; sysfs_remove_group(&hdev->dev.kobj, &ft260_attr_group); -- 2.25.1