From patchwork Mon Mar 11 11:05:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 1054363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44HwJV4DdVz9s47 for ; Mon, 11 Mar 2019 22:06:02 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfCKLGB (ORCPT ); Mon, 11 Mar 2019 07:06:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35030 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfCKLGA (ORCPT ); Mon, 11 Mar 2019 07:06:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0304307DAAD; Mon, 11 Mar 2019 11:06:00 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-37.ams2.redhat.com [10.36.117.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71EF410018FF; Mon, 11 Mar 2019 11:05:56 +0000 (UTC) From: Hans de Goede To: Wolfram Sang Cc: Hans de Goede , linux-i2c@vger.kernel.org, Charles Keepax , Benjamin Tissoires Subject: [PATCH] i2c: Do _not_ clear client->irq on remove if the irq comes from the board_info Date: Mon, 11 Mar 2019 12:05:55 +0100 Message-Id: <20190311110555.30653-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 11 Mar 2019 11:06:00 +0000 (UTC) Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Commit 6f108dd70d30 ("i2c: Clear client->irq in i2c_device_remove"), makes i2c_device_remove set client->irq=0, so that irqs assigned by i2c_device_probe get cleared (and re-assigned) when rebinding the driver. This breaks driver-rebinding for i2c_client-s where the irq comes from the board_info, since the irq from the board_info is now lost after the i2c_device_remove call. This commit fixes this by not clearing the irq on remove if the irq originally came from the board_info. Fixes: 6f108dd70d30 ("i2c: Clear client->irq in i2c_device_remove") Cc: Charles Keepax Cc: Benjamin Tissoires Signed-off-by: Hans de Goede --- drivers/i2c/i2c-core-base.c | 5 ++++- include/linux/i2c.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 28460f6a60cc..c3d94ffdff29 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -430,7 +430,8 @@ static int i2c_device_remove(struct device *dev) dev_pm_clear_wake_irq(&client->dev); device_init_wakeup(&client->dev, false); - client->irq = 0; + if (!(client->flags & I2C_CLIENT_BINFO_IRQ)) + client->irq = 0; return status; } @@ -745,6 +746,8 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) if (!client->irq) client->irq = i2c_dev_irq_from_resources(info->resources, info->num_resources); + if (client->irq) + client->flags |= I2C_CLIENT_BINFO_IRQ; strlcpy(client->name, info->type, sizeof(client->name)); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 65b4eaed1d96..1ff3c78a6c1b 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -769,6 +769,7 @@ i2c_unlock_bus(struct i2c_adapter *adapter, unsigned int flags) #define I2C_CLIENT_SLAVE 0x20 /* we are the slave */ #define I2C_CLIENT_HOST_NOTIFY 0x40 /* We want to use I2C host notify */ #define I2C_CLIENT_WAKE 0x80 /* for board_info; true iff can wake */ +#define I2C_CLIENT_BINFO_IRQ 0x100 /* irq comes from the board_info */ #define I2C_CLIENT_SCCB 0x9000 /* Use Omnivision SCCB protocol */ /* Must match I2C_M_STOP|IGNORE_NAK */