Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp355267imj; Sat, 16 Feb 2019 01:47:34 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib4OJWW5ecHn2R/FA51VCbSnZZUw6Llwyy9wjo6foAunJmZz5+khSI43oPupJGeUpB4VSoW X-Received: by 2002:a17:902:bd42:: with SMTP id b2mr14878028plx.27.1550310454470; Sat, 16 Feb 2019 01:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550310454; cv=none; d=google.com; s=arc-20160816; b=tkU1lfR2Rw1WFYAUqIbhaXxxaDhYu/DWnh70RFdfjju7fXpsj5+tis5chXG8MhgHob Qi+4bgSOk0INR+4lKEaYeNdNM6adIqBbeZZnQqgHAydZEVjZGL/La8LSLkhPRVzYnRyu ie1YrbON86w9fw0OePZDtU2Y9Sg9y7osyBjdasXkLQz9P0MH2fS8W3vmKfybbRiPZpG9 G9pFXKDYtkzfEP2Z3qjMbKLFNexeaIPN7+SjK2V8PEUAPC8ty4+IzcbiZILyQIVsc3yA eaqqZJyIb74c4qExHDNZlsLi/lHx0BoJRo07Oo8951vVqLz3t9qLvtSCt6X33MglSvT1 /8xA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=TnwgvlgKZzgDcW1p8jYLFZ+O7mxKkO66Ee7GWaCiVz0=; b=sbzUvtzdgQ9ZGu1Xe1EfQF26q+91RoF97Lm6IKYUUx4SJZppWT2JTu52G8t08nDiRp WJfMIFLxWUuiPgNgcavNq6ymJ/Rnd4dPQlexZW86lXEsPitP3HkM4fFIAeFsgl3M5GO4 Bmf5+nbCanueq37aTgVdsFMZm0mAiL3UQXUpwCDujelJqRqbealZm1WJtFOmxNeIJ+IL RCaYlJHac/nNhIIfI0HkhY4dZxehBeJ5tuNAJd7y1S3G2ubFBY8jTKn106xSbQcqHnrm WyjyM4f77ndL0iCZ42nA9+dzfGvj/y2iBdjMZfhrpAcdUk5g+z1VG4Fa5hOCiOdg8/qA 3yBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kwUwd6Yg; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si6741542plr.336.2019.02.16.01.47.18; Sat, 16 Feb 2019 01:47:34 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=kwUwd6Yg; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730097AbfBPAPw (ORCPT + 99 others); Fri, 15 Feb 2019 19:15:52 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35658 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726895AbfBPAPw (ORCPT ); Fri, 15 Feb 2019 19:15:52 -0500 Received: by mail-pl1-f196.google.com with SMTP id p8so5748777plo.2; Fri, 15 Feb 2019 16:15:52 -0800 (PST) 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=TnwgvlgKZzgDcW1p8jYLFZ+O7mxKkO66Ee7GWaCiVz0=; b=kwUwd6YgJAzlATPcvoPez7U5OfgKswR8/EaZ/MxsE/Th+pm8diDIMsEB0Ajtg9Xgvv pVuMHpt38dcMjeYvrD27P7+e2y8JgvK7TSk1bJAF5dRld4CyLOUKGa527epsvLfiTKfQ iaiXdkY+GQx7uveNH46zKmnzeEGImzlCxhCX7lw2pYxNbTSh0vfD8avgM91af18DghzJ 6H3XqjzKNCKG5NfNMuqobYTgIfsW0k3DkpVG0ITeKiz2SY5F6fzyiGfTegQghkD/miW3 +hqyhRRAaN0k9V2gCXNHXyMB9G6DsUn5fHdqyt3Hr5wzcAHHZ21prgkgLWZA+xlyn517 0RGg== 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=TnwgvlgKZzgDcW1p8jYLFZ+O7mxKkO66Ee7GWaCiVz0=; b=fANs16JFJs0cwReeNYI30u/N4BnYg4XmxJZ7vbrvdro4bgXN0xLv+gyaF4cFCRYM7F qeNH61gI9zPsNwzNmXI+t5VnN0+IXXOQagf2pV2U0hqn3pX0Ii41CKw/k91mn4D25jPl Q+Bomld0sQ51tCzcdgLTk/XApkVtCb0wmrDhDWupuOH+75nScx7821rAJHRPIkd8pzvi zQ0l+1gsNIZXXvtTJNqqlYw6aOwzJP7/pKYP42MFlKnJtWdI9MMAF45o/6ll+yKRNgio EcwCvh30kfAkKVHBB+FosGB/bqdBRVlIfabGHYyJiUozKfWF0XuZY3uRvs1N293QLf9M T6xQ== X-Gm-Message-State: AHQUAuYH1s9FfUv+SkQI11qGWV6mHaw3evDeJPHLW+nwuF/vtvsebVx6 3zXGw5/uxTPevsGZN+h9BF0= X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr12747662pll.33.1550276151603; Fri, 15 Feb 2019 16:15:51 -0800 (PST) Received: from abbey.corp.xevo.com (hq.xevo.com. [4.14.243.50]) by smtp.gmail.com with ESMTPSA id k66sm12343287pgc.24.2019.02.15.16.15.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Feb 2019 16:15:50 -0800 (PST) From: Jim Broadus To: ckeepax@opensource.cirrus.com, benjamin.tissoires@redhat.com, wsa@the-dreams.de, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jim Broadus Subject: [PATCH] i2c: Allow recovery of the initial IRQ by a i2c client device. Date: Fri, 15 Feb 2019 16:15:33 -0800 Message-Id: <20190216001533.5465-1-jbroadus@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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.20.1