Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp179543ybs; Tue, 26 May 2020 06:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3nxfv3/7oPP943FFywU/naFo8IHqoSaxlejOkcbmCI5NHXBhziv/erlQqitId/rchPLo5 X-Received: by 2002:a17:906:395b:: with SMTP id g27mr1215317eje.41.1590500422066; Tue, 26 May 2020 06:40:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590500422; cv=none; d=google.com; s=arc-20160816; b=dmUTcAwo8yYfXobdK/WCVss3WtF38Luy2Zi2zKkkDpusZ1ytAVZBgrQ5ZZ0dHOu5m8 ejqQYYd2X+aa7YxyKda0+C0gYObipMaVpUDKYm23vZ0rItC+3ToDR0+ssmmOl7YIfmUX r1DrCOnUO2n30cphLE2QO6tQBDSLPAL1UwsajwVdP6UNVqt/Jwd5JE2QYhZ22/RlBTgc 0sw9DYs7XJ3KMShURTlM90HN8So2/63mrYtcD3pZPUmKtH2rumLI7pUS+huVAcvij0fn Jvpv7Zet+pJqAqfezFhzjQU3nJ8KObAVaQ30ksuIYeQV8+6MElsyR2+SvSPWScgZvdc0 xf5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=p3D8tRzx5yi3dtudAYjOJKQoizPNsipgyxf+bvB/VrM=; b=wIsWwu0TgTJMEgLU4Imr0xT9ul4ck38kWFcZ0X4P7nWrJ1U/WU29BY2sQmEMLrCgSR 9C5D/e0DY/S7SebW/yZG7qCG+EpRAiHPVqG/orE0XclK7uTsODpvDRURM1Ed8rXAhqhu 4PuwQ1hXa8EIGNAkR3wElYsDorMpxezGT36+tI7V2Z9ySHISWz7yd/Qj0dRmmaiEUfk/ no4DgkkptLnDT8uCl7pPwpyePMClrVHQZCoJbteIYclXIb/9iS0Ex7Hbd1UmB6BPSlfU j4niAI2zJ4sRuAPdXGYoXgiWxlnfhCd8rmNcwl4B2uHsME3IWEVcLHVdj79pnn/iujy9 TWDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=OyLNlCe1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf7si11571406edb.292.2020.05.26.06.39.58; Tue, 26 May 2020 06:40:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=OyLNlCe1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731840AbgEZKXX (ORCPT + 99 others); Tue, 26 May 2020 06:23:23 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:22910 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbgEZKXW (ORCPT ); Tue, 26 May 2020 06:23:22 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04QALs08009674; Tue, 26 May 2020 12:23:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=STMicroelectronics; bh=p3D8tRzx5yi3dtudAYjOJKQoizPNsipgyxf+bvB/VrM=; b=OyLNlCe1CWQeq2gKXTCrGyYEX9CZYQP6JsUgiRs9gGBKD2v2mCcnxRx4grsbzE1p50KE jRozQrfLn0LDTOrO2vLJJnPBgLm8vLQE6RrIZRTUHW8pIAxdIGHqbhuOGWk12V3c3uGW gjizCURYNy6w8wc7OEcgVrnt217nPDapCs2+nDf+nld2qBGCwJ7/EFwzAomPOdUNSMDP rOTfRAoKZr5qd+TLx4kU/p8J1JYYole3YKqbPPRQ2HWO7oxE96ath2dCZwb5cXG+LOJm KjV3X+/ERIB02bwxj9RbdAEy31XO1uf7lODvHcWLpWw6xex1vM/6He4MV0Y3YqDEfTB+ dg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 316sa1y741-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 May 2020 12:23:07 +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 52FDB10002A; Tue, 26 May 2020 12:23:07 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2213C21BDB7; Tue, 26 May 2020 12:23:07 +0200 (CEST) Received: from gnbcxd0016.gnb.st.com (10.75.127.44) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 26 May 2020 12:23:06 +0200 Date: Tue, 26 May 2020 12:23:01 +0200 From: Alain Volmat To: Wolfram Sang CC: Benjamin Tissoires , "robh+dt@kernel.org" , "mark.rutland@arm.com" , Pierre Yves MORDRET , "mcoquelin.stm32@gmail.com" , Alexandre TORGUE , "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Fabrice GASNIER Subject: Re: [PATCH 1/4] i2c: smbus: add core function handling SMBus host-notify Message-ID: <20200526102301.GA14423@gnbcxd0016.gnb.st.com> Mail-Followup-To: Wolfram Sang , Benjamin Tissoires , "robh+dt@kernel.org" , "mark.rutland@arm.com" , Pierre Yves MORDRET , "mcoquelin.stm32@gmail.com" , Alexandre TORGUE , "linux-i2c@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Fabrice GASNIER References: <1588657871-14747-1-git-send-email-alain.volmat@st.com> <1588657871-14747-2-git-send-email-alain.volmat@st.com> <20200523104624.GB3459@ninjato> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200523104624.GB3459@ninjato> X-Disclaimer: ce message est personnel / this message is private X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) 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-05-26_01:2020-05-26,2020-05-26 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 23, 2020 at 10:46:25AM +0000, Wolfram Sang wrote: > > Adding Benjamin who mainly implemented this. > > On Tue, May 05, 2020 at 07:51:08AM +0200, Alain Volmat wrote: > > SMBus Host-Notify protocol, from the adapter point of view > > consist of receiving a message from a client, including the > > client address and some other data. > > > > It can be simply handled by creating a new slave device > > and registering a callback performing the parsing of the > > message received from the client. > > > > This commit introduces two new core functions > > * i2c_new_smbus_host_notify_device > > * i2c_free_smbus_host_notify_device > > that take care of registration of the new slave device and > > callback and will call i2c_handle_smbus_host_notify once a > > Host-Notify event is received. > > Yay, cool idea to use the slave interface. I like it a lot! > > > +static int i2c_smbus_host_notify_cb(struct i2c_client *client, > > + enum i2c_slave_event event, u8 *val) > > +{ > > + struct i2c_smbus_host_notify_status *status = client->dev.platform_data; > > + int ret; > > + > > + switch (event) { > > + case I2C_SLAVE_WRITE_REQUESTED: > > + status->notify_start = true; > > + break; > > + case I2C_SLAVE_WRITE_RECEIVED: > > + /* We only retrieve the first byte received (addr) > > + * since there is currently no way to retrieve the data > > + * parameter from the client. > > Maybe s/no way/no support/ ? I still wonder if we couldn't add it > somehow. Once we find a device which needs this, of course. Indeed. Such support can be added later on once such device is found. For the time being I will state "no support" > > > + */ > > + if (!status->notify_start) > > + break; > > + status->addr = *val; > > + status->notify_start = false; > > + break; > > + case I2C_SLAVE_STOP: > > What about setting 'notify_start' to false here as well? In the case of > an incomplete write? Ok. I will check that notify_start is false before calling host_notify (since otherwise it will call i2c_handle_smbus_host_notify with a bad addr value) and reset notify_start to false if it is still true. > > > + ret = i2c_handle_smbus_host_notify(client->adapter, > > + status->addr); > > + if (ret < 0) { > > + dev_warn(&client->adapter->dev, "failed to handle host_notify (%d)\n", > > + ret); > > I think we should rather add such error strings to the core if we think > they are needed. I am not convinced they are, though. Agreed, this error can be removed. > > > + return ret; > > + } > > + break; > > + default: > > + /* Only handle necessary events */ > > + break; > > + } > > + > > + return 0; > > +} > > + > > Rest of the code looks good. Maybe we should compile all this only when > I2C_SLAVE is enabled? > Yes, I will enclose that around I2C_SLAVE support check.