Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2546147imm; Fri, 24 Aug 2018 00:49:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbVrohAYH3gtUdAI9uvnpdInXIIDxRCGLDbXhLYm+kzM+U0nR9RwZAGuUbPjHO0lwbRurAQ X-Received: by 2002:a62:9101:: with SMTP id l1-v6mr681848pfe.226.1535096951932; Fri, 24 Aug 2018 00:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535096951; cv=none; d=google.com; s=arc-20160816; b=J7GBowJ28Zw3CaNKXjRb8c54Vnwjn/YpPiQKXIt/ScI63iTnBHbigXKrCvg8h8ohpy Bp6cRhNnRYyvTFMJo00KuFwXkqfrUChELUYT+wm0M2uJjizcTwEG7AQkmO9BmOOtjb0j 7OrDm8joQdZfz1V0Z8q8kJ47IIKEC5RDUayWxjf9CyTjy0A69IQ6HP3a96Lyv2GobRVo /XKhYfUVlbystTwoz/6288v+7TQKUByc/B9w84+16dsNjM7cIDftNWObf0Yfx4UV28vR d71XnkAyUzERM40rU7rp8niSfhG+2zsCWNV+/FOpRTFLZIg2t9MXIxct6UHhnTWZwk0d dGcQ== 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 :arc-authentication-results; bh=9fhjxl94yYWwZZGaPcDA9+KLlxtBRjd7R07oyL9k2RU=; b=sCTgjrJrvE0Ll0B/7IJGBLYpdvYNsrwjq22dPahml1BwCbgDkB7suBm/ptEnci/elQ FWACuIBhbZZEdLlsplaeCx0EmUTv5d2RFT3tgmOkYmCcMFRR5Ge95bzQ/wQI1x3PGMKn dnkVMSfOZoRMf1SJIP7TqVt/Cm+Mf/aJKsxYPFL8lsT+RkThdPqNnB0jSakIOZx0AYzw 7AikmLmNoULsjDzkfnDuEpGytRiUA7fB/DIas7WjbmB+9UCMXhgLV5dQMpeikgsp1O86 hySQDjJuTqJgfSzqSoFSJQClBkooCifSf557mSYz9TSCdbTDrwUyKuYlfCTQBNqU//J3 hNAQ== 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 b7-v6si5514065pgq.334.2018.08.24.00.48.56; Fri, 24 Aug 2018 00:49:11 -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 S1727720AbeHXLUj (ORCPT + 99 others); Fri, 24 Aug 2018 07:20:39 -0400 Received: from mail.bootlin.com ([62.4.15.54]:42877 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbeHXLUj (ORCPT ); Fri, 24 Aug 2018 07:20:39 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id D9FFC20732; Fri, 24 Aug 2018 09:47:12 +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 shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-53-19.w90-88.abo.wanadoo.fr [90.88.170.19]) by mail.bootlin.com (Postfix) with ESMTPSA id 714BA206DE; Fri, 24 Aug 2018 09:47:02 +0200 (CEST) Date: Fri, 24 Aug 2018 09:47:01 +0200 From: Boris Brezillon To: Peter Rosin Cc: Rob Herring , Mark Rutland , devicetree@vger.kernel.org, jmondi , Alexandre Belloni , Andrzej Hajda , David Airlie , "linux-kernel@vger.kernel.org" , dri-devel , Sakari Ailus , Jacopo Mondi , Jyri Sarha , Daniel Vetter , Russell King , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Subject: Re: [PATCH v8 3/4] drm/atmel-hlcdc: iterate over all output endpoints Message-ID: <20180824094701.1f17393f@bbrezillon> In-Reply-To: <56016787-0487-1571-7c28-2767033cda23@axentia.se> References: <20180810130359.9882-1-peda@axentia.se> <20180810130359.9882-4-peda@axentia.se> <20180813135949.32vrlrevtazr5x7d@apu3b.nibble.pw> <0baac94e-f3d2-53fd-4af9-854bb4498345@axentia.se> <5c9853fc-e2ea-6983-ac88-b52b6e9e6ecd@axentia.se> <56016787-0487-1571-7c28-2767033cda23@axentia.se> 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 Tue, 14 Aug 2018 17:05:29 +0200 Peter Rosin wrote: > >>>>>> @@ -77,13 +79,29 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint) > >>>>>> > >>>>>> int atmel_hlcdc_create_outputs(struct drm_device *dev) > >>>>>> { > >>>>>> - int endpoint, ret = 0; > >>>>>> - > >>>>>> - for (endpoint = 0; !ret; endpoint++) > >>>>>> - ret = atmel_hlcdc_attach_endpoint(dev, endpoint); > >>>>>> + struct of_endpoint endpoint; > >>>>>> + struct device_node *node = NULL; > >>>>>> + int count = 0; > >>>>>> + int ret = 0; > >>>>>> + > >>>>>> + for_each_endpoint_of_node(dev->dev->of_node, node) { > >>>>>> + of_graph_parse_endpoint(node, &endpoint); > >>> > >>> I'd really like to kill off of_graph_parse_endpoint, not add more > >>> users (check the git history on this code). You should know what are > >>> possible port and endpoint numbers, so iterate over those. > >> > >> So, add a comment to that effect in the docs of the of_graph_parse_endpoint > >> function. > >> > >> How can the hlcdc driver know the actual number of endpoints? It's a > >> one-way signal path out from that port, and it can easily be routed to > >> 1, 2, 3 or even more places. As shown above, forcing the endpoint id > >> to start at zero is a nuisance, and I don't see the point of it. > >> > >> But I welcome suggestions on how to arrange the above dtsi/dts fragments > >> in a world where the endpoint id absolutely has to start at zero. > > > > Your dts file arrangement seems fine. Can't you just not exit the loop > > on -ENODEV? IOW, just iterate til you find an enabled endpoint. > > That would regress cases where two (or more) endpoints are enabled > (which is currently supported). As I see it, the driver will have a > very hard time knowing when to stop iterating with any solution not > involving the equivalent of the functions for_each_endpoint_of_node > and of_graph_parse_endpoint. Open-coding of_graph_parse_endpoint just > to avoid it is a bit more than silly IMHO... I agree, and actually, I think this is Rob who suggested to do what we do here :-) (iterate from 0 to X, and stop as soon as -ENODEV is returned).