From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AE02C1B0F1 for ; Tue, 19 Jun 2018 21:28:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E487D208A5 for ; Tue, 19 Jun 2018 21:28:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E487D208A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zonque.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757475AbeFSV2n (ORCPT ); Tue, 19 Jun 2018 17:28:43 -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