Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3907415imj; Tue, 19 Feb 2019 11:34:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia+A54bl27CnNrDDYOGN6bDNl2KVWG7/kAVqJ/39WFfl+D9qE0Wj9Y+lSqktixhcJey0p68 X-Received: by 2002:a17:902:8b8b:: with SMTP id ay11mr2124998plb.162.1550604847478; Tue, 19 Feb 2019 11:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550604847; cv=none; d=google.com; s=arc-20160816; b=MBcUpuUQuXKSJ1g6M+32TftsKJc7ADU0XuY6sox9mn1BKyEe+K3d29HAzKvF7b6iln cb9qW9CLN4G3ZXcxIaBuAl/oQul14g2zbcfmfzNbV+zN9vVQzeHgCVPAyIiRw7KOIiJP OMubz/WgVrPbck9p7CaK+UPs56EmT0xDdBUmaDGRpIK5i62YceKrQLNAvrnxBAfkeAwq DLIYt5oxuzLFaz7dVtOjfK32Kvo8tDZCG+1qbCbE8+pX5EYWVCzKYuL/jfMa3kuT/H92 QcVt+R6dQRcdIvoG2wwW3Awbn0M1k4n6ZyKakcOyZG5/idzGqkEk0Rk44KLi20eYZOfO +WUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Pa5SyLYvT8lSMiPEf74ApKPdq55Rw/H7rCnoXk1VjGE=; b=z9Kkmba+kAkKIHQtagztDvN572JuZSyx+3rynScAEEwMG3kOiojlwcgY35QHP281nO ByoGIijnjGsfr50LDHcoqA+Lrkb44574FQH4JtzUSfbRl8Vb2R3DS0tfva7fDiWW1wC8 7+JOrIfMKpqtzGzwfo7eWmpEWB/Efy2wZsGiZr7yNN19luKlTFYUfqY7E8MdB70y00Nw ZLqFHAXzwmy3e0ut46/3FRUVD6ZPzK02Xb8ebPnLvLnlcrM/1H+SvJmndMyJPd4m/JP0 AXknpWp89FpPNWtw8oIGRDnN9qsShBRjsDVEZvfPaD/7XlnG0dZGqlZ4Xf9JGdrp+U2R t0dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FGV93vXC; 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 h85si16851484pfd.27.2019.02.19.11.33.51; Tue, 19 Feb 2019 11:34:07 -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=FGV93vXC; 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 S1728213AbfBSTc4 (ORCPT + 99 others); Tue, 19 Feb 2019 14:32:56 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34286 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbfBSTc4 (ORCPT ); Tue, 19 Feb 2019 14:32:56 -0500 Received: by mail-qt1-f193.google.com with SMTP id w4so24589329qtc.1; Tue, 19 Feb 2019 11:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Pa5SyLYvT8lSMiPEf74ApKPdq55Rw/H7rCnoXk1VjGE=; b=FGV93vXC03JU3RHhdkUbmQeg8cjTSjibnfT3NBJqXa1WDjTuXQffTPvVGAS35ZoTZJ ue/13Y8V7AMAfkM0W71EnXUH0jV/SwbOlr7iESfE4njVyVs/AwFEP2JZZId98pi2CC7H vJTiSTB5D+1mdK3egbVphe9z0EuGI6IYgz0QESuCoJqtbnmM0XqDUeGDaTP8UHJLUHpz f7fKg+hW9MMRmB0Z4g6fyvW+oHv5DHKX6hnnKo31/t+qrgCY3+xLDw1qgiVGlBrr9bF3 xH/QByjWYefWNlkpoZGofD9RYOXn2DUDRZgldogqZgfBjxT+mSHbh7NQqcw1KkpuAVFH 3DlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Pa5SyLYvT8lSMiPEf74ApKPdq55Rw/H7rCnoXk1VjGE=; b=CRNLLucg3baEr9WF6OJy6uSMPMMyvoeaHFu/UeZEOuHGsT9/kIA8V2TnAeu0I2ZPUd vkn1c+E9+AWkfPx45wtkoKfa0zRgnMc6RzCvcQ3nWvvAphsN3kY6HA/ED8AdBcJB9RCb eFa60sfukfA+ezZzveBwzcEdXpuB5gEeIdClpBfE5ybz7yq85+X3DcIuyDxYMcaNekHh 68ZV8KqkMn9AkB/HdwjI1vX/XsL5W0wzZOQvx93bcix9t0Pt21bguumga1qxXTRlvWhR tqcLHXBUdql6XG7HojhbIXni47YOYjx8Q8nmvcckR04McoJ3vwNs0qfGVB9qXDKLNMFO KGAg== X-Gm-Message-State: AHQUAuYbhzppuGGemTDxBpKM1OpdqxjPrA2oirC3c8q8Q5cJAnzdXKWp KdnsYTuBxwDyhHFLFPIlLOhAO2aUwRlsmrP13KA= X-Received: by 2002:a0c:b590:: with SMTP id g16mr6268620qve.146.1550604774754; Tue, 19 Feb 2019 11:32:54 -0800 (PST) MIME-Version: 1.0 References: <20190219193027.13882-1-jbroadus@gmail.com> In-Reply-To: <20190219193027.13882-1-jbroadus@gmail.com> From: Jim Broadus Date: Tue, 19 Feb 2019 11:32:43 -0800 Message-ID: Subject: Re: [PATCH] i2c: Allow recovery of the initial IRQ by an I2C client device. To: Charles Keepax , wsa@the-dreams.de, linux-i2c@vger.kernel.org, Linux Kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apologies.. This should have been marked v2. On Tue, Feb 19, 2019 at 11:30 AM Jim Broadus wrote: > > 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 >