From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C03A3C433DF for ; Thu, 2 Jul 2020 11:24:35 +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 8BDB220B1F for ; Thu, 2 Jul 2020 11:24:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nmZadCoB"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="tK4jwZSo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BDB220B1F 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+linux-arm-kernel=archiver.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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CGUOaLFZXoOKg2g+aulnTLzpVPM7+2jgtT//jLx+UHc=; b=nmZadCoBmr337Yu11vVQLEBvP rM4nACQ9LvToPFKZfPpFc+jnq0BmyM7ffLQQKLPlyTAdY6zICmbZTF2jfl5SPwZDskWvcq3G1Sx/C uywvebrJm5LW2aiJcO3mx/K1QUYxxxaMogDz9LOIGoRRZID/KCrg2QLUAzomk3PeI9BWHAtvaS18q 5s5DoOzQiYS/ImK6+Le5INwCTb0UoGEEXbK+TWOXMRrFiMPQPsFAY7+gwzZtiOPxx6dcQOM4qN0+w ZstKy15Ic9Y2OslxcnU3kbPjq7FBTW99CIGo0F+AvZX2eux9TN0/PFY5hoUF3QJVOk90+j3U2t6vm yBJF1GNoA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqxJN-0002W4-HS; Thu, 02 Jul 2020 11:23:25 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqxJK-0002UT-Ae for linux-arm-kernel@lists.infradead.org; Thu, 02 Jul 2020 11:23:23 +0000 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 062BG4IJ003106; Thu, 2 Jul 2020 13:23:15 +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=5WRolsP7RiTQVKYQWxXnd4r13bZrvjWmpEgS8eL44Vo=; b=tK4jwZSoCzqQvFoTTJc/3BLffPTvaB6X2vqCxqU71etrfo3J3A2ZSnsgdX+Fi8F15yzP 7x8RQDer+5OQrNS30yHcOjEEuqExVvYsoDcdYjuk0iS4gFDomdakmL/bT8eokV95ze2f NW8tMbSonOUUqCG6ybcXoRCgaJO1NdtcUhjY+2WrHG1l0mrhqRf8onRqTLzXNo+8ICwJ THtV4lEfmN0Tujg28nNYIkoJgS9FfBcZqYP0BVQMjM0epfycULeqRIAGiAsq4YgUY/Ti srMoj3Bn92Wt04cY1yBX2370pLrB8GxsjGjJOrhxNj6wVl14hF5pA5Bl9VCYrVeDmrQg 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 31wuk1qqj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Jul 2020 13:23:15 +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 D295C10002A; Thu, 2 Jul 2020 13:23:14 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B88812AFEEF; Thu, 2 Jul 2020 13:23:14 +0200 (CEST) Received: from gnbcxd0016.gnb.st.com (10.75.127.47) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 2 Jul 2020 13:23:13 +0200 Date: Thu, 2 Jul 2020 13:23:13 +0200 From: Alain Volmat To: Wolfram Sang Subject: Re: [PATCH v2 1/4] i2c: smbus: add core function handling SMBus host-notify Message-ID: <20200702112313.GE6855@gnbcxd0016.gnb.st.com> Mail-Followup-To: Wolfram Sang , 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 References: <1593070769-9106-1-git-send-email-alain.volmat@st.com> <1593070769-9106-2-git-send-email-alain.volmat@st.com> <20200701104946.GH2261@ninjato> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200701104946.GH2261@ninjato> X-Disclaimer: ce message est personnel / this message is private X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-02_05:2020-07-02, 2020-07-02 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200702_072322_676045_42426CC4 X-CRM114-Status: GOOD ( 23.70 ) 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, robh+dt@kernel.org, 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Wolfram, > Okay, now I got it to work, I also noted a few more issues. > > First, I'd suggest s/i2c_smbus_host_notify/i2c_slave_host_notify/g for > all occurences in this patch. This makes a stronger distinction between > the generic HostNotify support and the slave specific one. Ok with that. > Also, I wonder if this shouldn't go to i2c-smbus.c instead but I haven't > checked if we end up in dependency hell then. Second best thought: at > least move to i2c-core-slave.c, then we could save the #ifdeffery in the > c-file? I have actually difficulties to understand clearly what should go within i2c-smbus.c vs i2c-core-smbus or i2c-core-slave. My feeling is that i2c-core-slave is more about the registering of a slave rather than one usage of the slave mechanism. Hence I am not sure those functions/cb belong there. But at the same time, I don't know about i2c-smbus vs i2c-core-smbus. I putted it within i2c-core-smbus considering that the creation of the alert device is also done there. .... > > +{ > > + 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 support to retrieve the data > > + * parameter from the client. > > + */ > > + if (!status->notify_start) > > + break; > > + status->addr = *val; > > + status->notify_start = false; > > So, we are safe if the message is too short. Otherwise, we capture the > first byte (== address) only, right. Further bytes until STOP are > discarded. So, we don't check if the message is too long and contains > more than the status word. Maybe we should add that? Yes I modified that. > > + break; > > + case I2C_SLAVE_STOP: > > + /* In case of incomplete write, don't handle host-notify */ > > + if (status->notify_start) { > > + status->notify_start = false; > > + break; > > + } > > + > > + ret = i2c_handle_smbus_host_notify(client->adapter, > > + status->addr); > > + if (ret < 0) > > + return ret; > > + break; > > + default: > > The missing cases are mandatory. From my testunit driver: > > case I2C_SLAVE_READ_REQUESTED: > case I2C_SLAVE_READ_PROCESSED: > *val = 0xff; > break; Ok, done as well. > > --- a/include/linux/i2c-smbus.h > > +++ b/include/linux/i2c-smbus.h > > @@ -38,6 +38,8 @@ static inline int of_i2c_setup_smbus_alert(struct i2c_adapter *adap) > > return 0; > > } > > #endif > > +struct i2c_client *i2c_new_smbus_host_notify_device(struct i2c_adapter *adapter); > > +void i2c_free_smbus_host_notify_device(struct i2c_client *client); > > Those need to be guarded with I2C_SLAVE as well. And an #else branch > with empty/successful placeholders. Ok understood. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel