Received: by 10.192.165.148 with SMTP id m20csp210006imm; Thu, 26 Apr 2018 19:40:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZply/ADZIOEozXbFito8D6YafMYA27WG8ZU5ShLOt89tFUuMnp/LHct/ee4ZvxqPeIoxFQR X-Received: by 10.98.8.133 with SMTP id 5mr534575pfi.154.1524796844954; Thu, 26 Apr 2018 19:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524796844; cv=none; d=google.com; s=arc-20160816; b=RI1lDI5+mds0tQTJM21IRiJ5L5mY85ONPpOQOX2n2VWUM2VLUhsPQE+rL8FyqedEqj rQXPb7bZyO0BglvXBgBHEiRgfB9w9GMZ8e6iiROI7R6ajYZRTlo51WU2zmR1gtpf4OjS ZvRReflP1dCDOMLF6fQEV/5wHXZQ/nuyfp5FkP8c65En3B39TmmJ4jdHk36bUtM5h2ur 5HbjLtvq/g1QQoSP+ct16gFcygigdem7GFP575L3oKwip795vy1ZHQkQTCTn9Lx2pR8Z 92P58elLWFaoKjY3oK3DfhfMUjh+oboR6q5mmleUYsvh5EvZJcRC0JqLRxRP9cMDViCJ E30g== 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=1vuSCfo/TX8CUFgxWuul7BlTOUN8pQ3uRzYB6EJUzB8=; b=uSSWwSvFCOd68eScx62VaTKwNtCS5ZsgX3CXZBt66omE28xiCXRWWPqgp29WzbUemx h4TyuHAFZnv8laefs4vvd5l5lGf8U4rNxJPtUjTwU2McSTolMHIAHRYN5CzJlaUJQz4G E+dh5w9wLMnh6rI0jqjoSGuv3WiVXIb7xjCMXarkni715HPCvvoBbVg+qAyjMGm7IQ6x 69NBShlsgkgylo7PF38r75r5uIHJ0LDUwkWri/ypiAIy7a8QiV8wsS3FoxKue0Aj2fzK bwXvwOwVbRow6ix4jVs67VMMlPEQ+kqatIT7z6XIcaJj0DOf8UbV6jFg303cRmM1cC+T 0v4g== 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 w13-v6si286291pgq.385.2018.04.26.19.40.30; Thu, 26 Apr 2018 19:40:44 -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 S1757291AbeD0CjY (ORCPT + 99 others); Thu, 26 Apr 2018 22:39:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757029AbeD0CjW (ORCPT ); Thu, 26 Apr 2018 22:39:22 -0400 Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) (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 C87122184F; Fri, 27 Apr 2018 02:39:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C87122184F 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-f181.google.com with SMTP id s70so299650qks.13; Thu, 26 Apr 2018 19:39:21 -0700 (PDT) X-Gm-Message-State: ALQs6tBqD+Ur0sCboJpbu7IO90eCsN9a4u+OKQfV/H7HuFxM62/CVC8/ K+RMU080y2fG2W71YCvlyT9//DHGzYuASRg0lg== X-Received: by 10.55.31.132 with SMTP id n4mr388552qkh.375.1524796760885; Thu, 26 Apr 2018 19:39:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.163.228 with HTTP; Thu, 26 Apr 2018 19:39:00 -0700 (PDT) In-Reply-To: <6045807691c310ccdd57ab16524b7525f26a1dc1.1524751696.git.michal.simek@xilinx.com> References: <6045807691c310ccdd57ab16524b7525f26a1dc1.1524751696.git.michal.simek@xilinx.com> From: Rob Herring Date: Thu, 26 Apr 2018 21:39:00 -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 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? Rob