Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760589AbbKTXOc (ORCPT ); Fri, 20 Nov 2015 18:14:32 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:58767 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474AbbKTXOb (ORCPT ); Fri, 20 Nov 2015 18:14:31 -0500 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Guenter Roeck , Lee Jones , dinh.linux@gmail.com, linux-watchdog@vger.kernel.org, Damien Riegel , linux-kernel@vger.kernel.org, wim@iguana.be, robh+dt@kernel.org, kernel@savoirfairelinux.com, kernel@pengutronix.de, shawnguo@kernel.org, sameo@linux.intel.com Subject: Re: [PATCH v3 2/5] mfd: syscon: add a DT property to set value width Date: Sat, 21 Nov 2015 00:13:27 +0100 Message-ID: <4478024.TgK5OkRQEy@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20151117172649.GA11035@roeck-us.net> References: <1447700814-5391-1-git-send-email-damien.riegel@savoirfairelinux.com> <20151117091946.GG17829@x1> <20151117172649.GA11035@roeck-us.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:36jDlxojso2SGnnhiTAyWxCt8vZzLgL6wH31g+pD84AFoDA5e2f k4gTbHaf+hb7Twl28USZIdsyglrIjl0hL0oEeLTZGxP9DAf9/hKn5AW8iEOEWcLY1dMHMKF uK2Dk0Zy8/fiTAxGUCeZh0kQvUyhJqrAUb8L+Ai4czbZSPymlip+wkgEBGnYVoBdvisAOv+ LzlwoiCE0k/CIeSmukAuQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:0Cmtfj9TbGg=:2ZzZkl4uM24417te/kkeXY wPJbNUJ9FZKhBUOamdkPuUI3DFk1t4sS94veFNV1O3OYlFfhGQBKBuPbTlFz73Z2aqyC5zgJb ek4uv8Vm2r5iKVx2Hq61yPpI2Q/G/F25wTdaM11OOoPisKX01ZX6bAs2EDADkFMMs4uajq6uC vbWt9FVNk5aaJVunjuBOd9xKd60P88AUipvZgvm4NLKbysXNrNfGlYJah7eGvYM7ZNFGm16Vu yQ0FZARd0aLMNw/SDSo1sDTC+4Eu23N/GJvs1//XDWN8st3UD6ZmjXOZ4XikTZB7Pvn/DJLe1 EloQZNugskBw+nmWY2ata1pSfZJgtGeNd178gws1LhjWgOXMG7OW2QAI8JJ4D2y8LcpydPVS+ CzQEXwsQqkMaXJp3muHiW39hnRv0DiAb4NGUvvHjA6H+7PCqe+nZ5hjvivLHmVom6/GUYE6Hl AUKHcIFPVMkrGqmh2Ym5DnqwExhjjhjDRxErmX7EuHMYYvqnQaTOHt77JxuGG9ysugtvqxTYR xXFqw9FZObJyDmqqwPkJ/ThV/Aq1Qwh5DNveqUs3I6XSSKi3zmBG+BOUGjgSk/vzccN3zZxst Q3Jhxq7LXUTHZbkjqiC7yjECOCWJhP7Lu+A0AeazQ7wrN2o5cfIU4bwHRGENeUiRMYPxhr9JU lwECVgZ/Tlc1x4F7dyx38V76GSdxZrbxKCEyT5lQ5gRwvNSV+EdPN55OntRqWQUNmFMWLX67C 3kuWopj+4eTI9mjS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1458 Lines: 46 On Tuesday 17 November 2015 09:26:49 Guenter Roeck wrote: > > > > This syntax is confusing, as we normally associate it with an error > > condition. Instead, I'd use: > > > > if (of_property_read_u32(np, "bus-width", &bus_width) == 0) > > Or maybe better > > if (!of_property_read_u32(np, "bus-width", &bus_width)) I would also prefer the latter, but it doesn't matter much either way. > > > > Or, for more clarity: > > > > of_property_read_u32(np, "bus-width", &bus_width); > > if (bus_width) > > > > If you choose this version (which I think is my preferred method, don't > > forget to initialise 'bus_width' to zero. > > > Ignoring an error and depending on bus_width==0 to determine if the property > was provided seems odd, especially since it would "hide" if the bus-width > property is set to 0. In the original code, this would be detected as error. Right. Another option would be ret = of_property_read_u32(np, "bus-width", &bus_width); /* no bus width provided, default to 32-bit */ if (ret) bus_width = 32; syscon_config.val_bits = bus_width; syscon_config.reg_stride = syscon_config.val_bits / 8; which has the same effect but seems a little clearer to me. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/