Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5651676img; Wed, 27 Mar 2019 12:28:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsO8ci5sYgqo1SQWQvtoq5Pdsdgs86pwmQOvUg4PxzpmMQTOmpNg+FGwSotQEE1hCl8zyV X-Received: by 2002:a62:1701:: with SMTP id 1mr29319642pfx.120.1553714918319; Wed, 27 Mar 2019 12:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714918; cv=none; d=google.com; s=arc-20160816; b=GIIWG7uuT9P/z0Wqs0t1uLRmdjEnCL/1t+bWkdVQegEQGtplMSfekUsdDAOACDEETX cqhFTapfngTGrQ9EWs8Mzn0o+RPeiKVhHeE0nr8dXDKkP0BwEs5TrfNG2bI5D4Ssd467 iL1VbW4OcsDQhN407bZ/6getdKQUAIjydtHT+/MpobT5crwRlaLgR5O8y8K3ezutshZu JCBvNLSIUfoY7kZAP304IDU2+97IMrSa5QIi7oZQJwP1yedLF0CdA4Vx/MTJRcoDrBGZ PnKRlMttAsYwtTkdObQI9N+AWywT+gjnZKlFmlvcrGgQRGBbAr0n5aWgRIPOScm7iNgR vCQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=me4IV+NOtGWZasHKyi1TpGdbTXK0oDaAuINxIb/ri/c=; b=iXMdeAhrHBEM3/SttqxRq8eSOYS+jAv7gdKtmDr1gwukN0k+lOLUFalBHhUXWV8fIN hgqMASk01BlbyUTJuWvfe/ZZTylu6f/CA7F4uXkz/4cqPLpemSENooQb+aHxlIW/sYhB As1qxtwnFtX6tZu/Np9iQR/DwdzSpaz5grRk07uvZxpDm4OQlZMm1J6/MHRgf0uNkebe vBLXEbEGp2yVF4Sn095o2X0NZm2+R20KROaV9btHMz/ER8kgHVKJw2RlPpVmUPv3Embu SKOaXieIu1B9aNyjwgcAtvmUv578FPSYPvbCnCpWYbLnQlOxvW8McSV6y0bcNUee197D ifiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kfmfIVDR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si21334711pln.403.2019.03.27.12.28.23; Wed, 27 Mar 2019 12:28:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kfmfIVDR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388000AbfC0T0g (ORCPT + 99 others); Wed, 27 Mar 2019 15:26:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:45968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731754AbfC0SFB (ORCPT ); Wed, 27 Mar 2019 14:05:01 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB6BF2063F; Wed, 27 Mar 2019 18:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709900; bh=y6Se3t2aBTfGe8oj5pfCOQOQ6/xPBNCRYHWhm7koozs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kfmfIVDRV4zRvx55sn85YqNdjEMyuctN92k1V9T+n/W1dvFWEA+Gxkcv/36RJDtnG 1uQLe9ftwbMRuMoft7i+OJ/UQcopUDFmGUx9JWL/Sean/0VPgpsqXgpNdJzF533V+A KC9Chxzp7qFqy+T0T/A0BXmLKKUDW/iwcSoWP9nw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jim Broadus , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 098/262] i2c: Allow recovery of the initial IRQ by an I2C client device. Date: Wed, 27 Mar 2019 13:59:13 -0400 Message-Id: <20190327180158.10245-98-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Broadus [ Upstream commit 93b6604c5a669d84e45fe5129294875bf82eb1ff ] A previous change allowed I2C client devices to discover new IRQs upon reprobe by clearing the IRQ in i2c_device_remove. However, if an IRQ was assigned in i2c_new_device, that information is lost. For example, the touchscreen and trackpad devices on a Dell Inspiron laptop are I2C devices whose IRQs are defined by ACPI extended IRQ types. The client device structures are initialized during an ACPI walk. After removing the i2c_hid device, modprobe fails. This change caches the initial IRQ value in i2c_new_device and then resets the client device IRQ to the initial value in i2c_device_remove. Fixes: 6f108dd70d30 ("i2c: Clear client->irq in i2c_device_remove") Signed-off-by: Jim Broadus Reviewed-by: Benjamin Tissoires Reviewed-by: Charles Keepax [wsa: this is an easy to backport fix for the regression. We will refactor the code to handle irq assignments better in general.] Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-base.c | 9 +++++---- include/linux/i2c.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 28460f6a60cc..af87a16ac3a5 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -430,7 +430,7 @@ static int i2c_device_remove(struct device *dev) dev_pm_clear_wake_irq(&client->dev); device_init_wakeup(&client->dev, false); - client->irq = 0; + client->irq = client->init_irq; return status; } @@ -741,10 +741,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) client->flags = info->flags; client->addr = info->addr; - client->irq = info->irq; - if (!client->irq) - client->irq = i2c_dev_irq_from_resources(info->resources, + client->init_irq = info->irq; + if (!client->init_irq) + client->init_irq = i2c_dev_irq_from_resources(info->resources, info->num_resources); + client->irq = client->init_irq; strlcpy(client->name, info->type, sizeof(client->name)); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 65b4eaed1d96..7e748648c7d3 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -333,6 +333,7 @@ struct i2c_client { char name[I2C_NAME_SIZE]; struct i2c_adapter *adapter; /* the adapter we sit on */ struct device dev; /* the device structure */ + int init_irq; /* irq set at initialization */ int irq; /* irq issued by device */ struct list_head detected; #if IS_ENABLED(CONFIG_I2C_SLAVE) -- 2.19.1