Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp72745imm; Tue, 19 Jun 2018 14:31:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJQJn/p3O1tpDbjxRfDmignuunvRKlk9mapIb1QD9o7UXUsesrOjGTEsGLv+K9Azgs+Sv7O X-Received: by 2002:a63:583:: with SMTP id 125-v6mr16053439pgf.385.1529443912401; Tue, 19 Jun 2018 14:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529443912; cv=none; d=google.com; s=arc-20160816; b=BjwCbBaqFz7TqM5N7H87A4VfvDQGZkbeTiZ7SIRcXw5ZtqyGQOQCsRIyXSnGtl2XOO B0L7O/R0zYPeQGqScuJG4XV42L09U4yRya3MxcZbBGcSAXRdhHuaxX0fL43WGzhuYx7k XicraFMGDNFGbflpLxC75fQO3pQRuMrpVB2KI8mFyi0wcEqsCgTp5QgjJBqFBJhsB7Ct FvsNep8EqB0B/pfrFiF/IO7wAAnxzbv9+PXDB1NTNXeqgO6pI6u35o6rzffYNZ6kdPZj bGMXLsTcG7EEHmIv/jKk3nX5bGrQw4QkVFdHsaBVcOdL1LPKoaNeilAVCHgIolyyoPoZ qqcg== 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:arc-authentication-results; bh=E+JYTukyx7PVJ/Jd+YbnD7kBqZGhe/KH0MTK+eWdeIE=; b=gZF3TpbYc0pN62yx9ZkSgrThC0GkN6iN9i0F5E8DWC7GwD7IuN8/DKPXjqc4oq8Ni/ XhNZMcqE4MnHHQTPLidwVR/VLH9HOAYYs2d6OvA4ScBzjdkbvVjuji0JdfLUCh+PhOvA lVbBpmCa4DzRzptIO/zhmc03YkBfGY9fjt3KFyxmnzDkTYMS/MWwlGbwICCvmvFhHE6v yLQv9Wr+AX/EhG4fcKwHl7FrHnD1gepq+uA/vqyrzS8e7uNauwm8CLvjBJaMJwpBFT2G 0n8vZwJBje+JIwwxX2R+VbBTh1v+x45RKNdcDCzrlS1eVXiHVTFhayJgj2Stvq3kYZ0q QLBA== 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 t1-v6si531794pge.439.2018.06.19.14.31.25; Tue, 19 Jun 2018 14:31:52 -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 S1757471AbeFSV2m (ORCPT + 99 others); Tue, 19 Jun 2018 17:28:42 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50648 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757353AbeFSV1z (ORCPT ); Tue, 19 Jun 2018 17:27:55 -0400 Received: from localhost.localdomain (pD95EF733.dip0.t-ipconnect.de [217.94.247.51]) by mail.bugwerft.de (Postfix) with ESMTPSA id 4B67028A28F; Tue, 19 Jun 2018 21:24:48 +0000 (UTC) From: Daniel Mack To: zbr@ioremap.net, robh+dt@kernel.org, mark.rutland@arm.com, szabolcs.gyurko@tlt.hu Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Mack Subject: [PATCH RFC 2/4] w1: core: match sub-nodes of bus masters in devicetree Date: Tue, 19 Jun 2018 23:27:42 +0200 Message-Id: <20180619212744.794-3-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619212744.794-1-daniel@zonque.org> References: <20180619212744.794-1-daniel@zonque.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Once a new slave device is detected, match it against all sub-nodes of the master bus controller. If a match is found, set the slave device's of_node pointer. This alone can already be used by slave device implementations to obtain more properties from devicetree. Another use-case is introduced in the next patch. Signed-off-by: Daniel Mack --- drivers/w1/w1.c | 3 +++ include/linux/w1.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 80a778b02f28..dc73d8c08438 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -686,6 +687,8 @@ static int __w1_attach_slave_device(struct w1_slave *sl) sl->dev.bus = &w1_bus_type; sl->dev.release = &w1_slave_release; sl->dev.groups = w1_slave_groups; + sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node, + sl->family->of_match_table); dev_set_name(&sl->dev, "%02x-%012llx", (unsigned int) sl->reg_num.family, diff --git a/include/linux/w1.h b/include/linux/w1.h index 694101f744c7..3111585c371f 100644 --- a/include/linux/w1.h +++ b/include/linux/w1.h @@ -274,6 +274,8 @@ struct w1_family { struct w1_family_ops *fops; + const struct of_device_id *of_match_table; + atomic_t refcnt; }; -- 2.17.1