Received: by 10.192.165.148 with SMTP id m20csp692832imm; Fri, 27 Apr 2018 06:04:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZprEP7wu2LSf+eaMmIZRpNYmfWDfOuyxRfSxIACRJmXtaPuqM4/vMPzXNzpgSVMLGFBaG1o X-Received: by 2002:a65:4003:: with SMTP id f3-v6mr2077177pgp.359.1524834293508; Fri, 27 Apr 2018 06:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524834293; cv=none; d=google.com; s=arc-20160816; b=cLV7KGe8Fh10u+3PpWD3Si2GJK7nirajWd7a0drUVFciBpPcsbODF3SKkjuEHJE210 TdTq4c9vpKHbrxOzmRgSUVzcb09JzcrXv21/ZDUXIOyMSmy/KWChN1dKhSlGnxdOeeSS 8KHbBavFPwOaDZAMBw19ik61VaRoNzjaq/ekO26QUUv2tNxo62Ih7Mo5d0b2p48VyTDg ANsQc+Ia7fQ4ViW3w+CJb6yYrKDuXC8YPWqi/P1X+V/CLMcZFlY7Ht4ALzzIk6Ft3U54 YX4KFgk6AlgpuTCzzIyXmel+tlvTfMwaKChynIRAvhCMZPp/57lm0KDg5Siv/Ly6BoSp d2RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=CQWqXjvdnsJojxTETzDs5wmheLQ1D79/whI8Q4Jgphk=; b=EiosNdnOr9W3c3cxMdnFcE5aiOPU8UF7wiVlqWNlvMCrQyfnC/gbwjv1MmH/7xcMWH VufpQlfIFloVprJgD78lDqV44HQ4+/duzN3wSJilc7ututCqb6YyjMyjTF/9lhtXnnnd 0alFcpUj7O+pg9BHXtqWpCMPfcuI9cvC57uT+4faSdxjXFB3nQV0w2yAcBEmRyLx6Bxg PDC0OEAF9j5371U4NSJvWMpDBnhlJSdr6RJLpFgoIGhEzSCdgtuHo9KOwLdRI4/nsPZO wfY9p7Omw6wmiazBuCPDOtZIDtN85J2xVjBRtBVv2oEordzg46mxqsy0BwBzm+lIXeO/ LBYA== 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 l27-v6si1233324pgu.353.2018.04.27.06.04.39; Fri, 27 Apr 2018 06:04:53 -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 S932435AbeD0NDT (ORCPT + 99 others); Fri, 27 Apr 2018 09:03:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:34256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932322AbeD0NDR (ORCPT ); Fri, 27 Apr 2018 09:03:17 -0400 Received: from mail-qk0-f172.google.com (mail-qk0-f172.google.com [209.85.220.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B34292184D; Fri, 27 Apr 2018 13:03:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B34292184D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=robh+dt@kernel.org Received: by mail-qk0-f172.google.com with SMTP id h19so1270967qkj.10; Fri, 27 Apr 2018 06:03:16 -0700 (PDT) X-Gm-Message-State: ALQs6tBE6RErJmHHR5xVYZNsqDgL/TXt1zK52oNVfV3kwA7i043C2ilY 9dz8lE7Z+vuyPqlbEZ+IVyHohRIhsmOoDcGFRQ== X-Received: by 10.55.153.133 with SMTP id b127mr1791972qke.43.1524834195860; Fri, 27 Apr 2018 06:03:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.155.2 with HTTP; Fri, 27 Apr 2018 06:02:55 -0700 (PDT) In-Reply-To: References: <6045807691c310ccdd57ab16524b7525f26a1dc1.1524751696.git.michal.simek@xilinx.com> From: Rob Herring Date: Fri, 27 Apr 2018 08:02:55 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/3] of: base: Introduce of_alias_check_id() to check alias IDs To: Michal Simek Cc: "linux-kernel@vger.kernel.org" , Michal Simek , One Thousand Gnomes , Alexander Graf , devicetree@vger.kernel.org, Frank Rowand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 27, 2018 at 1:10 AM, Michal Simek wrote: > On 27.4.2018 04:39, Rob Herring wrote: >> On Thu, Apr 26, 2018 at 9:08 AM, Michal Simek wrote: >>> The function travers the lookup table to check if the request alias >>> id is compatible with the device driver match structure. >>> This function will be used by serial drivers to check if requested alias >>> is allocated or free to use. >>> >>> Signed-off-by: Michal Simek >>> --- >>> >>> drivers/of/base.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ >>> include/linux/of.h | 2 ++ >>> 2 files changed, 51 insertions(+) >>> >>> diff --git a/drivers/of/base.c b/drivers/of/base.c >>> index 848f549164cd..382de01acc72 100644 >>> --- a/drivers/of/base.c >>> +++ b/drivers/of/base.c >>> @@ -1892,6 +1892,55 @@ int of_alias_get_id(struct device_node *np, const char *stem) >>> } >>> EXPORT_SYMBOL_GPL(of_alias_get_id); >>> >>> +/** >>> + * of_alias_check_id - Check alias id for the give compatibility >>> + * @matches: Array of of device match structures to search in >>> + * @stem: Alias stem of the given device_node >>> + * @id: Alias ID for checking >>> + * >>> + * The function travers the lookup table to check if the request alias id >>> + * is compatible with the device driver match structure >>> + * >>> + * Return true if ID is allocated, return false if not >>> + */ >>> +bool of_alias_check_id(const struct of_device_id *matches, const char *stem, >>> + int id) >> >> Wouldn't it be simpler to just return a bitmap of all allocated ids >> that match rather than trying to build that up 1 bit at a time? > > Is alias list stable or can dt overlay change it? Stable. If you use an id and then an overlay adds that id as an alias, what should the kernel do? The only choice is ignore the suggestion. > What should be the expected flow? Find out maximum number of aliases of > the same kind and allocate bitmap and return it with length. I think we can assume <32 so just return a bitmap in a unsigned long or u32. Use that to initialize a bitmap in the driver. For un-aliased devices, find the first unset bit, use that id and set the bit. > Anyway if you look at that patches I sent then I call in the driver > of_alias_get_highest_id("serial") which doesn't take care if alias match > with actual driver. It means having information about max alias ID which > match actual driver that would be helpful but I am not quite sure what > should be the flow. I'm a bit confused as to why you use of_alias_get_highest_id and of_alias_check_id. of_alias_get_highest_id is really intended if you want to start dynamic allocations above all the alias ids. I guess the need to match devices is based on each serial driver having it's own major and /dev name. IMO, we should get rid of those and every serial driver use ttySn (with the exception of things like USB serial). Then you'd just need to find all serial aliases. But you can support both with this function. Just return a bitmap of all aliases if match is NULL. > Any link to similar function would be good to understand how the flow is > supposed to work. I don't think there's a good model. The pl011 code looks broken to me. The warning about devices with and without aliases should be fixed. That is perfectly valid and should be supported. You should really only need an alias for your console. Rob