From patchwork Thu Jun 25 07:39:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alain Volmat X-Patchwork-Id: 11624717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD34A138C for ; Thu, 25 Jun 2020 07:42:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5F8F20663 for ; Thu, 25 Jun 2020 07:42:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ERSOr4mQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="GXcV/xxt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5F8F20663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZBAFebtev2gBXgQk3+3fOK1GK8RZWK2Ehm7YJ93bQk4=; b=ERSOr4mQSzFem07l61N5m7Jtb ohYUViUl/JeNBvRGm0qrlhElO+ATv0ogSyFjy70IHymVZ1qq8J8QQ2AAYnlYrAX9bjdCcy1FppSct SGQU9NOObHfhrhqBCevuwGTD9DN18Eqay1nT1seLLZ/EeN7Ea7SbmTcr0W3tafqH454TSlfL1t+Ni H6/yU7BPaG/b+1zfKiAtWY0Ddxy9ihQ7PrGxScU2ZjW/ysDRnivJ/SV2EFJ3dD+x4nUwFcK0W/32k 4dmLf29ilYX4REOApdgv68xf+vwi4cmw07zSGurQqKbwnrL5sQeiJP0rHKrUpQ5c5l7/qmD2odlq8 OIYq0hx1w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joMUW-0003gQ-7m; Thu, 25 Jun 2020 07:40:12 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joMUJ-0003c2-VU for linux-arm-kernel@lists.infradead.org; Thu, 25 Jun 2020 07:40:01 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05P7djCN018742; Thu, 25 Jun 2020 09:39:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=B7ajrBgreKK0clsVTdK1y2OSMqOBYMm31F6kF44CZ5o=; b=GXcV/xxt2JzujKSKEJ0cvS4GVLXnValQ9eUM/YNJcX1/MIp2koy0Wy7ruATMxQX6VG+O Qle7wIkSzPgyy37Sr23EKRV/jhCez4rEzgxjuwofIFa1+NkI8H/SATGI95nOqTwFhjlt uz2aoBF362cXjfznk29L6ZdgOchNNP4b3lKYJZ2Fbfdx9ceQvHenhDMuFthP8awxCAjO 0gY9YHotmS41uYxhJz+8LYHFSMQd7NJ8rdmvxmF/0kEQmJ91GA2SX0Z8lZrF9eKX9mx6 qDf2gSA7qK9qZRmjuJcuMe4u0gwqaEem5vgciyNMHENutrGob6IvS6vuwdka598oFlCj 8w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 31uuumghkn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 09:39:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 31E71100038; Thu, 25 Jun 2020 09:39:51 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 267142A82E2; Thu, 25 Jun 2020 09:39:51 +0200 (CEST) Received: from localhost (10.75.127.49) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 25 Jun 2020 09:39:50 +0200 From: Alain Volmat To: , Subject: [PATCH v2 2/4] i2c: addition of client hnotify reg/unreg callbacks Date: Thu, 25 Jun 2020 09:39:27 +0200 Message-ID: <1593070769-9106-3-git-send-email-alain.volmat@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593070769-9106-1-git-send-email-alain.volmat@st.com> References: <1593070769-9106-1-git-send-email-alain.volmat@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG6NODE1.st.com (10.75.127.16) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-25_03:2020-06-25, 2020-06-25 signatures=0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.207.212.93 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alexandre.torgue@st.com, linux-kernel@vger.kernel.org, pierre-yves.mordret@st.com, alain.volmat@st.com, linux-i2c@vger.kernel.org, mcoquelin.stm32@gmail.com, fabrice.gasnier@st.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Addition of two callbacks reg_hnotify_cli and unreg_hnotify_cli that can be implemented by adapter drivers in order to take action whenever a client with HOST_NOTIFY flag is being registered to it. Signed-off-by: Alain Volmat --- v2: replace generic client reg/unreg callbacks with host-notify client reg/unreg callbacks drivers/i2c/i2c-core-base.c | 18 ++++++++++++++++-- include/linux/i2c.h | 8 ++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 26f03a14a478..46745e403e98 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -319,6 +319,14 @@ static int i2c_device_probe(struct device *dev) if (!client) return 0; + if (client->flags & I2C_CLIENT_HOST_NOTIFY) { + if (client->adapter->algo->reg_hnotify_cli) { + status = client->adapter->algo->reg_hnotify_cli(client); + if (status) + return status; + } + } + driver = to_i2c_driver(dev->driver); client->irq = client->init_irq; @@ -415,8 +423,11 @@ static int i2c_device_probe(struct device *dev) dev_pm_clear_wake_irq(&client->dev); device_init_wakeup(&client->dev, false); put_sync_adapter: - if (client->flags & I2C_CLIENT_HOST_NOTIFY) + if (client->flags & I2C_CLIENT_HOST_NOTIFY) { pm_runtime_put_sync(&client->adapter->dev); + if (client->adapter->algo->unreg_hnotify_cli) + client->adapter->algo->unreg_hnotify_cli(client); + } return status; } @@ -442,8 +453,11 @@ static int i2c_device_remove(struct device *dev) device_init_wakeup(&client->dev, false); client->irq = 0; - if (client->flags & I2C_CLIENT_HOST_NOTIFY) + if (client->flags & I2C_CLIENT_HOST_NOTIFY) { pm_runtime_put(&client->adapter->dev); + if (client->adapter->algo->unreg_hnotify_cli) + client->adapter->algo->unreg_hnotify_cli(client); + } return status; } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index b8b8963f8bb9..35ad108adc68 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -507,6 +507,10 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info, * so e.g. PMICs can be accessed very late before shutdown. Optional. * @functionality: Return the flags that this algorithm/adapter pair supports * from the ``I2C_FUNC_*`` flags. + * @reg_hnotify_cli: Callback informing that a new client with HOST_NOTIFY flag + * is being registered + * @unreg_hnotify_cli: Callback informing that a client with HOST_NOTIFY flag + * is being removed * @reg_slave: Register given client to I2C slave mode of this adapter * @unreg_slave: Unregister given client from I2C slave mode of this adapter * @@ -543,6 +547,10 @@ struct i2c_algorithm { /* To determine what the adapter supports */ u32 (*functionality)(struct i2c_adapter *adap); + /* To inform the adapter of the probe/remove of a HOST_NOTIFY client */ + int (*reg_hnotify_cli)(struct i2c_client *client); + void (*unreg_hnotify_cli)(struct i2c_client *client); + #if IS_ENABLED(CONFIG_I2C_SLAVE) int (*reg_slave)(struct i2c_client *client); int (*unreg_slave)(struct i2c_client *client);