Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp996223ybr; Sat, 23 May 2020 03:48:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2ZpJ9N0VQvphkCx8j+fp2VMBDbOcXFNGmLA+upjMA5iMT8LRpnAdIrnubINanPnlRy0G7 X-Received: by 2002:a17:906:578a:: with SMTP id k10mr11051177ejq.297.1590230916817; Sat, 23 May 2020 03:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590230916; cv=none; d=google.com; s=arc-20160816; b=U3tFJNN4BvWpGNO0Wzp4+H4QiQ3xOraohJ6Y8CXoNlwvIUn5OFk582XRFhNaN9HxM9 EFOXQ676NehHrHg4Es2/uyKiiLGMw1AISicZw5PD0Vjce1bsbsXOa3YGM0Lmiitfb//K zyhX2SdZvNaSPB2dEXR92kXcYmmPGbY/0OvcWHxLOgbdcopHBKTZ2xcsK84Q+LeAZV8w eyHCvuPJNggiBanMBPv4VCy9IBgzmIFSV3lK+k0a2HKrXhR0ai8PpA9BTDnN8wIXqZRn mk60U7cPY6ooz75VbxIlZ53hi8GMPSDbleJlEGEABWHXnqdDpiNfVFFf5ti600EF+wlL g6uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gC+L9KfXd87cISUbRdf89TpYaQVn7eKqqh1380Cp9qs=; b=uROrlVJhm5ke52cTseKNdZt4pd6kgbVSl9iy0bH3d9zx/W9unDXGDjmNWtIhlK4T8/ 96bbuWqY3di13+n0KpOjsVIXJ6KhEGInbkI2obyKDpTNdb/ELoTZOK+mUCIB8CG25pMN MxJcJsDUoUh1hTARQnDs91aQyqKYAVnWdEYdixmSRB1vnkcjuPTeb7Sb/Y54cynZeVmi QT+YuZFPaAtiR28UFd02uZmhLvFHSiMCU5GhlVc1hqr2o+UzHQP+QEGGJ1xLqSO/h2PX wv5RG8STOcyR1PsjSpJGat7A84Iq78GAG2vbhYruHorP95Dcrj6Axe1dzbHa1i2Ndcz7 OI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dkhtftQ/"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si6290531edy.216.2020.05.23.03.48.13; Sat, 23 May 2020 03:48:36 -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=@kernel.org header.s=default header.b="dkhtftQ/"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387749AbgEWKq3 (ORCPT + 99 others); Sat, 23 May 2020 06:46:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbgEWKq2 (ORCPT ); Sat, 23 May 2020 06:46:28 -0400 Received: from localhost (p5486c962.dip0.t-ipconnect.de [84.134.201.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4740E2071C; Sat, 23 May 2020 10:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590230788; bh=pbReTCTmAIHmTd4BJrQV3YAqM3Cg2azMISSPySR/VeE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dkhtftQ/UB2JXoW8P545devsy9L/piU0uizM9rj9bh9fsgUV27y1zesvuLCrCYqb4 ex99CvspcJLpmfp36jRcZUNvzuJj2aH/KIqA2Z/lAWh3C3t7erD8w209kJPvzhrcrt JMWBvyOa/VKZvl4R9niA0/QJ2mgpf9oYRCZpAfFU= Date: Sat, 23 May 2020 12:46:25 +0200 From: Wolfram Sang To: Alain Volmat , Benjamin Tissoires Cc: robh+dt@kernel.org, mark.rutland@arm.com, pierre-yves.mordret@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, 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@st.com Subject: Re: [PATCH 1/4] i2c: smbus: add core function handling SMBus host-notify Message-ID: <20200523104624.GB3459@ninjato> References: <1588657871-14747-1-git-send-email-alain.volmat@st.com> <1588657871-14747-2-git-send-email-alain.volmat@st.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WYTEVAkct0FjGQmd" Content-Disposition: inline In-Reply-To: <1588657871-14747-2-git-send-email-alain.volmat@st.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --WYTEVAkct0FjGQmd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > 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 =3D client->dev.platform_da= ta; > + int ret; > + > + switch (event) { > + case I2C_SLAVE_WRITE_REQUESTED: > + status->notify_start =3D 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. > + */ > + if (!status->notify_start) > + break; > + status->addr =3D *val; > + status->notify_start =3D false; > + break; > + case I2C_SLAVE_STOP: What about setting 'notify_start' to false here as well? In the case of an incomplete write? > + ret =3D 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. > + 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? --WYTEVAkct0FjGQmd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAl7I/wAACgkQFA3kzBSg KbbXgQ/+LcMC7QayI4s8Dvz6JvDUJwv5Hb0sbJhWY6hZjTukOGuxIPjrqZ/TqNGN FAqr4fNEgfEH2wJw2zvuMUlqkVhAgfnw5/DtOOzDGhmogXa8eyP8VCBA35wNkLv7 glMCNfuaWYvQMZv0Ftr8atBoONlIofe0s7yIABC0KginLoUqTMLIGOzM4+JWAQ9o l4n8aoWdmZL1/TksIOhN6UK0uxup3MPvL3KGCFh8YwFRxvRvEZOcvxbcXjZstQd3 5Rf0BYf85c0vVOxXY0V7tNUVSZtcgkKr0yyrFtRwpI0EaFwx6lR9zrclPeNZQd9p xHwp/i3DSUL69SPOgCgeaOglKUEZqNk8i8RzBDcGBtiih5illJH+6gXuYcS9GfR2 XJgUybgtl9dQwIcr4KkZraayA4SNBiXwNcjOn1CqunS3Xv21Ep8dW3HTkv6opO1f u1j43ZN/51NATCPp/I6OdSQqpfMhpds4BPjrAm96ZygEVYHWqAdOOs/IK2Rvdnw5 0yQBdpeqWP+oFpL/W0uUcS+u5pMjQSL8SA9hxav4FuitaECBsgeFU+k7O28Qsv4g 9w6QKh7X9oEbbiG22YLNJ+/pGbijqMSRASEyYsu6wh3GsJ/RqIC1WnsGztdNwDtR 8GXDv+ja9iaSIc28HjfMszo/vbXSlU2MJ7SwWOG1H2sFxQO3ZNw= =EXgv -----END PGP SIGNATURE----- --WYTEVAkct0FjGQmd--