Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp73402imm; Wed, 3 Oct 2018 12:06:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV63D91K4D2bQCJCesCiVWgQ6mtBdzpwHGQAKDBELhtsR1fV7EjTsIjUcUpB9jfxsNhxRvbPA X-Received: by 2002:a63:d84a:: with SMTP id k10-v6mr2638861pgj.314.1538593618055; Wed, 03 Oct 2018 12:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538593618; cv=none; d=google.com; s=arc-20160816; b=xhG4s8/VV2mm52Pt57/gXhXZkcENIQ3Qj9wsXvcSSV/emr8zEVq5HkWsAySt7TZJI3 b7iDJJCHxOTvlsk6kTy5xGbWmqvzMvjM6iw773treA8qOjM/bxfDKpvGRTr0lQJjiD0J V2n7YcyLSTYaYBwVh0MYp89TiANgzuRXoSG3K5u9VS3vp0Pw07PLIH3Sz7pthJeNoXsS PeZF6vHG2mMYD5egOlPwGwgW6l6rBKz48u55oF0O4pcwxFHjdnd/timNjKPD9QuijULl AOoS0ptqeGJmdj9xVkt0huFBs3KDTD/M+5ZCFiKpscTAyaIiLix+AY89wHeuyjVz+56s Qntw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=w5nUuF/59Mds8wDwy+E43mlUgYjRZYshxoz6oo4sAzU=; b=oYjAMKJSA41mMURfn6WHNLOj4cRfO7LO6ZQHAUqRmBIfL7MHR+islTduYOUs48W9PA Bre4/nrPx2UmOyvsi5c/ylOGc3zXgQCgQ6wANZQu09cGUEuv2XIghAyaUTS1ckUaM25M vT0KiOICQeGMsAXGgDyWI4eLTrDopb5MU9bxGbSv4kVfFm5RUCCfrEIix9WlBcGcsC2S pGeXXKTxElaIuvBXuhtZGH7etQtwaS17e7hL+ci3NhNT98bT3diu6ix33FNvEMkCht9O UlDdwXrP75R1Mt3bXHSDbvAH9BVK1BPG2qpx6e35Mikph6sGeubskH6DvJ3YCy1szrsU x8rQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s130-v6si2806735pfc.81.2018.10.03.12.06.41; Wed, 03 Oct 2018 12:06:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbeJDBz4 (ORCPT + 99 others); Wed, 3 Oct 2018 21:55:56 -0400 Received: from mail.bootlin.com ([62.4.15.54]:47668 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbeJDBz4 (ORCPT ); Wed, 3 Oct 2018 21:55:56 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 51961207C3; Wed, 3 Oct 2018 21:06:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 7E79420719; Wed, 3 Oct 2018 21:06:12 +0200 (CEST) Date: Wed, 3 Oct 2018 21:06:13 +0200 From: Boris Brezillon To: Joe Perches , Rob Herring Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Greg Kroah-Hartman , Arnd Bergmann , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Cyprian Wronka , Suresh Punnoose , Rafal Ciepiela , Thomas Petazzoni , Nishanth Menon , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Vitor Soares , Geert Uytterhoeven , Linus Walleij , Xiang Lin , linux-gpio@vger.kernel.org, Sekhar Nori , Przemyslaw Gaj , Peter Rosin , Mike Shettel , Stephen Boyd Subject: Re: [PATCH v8 05/10] dt-bindings: i3c: Add macros to help fill I3C/I2C device's reg property Message-ID: <20181003210613.27d180c7@bbrezillon> In-Reply-To: <20181003205953.426021bb@bbrezillon> References: <20181003132212.12619-1-boris.brezillon@bootlin.com> <20181003132212.12619-6-boris.brezillon@bootlin.com> <20181003205953.426021bb@bbrezillon> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 3 Oct 2018 20:59:53 +0200 Boris Brezillon wrote: > On Wed, 03 Oct 2018 11:37:17 -0700 > Joe Perches wrote: > > > On Wed, 2018-10-03 at 15:22 +0200, Boris Brezillon wrote: > > > The reg property of devices connected to an I3C bus have 3 cells, and > > > filling them manually is not trivial. Provides macros to help doing > > > that. > > > > This patch logic seems excessively fragile. > > Keep in mind that this header is meant to be include by .dts(i) files, > not regular .c files. > > > > > > Signed-off-by: Boris Brezillon > > > Reviewed-by: Rob Herring > > > --- > > > Changes in v8: > > > - None > > > > > > Changes in v5: > > > - none > > > --- > > > include/dt-bindings/i3c/i3c.h | 28 ++++++++++++++++++++++++++++ > > > 1 file changed, 28 insertions(+) > > > create mode 100644 include/dt-bindings/i3c/i3c.h > > > > > > diff --git a/include/dt-bindings/i3c/i3c.h b/include/dt-bindings/i3c/i3c.h > > > new file mode 100644 > > > index 000000000000..97448c546649 > > > --- /dev/null > > > +++ b/include/dt-bindings/i3c/i3c.h > > > @@ -0,0 +1,28 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 */ > > > +/* > > > + * Copyright (C) 2017 Cadence Design Systems Inc. > > > + * > > > + * Author: Boris Brezillon > > > + */ > > > + > > > +#ifndef _DT_BINDINGS_I3C_I3C_H > > > +#define _DT_BINDINGS_I3C_I3C_H > > > + > > > +#define IS_I2C_DEV 0x80000000 > > > + > > > +#define I2C_DEV(addr, lvr) \ > > > + (addr) (IS_I2C_DEV | (lvr)) 0x0 > > > > This looks to be missing surrounding parentheses. > > Actually it's not. The macro is supposed to declare 3 u32 integers each > of them separated by a space: > > reg = ; > > is translated into > > reg = <0x34 0x80000001 0x0>; > > > > > > + > > > +#define I3C_PID(manufid, partid, instid, extrainfo) \ > > > + ((manufid) << 1) \ > > > + (((partid) << 16) | ((instid) << 12) | (extrainfo)) > > > > This macro doesn't make any sense. Missing a shift and an or? > > Same here, the PID is taking 2 32-bit entries. > > Now, I agree that this is far from obvious, and if Rob is okay, I'd > like to propose a different binding to avoid having to define these > macros: > > reg = ; > > If pid_msb and pid_lsb are 0, then the node is defining an I2C device Actually, I meant pid_msb == 0. This part of the PID is encoding the manufacturer, and I don't think 0 is a valid manufacturer (I hope it's not). So, we'd have something like: reg = ; > (AFAICT, 0 is not a valid PID), otherwise it's an I3C device. This way > we get rid of the IS_I2C_DEV flag, and we can get rid of those macros > without making I3C dev node definition too painful (the only part > developers will have to get right is the PID) > > > > > > + > > > +#define I3C_DEV_WITH_STATIC_ADDR(addr, manufid, partid, \ > > > + instid, extrainfo) \ > > > + (addr) I3C_PID(manufid, partid, instid, extrainfo) > > > + > > > +#define I3C_DEV(manufid, partid, instid, extrainfo) \ > > > + I3C_DEV_WITH_STATIC_ADDR(0x0, manufid, partid, \ > > > + instid, extrainfo) > > > + > > > +#endif > > >