Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5973596ybi; Tue, 4 Jun 2019 16:01:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6296LxX0lzE7CPBad0ItEJafBQEegNtmxPIiFW13pX0ja2mnvhtTI/nlOdbh6TeWHazIC X-Received: by 2002:a62:3145:: with SMTP id x66mr42245428pfx.223.1559689315305; Tue, 04 Jun 2019 16:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559689315; cv=none; d=google.com; s=arc-20160816; b=KZuaPztBV7hVU/+gbxBW23Evhi2m9xwEAhoXXva/7vtdz1+wzIKnZOpmJeVOVQEyH3 Oa6Swg+tFroTDTx562V9uPpnjKitjZrV1fL0KTiR93MpMJlYTLhy2VdnEz7C5yNFbvUr zu6gfWQBQGaprh1Im65oXjXBip1Kv4mYFHVsAN+i0R2d6+HpFrfrWUeGYlQJWMdfdL5f V2plJM7EUW3oiMDZpKC89oENu3F/PXJo6Ma/sAybX6jiHJNQ0aiENICYQf545twssDg7 xemQO7uliwK9a24Z6m+eh6026P5+85D/6g6bCkKEPPNJn4EZjAqCoDsnG4Nys64YIDbb J/fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=BYxNT7Sm/H/88U5pT9PKubUTYc9p2VmhZQMeOwENRKI=; b=eY6DLi/6nfk4LFXUFQU2VqDmIsPQRrgCIAtWRR3oHFIKjAGHycvtPPbJfoDwgUBVTn vHITv+er1LBZSQkSJgVayV9lctBGKOc5xQNphtBFd3dDaFRLi0b3touhG02xIq7celOv XUkEwHbEV/4eP3gOjg1yaxrP6hRWQqY0+4yqUCCQYY0lUlxyEUWYVxU0CY0KBZ097df5 vGWmAVzup4Qc5iv4iTbQepqt8fS0q4XfjtKUs3IDj2krGT7caXMn+5Q5VeFB97Ijlkvg 5L3aOT+B5emm7i4xSSB16jQYHeu4tDtOgaq31gmHF2nutvihBOi8l1e3RjqxmdDI9Ug5 8N4g== 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 a9si22779056pgw.14.2019.06.04.16.01.36; Tue, 04 Jun 2019 16:01:55 -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 S1726605AbfFDXA0 (ORCPT + 99 others); Tue, 4 Jun 2019 19:00:26 -0400 Received: from sed198n136.SEDSystems.ca ([198.169.180.136]:29140 "EHLO sed198n136.sedsystems.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbfFDXAW (ORCPT ); Tue, 4 Jun 2019 19:00:22 -0400 X-Greylist: delayed 1464 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Jun 2019 19:00:21 EDT Received: from barney.sedsystems.ca (barney [198.169.180.121]) by sed198n136.sedsystems.ca with ESMTP id x54MZv1K029406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 4 Jun 2019 16:35:58 -0600 (CST) Received: from SED.RFC1918.192.168.sedsystems.ca (eng1n65.eng.sedsystems.ca [172.21.1.65]) by barney.sedsystems.ca (8.14.7/8.14.4) with ESMTP id x54MZtKp036309 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 4 Jun 2019 16:35:57 -0600 From: Robert Hancock To: linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, Robert Hancock Subject: [PATCH 1/2] mfd: core: Support multiple OF child devices of the same type Date: Tue, 4 Jun 2019 16:35:42 -0600 Message-Id: <1559687743-31879-2-git-send-email-hancock@sedsystems.ca> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1559687743-31879-1-git-send-email-hancock@sedsystems.ca> References: <1559687743-31879-1-git-send-email-hancock@sedsystems.ca> X-Scanned-By: MIMEDefang 2.64 on 198.169.180.136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously the MFD core supported assigning OF nodes to created MFD devices, but relied solely on matching the of_compatible string. This would result in devices being potentially assigned the wrong node if there are multiple devices with the same compatible string within a multifunction device. Add support for matching the full name of the node in the MFD cell definition, so that we can match against a specific instance of a device. If this is not specified, we match just based on the compatible string, as before. Signed-off-by: Robert Hancock --- drivers/mfd/mfd-core.c | 5 ++++- include/linux/mfd/core.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 1ade4c8..74bc895 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -177,7 +177,10 @@ static int mfd_add_device(struct device *parent, int id, if (parent->of_node && cell->of_compatible) { for_each_child_of_node(parent->of_node, np) { - if (of_device_is_compatible(np, cell->of_compatible)) { + if (of_device_is_compatible(np, cell->of_compatible) && + (!cell->of_full_name || + !strcmp(cell->of_full_name, + of_node_full_name(np)))) { pdev->dev.of_node = np; break; } diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index 99c0395..470f6cb 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -55,6 +55,9 @@ struct mfd_cell { */ const char *of_compatible; + /* Optionally match against a specific device of a given type */ + const char *of_full_name; + /* Matches ACPI */ const struct mfd_cell_acpi_match *acpi_match; -- 1.8.3.1