Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp698795ybh; Wed, 18 Mar 2020 07:34:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt3AJJsKRm/PVx1g/qDeMoQX6NimPd6j/EMCCleCSYK5WKcUhjYhHE+wsy9G1XYO6MocuKL X-Received: by 2002:aca:57d6:: with SMTP id l205mr3262776oib.20.1584542066059; Wed, 18 Mar 2020 07:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584542066; cv=none; d=google.com; s=arc-20160816; b=oWbprbnkgEeXWtgYsCq4errwyaSeyXxuMKC+PqctaFGaJeERS00EVVrneK2cIWuMEd ZtzOzcdVjlH9Y+CzDFaT8pjbQvE60dGiFzpnSpnMJnIhUWp6rCaCkHlXOUxJzdSUO/uB Ictewe9AcqpC/Kf4xtsnDUGiEBNqsmYgy4ffcF0epF/ePOxY2PEhxtqcTyDBu9ViW+3K VD21D5CwVQXfcTclnPo4C5ufW0tUF62BNrbT1huZWfNxAxcYmQUiUbLwE12f5k2griwa QdFt/3gJaU3YP2VOzOzAsTJxQAlhwoqrx10yrr5UD9R4FYe0j+WChjhEH0wNlou7TB5R 8xkg== 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; bh=XEBHXTCfJ9EpAToH/gqywdAAs0pJvKKr5BO2C2YQuTw=; b=JRYKlL4DG4TFKwCuJ0Y0Ix5AGl3Q56ooZg7+hPQozDEoMdbWppbgUvtwK3qaa+RQnU q0KH6uB8i5X0ZBJIYLabLIgq38FIlugpu0DGofE5loQwybxHiACxw9onKQvJjC5DQFeK sDnt9H4YWW9pWTZA1Sm4F5XnNfwYtfx3KBfptuhicUR1OkW/oYGqyBQQk/dNvJTxzMqA B8jPMGH4Xx5nrCYzWxl07iyLZiMpAfCbVMH5L9RZNN0vmnuykFoeJqAUBY1d4V6UdOMO zE2UrjMwWJPiaIETfOG97b3lQ239zN/CW1KrGmXd8sVHzAZv5sWWvRvvWvX0sp8Z43ni LyXw== 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 u67si3324668oie.259.2020.03.18.07.34.13; Wed, 18 Mar 2020 07:34:26 -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 S1727194AbgCROd0 (ORCPT + 99 others); Wed, 18 Mar 2020 10:33:26 -0400 Received: from sauhun.de ([88.99.104.3]:48226 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgCROdY (ORCPT ); Wed, 18 Mar 2020 10:33:24 -0400 Received: from localhost (p54B333FA.dip0.t-ipconnect.de [84.179.51.250]) by pokefinder.org (Postfix) with ESMTPSA id 039522C097D; Wed, 18 Mar 2020 15:33:21 +0100 (CET) Date: Wed, 18 Mar 2020 15:33:21 +0100 From: Wolfram Sang To: Geert Uytterhoeven Cc: Wolfram Sang , Linux I2C , Linux-Renesas , linux-i3c@lists.infradead.org, Kieran Bingham , Niklas =?utf-8?Q?S=C3=B6derlund?= , Luca Ceresoli , Jacopo Mondi , Laurent Pinchart , Vladimir Zapolskiy , Linux Kernel Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" Subject: Re: [RFC PATCH 6/7] i2c: of: mark a whole array of regs as reserved Message-ID: <20200318143321.GB8300@ninjato> References: <20200220172403.26062-1-wsa+renesas@sang-engineering.com> <20200220172403.26062-7-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="aVD9QWMuhilNxW9f" Content-Disposition: inline In-Reply-To: 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 --aVD9QWMuhilNxW9f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > +int of_i2c_get_board_info(struct device_node *node, struct i2c_board_i= nfo *info) > > +{ > > + u32 addr; > > + int ret; > > + > > + ret =3D of_property_read_u32(node, "reg", &addr); >=20 > Perhaps the time is ripe to start considering #address-cells, instead > of assuming 1, here ... I think here it is okay because we really want the first entry of the first tuple. > > + of_property_for_each_u32(node, "reg", prop, cur, reg) { >=20 > ... and especially here, if this code can ever be reused for i3c, which u= ses 3. But here I agree. I reimplemented the code to handle it, and it worked with '#address-cells =3D <2>;' as expected. Here is the diff to this patch: @@ -16,6 +16,7 @@ #include #include #include +#include #include #include =20 @@ -75,13 +76,14 @@ static struct i2c_client *of_i2c_register_device(struct= i2c_adapter *adap, struct i2c_client *client, *first_client =3D ERR_PTR(-ENOENT); struct i2c_board_info info; bool first_reg =3D true; - struct property *prop; - const __be32 *cur; - u32 reg; + unsigned int i =3D 0; + const __be32 *prop; + u16 reg; =20 pr_debug("register %pOF\n", node); =20 - of_property_for_each_u32(node, "reg", prop, cur, reg) { + while ((prop =3D of_get_address(node, i++, NULL, NULL))) { + reg =3D of_read_number(prop, 1); of_i2c_decode_board_info(node, reg, first_reg, &info); =20 client =3D i2c_new_client_device(adap, &info); Thanks, Geert! I will send out the new version in a few minutes. --aVD9QWMuhilNxW9f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAl5yMS0ACgkQFA3kzBSg KbYtfRAAil0f+6TG3T06kRnSNoNLPpEoqabj0ip7Vz7+gSloBvl8lszjT7CP//7R 9gnjhLFvr6hPVbC64dzimreCL1JGYUtFOhKDl/pPSA+TrEFEARbOCxIbdhgieFC0 DrSN2Ed+jK7ZRTPdTuT2y6DNf6bbDHo3ihnzd57I2wy6cEsTMdyIJSAnsxfn5QVf 6EKTCLAeBI9hPd3jDB38ICvQ0Vf9/F9lHRZNOQo1hQwSkUbnyyqf26k8kt/VAnm9 Ipcvlz8krmqY2FWnC/FlzhKV5lSc9i7VSZJTQOjtO39RHxRAsOytbzc6erlTp9Pz V1+Uw8HGIVMbQe1+kpaaJvomxTApQ2HqjTOPTQc/2h9qXUdCdeWFi56oaJzCl7hp WHCgqmUCfs4a1V75vuHk2Fj3mPMQsvmjiWrvW5Sz5nvto2GTjKsg2m/v6bdabTxk iMFjwBfQVun1ziMQOad0zycEFF+sBtQafAg4zmS/FAyrhGAVI9YQ57Z93dlk7D1L YLFvxifo+L5a6/ny1uEL0xrjMoYfiUCTXlySSuywl5dD5jsqBoUWduFXeHo0DezA Pe/Vht7ChN7WlI3kDt3X+zCVGmf5WnObEJPrzm39gUNjod7UpW39zgoKQWuF4Rpp JCKxZe174onb36K3lz83DRTkg5v5NU1AdVgwqrKM6RjakOs1aXM= =Ku4u -----END PGP SIGNATURE----- --aVD9QWMuhilNxW9f--