From patchwork Thu Oct 5 19:44:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114987 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp958032qgn; Thu, 5 Oct 2017 12:44:35 -0700 (PDT) X-Received: by 10.98.245.74 with SMTP id n71mr24753457pfh.102.1507232674940; Thu, 05 Oct 2017 12:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507232674; cv=none; d=google.com; s=arc-20160816; b=zJVeAoQUOEsjdA7p5WTKUrT7unXXoWP6aOfKgCHuO6ivt0hPIpnEse36YKmKhoXEKo bacqu4iV1kbTWK/LNgWtRckbsmim6tAd/dQqGlb0X/tbPOEGXJ1El07jsp5ZYFAtV1mi BdibkZ2BW7J2Ps70EeEUGiBXDw4HUzJZ2/x8viuwUnRU8B1IQVd2+VtNxJLMKRjA5Upz rwNvcAFINzCfqpjUE4PAUGVIrXQ/7m/9xH1azAasYshSYnfOZRlrMKKv518w6yfZRY85 mJ7QDFWbMySQ6XGyXNgvgqiPscWVGmmsEe/bxynJV2QRbvXbf1qQnKe62YckLHTGiRcD mbVA== 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=h/KYuSxJwmfJCiJs0+VRzZFBXjM5dyJpE1bvZ6WNx0Y=; b=VVu0ggo/uZm2gqX9EmeKD1jtusgUEwHMxeXgCNcymtnwdCs0qcV+3jWmEAP2yp/YCq 5yVYOyt/oagP5+3aCL0h6c00+MNDi36TH+sS1UGUBril76k5xAtgoEFgUKvXIhqWpwiR lqXwJxi8AZ0ZoMeMVlCfZE2LVj9QYrulDRwk4Ruc9K9MYFBUGQo42kDVuqk2tvK2ZeCk 4NL56Sq3agm7xBlGbD36gEPvNTv0D0inxa/2t+H3EgF54Dr49fHr2ByTC80z5cXtQUf8 9CGRmyWE+MPufQMrZjHHwcan8Caj1CvZ9KeGZgyZzG4ceUruOTg+KVesuOBboz+RQnkO QMrQ== 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 s2si13652021pfi.348.2017.10.05.12.44.34; Thu, 05 Oct 2017 12:44:34 -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 S1752132AbdJEToc (ORCPT + 26 others); Thu, 5 Oct 2017 15:44:32 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:37433 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbdJETo3 (ORCPT ); Thu, 5 Oct 2017 15:44:29 -0400 Received: by mail-oi0-f66.google.com with SMTP id h9so9087066oia.4; Thu, 05 Oct 2017 12:44:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h/KYuSxJwmfJCiJs0+VRzZFBXjM5dyJpE1bvZ6WNx0Y=; b=Tivsx2UtRko7Lp6nPEcHMPbpr3Dw9XgjDOVNL+3YJDDJYPc/AZSetyRt/bL/renIce LTDbHkA487xIR397fQxelEvV8AMKy2rsXjUu+XDxM62hPBG1TWIcVqoiX+vjsdKOFGcq Hn/8M9JXkS1i8t/SDmenJCtyTVvoiMn5nwnx+K1daSCpW1fEiv3RekDe9fxT3/wxgoHQ G82Fs3qTqXapSgAkDp+/wvSM8xbDygnn/Wsh/CSdpRvm7WBV3A/40SBgKWa4NRU/lYMI W+9Y9/I1X8RvcU07YVIGRB0q9QYoa/zok7VSb3c4hVnIg5U8mUkQ4NAfbD/HUuPb1OgU pqBg== X-Gm-Message-State: AMCzsaUVzWBq6pH7eGiasWTgNvfRqmpaxtyP0IOq5Rs3mJZHbvMtgTe/ lz8bciAO2kMlAyy0oqBWfbJKaWI= X-Google-Smtp-Source: AOwi7QDwHTwb0s8FnwGUnkCej5CX6/oWpd5DJHbFFtziy6Mcer2nesoFC23YOHo1WlyZMIi3resmgg== X-Received: by 10.157.65.207 with SMTP id v15mr12058343oti.452.1507232668434; Thu, 05 Oct 2017 12:44:28 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id b73sm9011795oii.1.2017.10.05.12.44.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 12:44:27 -0700 (PDT) From: Rob Herring To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Nicolas Pitre , Frank Rowand , Grant Likely Subject: [PATCH 2/6] of: remove struct property.unique_id for FDT Date: Thu, 5 Oct 2017 14:44:18 -0500 Message-Id: <20171005194422.26224-3-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005194422.26224-1-robh@kernel.org> References: <20171005194422.26224-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only Sparc uses unique_id, so remove it for FDT builds and shrink struct property a bit making the unflattened DT less of a memory hog. Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- include/linux/of.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.11.0 Acked-by: Grant Likely diff --git a/include/linux/of.h b/include/linux/of.h index cfc34117fc92..8f9e96752837 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -38,7 +38,9 @@ struct property { void *value; struct property *next; unsigned long _flags; +#if defined(CONFIG_OF_PROMTREE) unsigned int unique_id; +#endif struct bin_attribute attr; }; From patchwork Thu Oct 5 19:44:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114992 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp959088qgn; Thu, 5 Oct 2017 12:45:58 -0700 (PDT) X-Received: by 10.84.244.2 with SMTP id g2mr10485561pll.400.1507232758017; Thu, 05 Oct 2017 12:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507232758; cv=none; d=google.com; s=arc-20160816; b=QNMuIxAIAxweB1ER2KzxHupPuFXcBu+UoLcGut8sg/DI0/CcMjS4DKM5JRu94OVBu7 pnLt1kSGWpnYkYIHhwsLoWkt5uspWMPHAqZNsIaulW66LFxBxHPB68wEQtZaWQ7lh6kL E/6LzFoiy7226mdV5oleKg4u6F5GZv+73VKP4+V+lQWZu4yuyFI2pPK7Lx61f1dmwCia USWnh0ysOspxU1M36L+P5eQfPKgobcW0gAsh6SS5WDO+/2qU4+EYw6KL3zV1luJSLc0C CxlDUYYez1UBvFlAMz1/cTn8zK1zOyNaoHe0Oo79EYwYqwTh4xBrkkUsSEnInSTDsDOa 72rw== 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=N6wWpUT7ykSY26BwluXIPr9JsIf63O+MFlQ/ZHDF6tQ=; b=syVRM+1VEAWA/hCLjvd5X4IahfUHePczJ3oz1Nkk/L/QpknPgAw29J0HQTDRsIdAgB F2AtakaBnGXkAsyGahO0H6WXP684YrZpIxsvphB7vk8f8osly7LvUK5H2pIHipQGL+tJ ity2ycQX2aEWI8C43iaYR5IoVz8Ih3zH436PlaVe3327eK03wYIIgTOHkUoMGgxJi0K2 H+Y/It6kA2RRWERb9EgJOWuK8cF13JnqegmlOGPZQVs/0/tXeSUh1EWhmZVAYBgYb4S1 3/N/Qq+JM717L/yLsAMEi3z9zNt/B7LEVOQZSE8QIdcxXoYvYiM7AlIp8O9QyqVwOk47 jHkQ== 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 z1si14228160plb.359.2017.10.05.12.45.57; Thu, 05 Oct 2017 12:45:58 -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 S1752342AbdJETpy (ORCPT + 26 others); Thu, 5 Oct 2017 15:45:54 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33430 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbdJEToa (ORCPT ); Thu, 5 Oct 2017 15:44:30 -0400 Received: by mail-oi0-f67.google.com with SMTP id n129so9100692oia.0; Thu, 05 Oct 2017 12:44:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N6wWpUT7ykSY26BwluXIPr9JsIf63O+MFlQ/ZHDF6tQ=; b=MQP3NlxJbmvxuzC1XvantOnqqqr/f5AX9n9RxCpeosOFcJhwluB4QyKH9vHBuk8RwC CpvA9HxZOmNv2Idf9T+kLtnOwUVkqxIEYV7SVmjzKbhJVZdf8mPO9hbDG23GXZIQyM8f saktrtFUy8TXtmOwimA0+7YgbSc/l9fG50/4f8/o4cYoP4NpNUntf9KBbfjqgykOoGWX xeG5kptbJtxlJfOA/qLiBzyJGc9SnbfkbkLKiqyRGqIwgG/xeVGa/zvbKBNedipKGyKS G2gSV0MmP4pHKJEcoD9MJdPSyuAFrnKh/fJSNTMERpG30kb18QWBCBs0RXa9sAoJ0FOY 6vhQ== X-Gm-Message-State: AMCzsaW8ouvsUJFRc2sBBgHRNm3XD6loZvIJiYIRkEnEN41M7PZoRB9D UdOm+QZvKgOKPZVGlx61rWQq5X0= X-Google-Smtp-Source: AOwi7QBIrxnT3Y1UvLwS97apSAfBZ8tynq/d5irmjgA2CouUS+jum/9LNBD0UeGyCFo3H/8QqWstpw== X-Received: by 10.157.67.42 with SMTP id s39mr3496046ote.243.1507232669731; Thu, 05 Oct 2017 12:44:29 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id b73sm9011795oii.1.2017.10.05.12.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 12:44:28 -0700 (PDT) From: Rob Herring To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Nicolas Pitre , Frank Rowand , Grant Likely Subject: [PATCH 3/6] of: make struct property _flags field configurable Date: Thu, 5 Oct 2017 14:44:19 -0500 Message-Id: <20171005194422.26224-4-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005194422.26224-1-robh@kernel.org> References: <20171005194422.26224-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only Sparc and CONFIG_OF_DYNAMIC use the struct property._flags field, so make it conditional shrinking struct property a bit. Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- include/linux/of.h | 4 ++++ 1 file changed, 4 insertions(+) -- 2.11.0 diff --git a/include/linux/of.h b/include/linux/of.h index 8f9e96752837..7eb94b7fbcf3 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -37,7 +37,9 @@ struct property { int length; void *value; struct property *next; +#if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC) unsigned long _flags; +#endif #if defined(CONFIG_OF_PROMTREE) unsigned int unique_id; #endif @@ -205,6 +207,7 @@ static inline void of_node_clear_flag(struct device_node *n, unsigned long flag) clear_bit(flag, &n->_flags); } +#if defined(CONFIG_OF_DYNAMIC) || defined(CONFIG_SPARC) static inline int of_property_check_flag(struct property *p, unsigned long flag) { return test_bit(flag, &p->_flags); @@ -219,6 +222,7 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag { clear_bit(flag, &p->_flags); } +#endif extern struct device_node *__of_find_all_nodes(struct device_node *prev); extern struct device_node *of_find_all_nodes(struct device_node *prev); From patchwork Thu Oct 5 19:44:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114990 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp958608qgn; Thu, 5 Oct 2017 12:45:22 -0700 (PDT) X-Received: by 10.84.141.131 with SMTP id 3mr23950650plv.219.1507232722641; Thu, 05 Oct 2017 12:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507232722; cv=none; d=google.com; s=arc-20160816; b=ubnjkP6ijOwNrhUnsPYyuhOfeLhXq7VqRD6x+BMBVuN9WwfKThjfddQECrXaPIDBip 9mj9T/9r/LdECfWfopeIEO1P/GTzbAb2clB1iwWWxLNuSHep9jkVbC+PSehf57NPQxfj N/fxfcXjmSex3I/Eyxf7sIBh5Phb/UpKxAko34fLlF7FaDFxYxwntjaFiMjMnYtVkRH+ vtuOXGaCc/MNV9+f2hAgHqU3XmnVDN8uvmjm2j4hB/Ijusd1DUBTa8KJTIC51An5zplq H7hSuGvrpkXlEAa09emzmta+hxn8+/smPDKFErNt8qLto6SFYGLcQJlPlwJ4+2EtYcKG ayUA== 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=a/gEJfGlL/gJiaI7qABAvDPfTI3yxaF804rLfInBGhA=; b=UIpADozCbQJ2w3pRkMV3+/F8wdF9QehjGdUCRzdoAH6XVljd6f2XiYtRgpY6XD46rA ALDyxYt/C9jvW9ThLH6hNPkmajTFwsQBkoA4nNVxePZtmzgjVuRZDzEu771uy9ohaWg4 8yrqcawy1QfBdy2NMSfb0HEPePQ+12d+Fmar5q1OtjbPV9sQdhllG7byXhMPSsyOzY5p XzvVHkYEvWXs98hKHDqp28z74Mtu/kZtJe+g8YDjiYi9Jl4IY/kbVTK2QX0Kb9qJYdTa lzjVeJsZkVZTyEp51WoOVLc8YjEEZW5CaIW751JGhbH3ErdyLDnzruY6RPo9CRW52zgd qRPA== 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 s73si1605248pfe.177.2017.10.05.12.45.22; Thu, 05 Oct 2017 12:45:22 -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 S1752260AbdJETpT (ORCPT + 26 others); Thu, 5 Oct 2017 15:45:19 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:38764 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbdJETob (ORCPT ); Thu, 5 Oct 2017 15:44:31 -0400 Received: by mail-oi0-f68.google.com with SMTP id t134so2084101oih.5; Thu, 05 Oct 2017 12:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a/gEJfGlL/gJiaI7qABAvDPfTI3yxaF804rLfInBGhA=; b=mzdRJckFAP03VC2emPexuwjEfNiKsRth898wDUMzdO7vbtQfPeSUeuX5SVuwNi2MLy MzL094MZcmB20Dxjmt7m1gR6hIIy5sPh9aAh0Poby1q4TP6J2tbLF+9otrogNuPXyBPY 4kqvYQhVQKvC1Fuc7KhearmtQxiNgSCpdv5OCdHLwM4hqSqonDoXVmUNzNQLr3svGx8w Q70Q6NIQnsW3gVWHrRh5zct9h9f1DuYx9Q2sMPBE+Bf6YTIUyp2i+vvwSv4AoT3FeBUj /MIPczRfURdgqyJMdZgtkjaLI+FIB4k3lcDOu5De/G9TdzzM3MUisk8pWIoGYX53OWBH ffpQ== X-Gm-Message-State: AMCzsaVqkSqFHbYafU4gg8ZSVlwTr6f9kMy92+GBtW08EWQD6ea6Ge8u p/eTJJEIL53GqEP6ImQH+W0dcHA= X-Google-Smtp-Source: AOwi7QAKiYj8PM2JlSVAwLIjMZeoZX1r2oUIJOdAifFdT8qPJHifIRWzX2OZ6CzqBoHuzvvVhFBMDA== X-Received: by 10.157.35.110 with SMTP id k43mr10968376otd.434.1507232670684; Thu, 05 Oct 2017 12:44:30 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id b73sm9011795oii.1.2017.10.05.12.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 12:44:30 -0700 (PDT) From: Rob Herring To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Nicolas Pitre , Frank Rowand , Grant Likely Subject: [PATCH 4/6] of: move kobj_to_device_node() into dynamic.c Date: Thu, 5 Oct 2017 14:44:20 -0500 Message-Id: <20171005194422.26224-5-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005194422.26224-1-robh@kernel.org> References: <20171005194422.26224-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only user of kobj_to_device_node() is in dynamic.c, so move it there. This avoids having to make it conditional once kobject is configurable. Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/dynamic.c | 5 +++++ drivers/of/of_private.h | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 301b6db2b48d..9d6ba18c529f 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -16,6 +16,11 @@ #include "of_private.h" +static struct device_node *kobj_to_device_node(struct kobject *kobj) +{ + return container_of(kobj, struct device_node, kobj); +} + /** * of_node_get() - Increment refcount of a node * @node: Node to inc refcount, NULL is supported to simplify writing of diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 3ae12ffbf547..cc86a974f35f 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -35,12 +35,6 @@ extern struct mutex of_mutex; extern struct list_head aliases_lookup; extern struct kset *of_kset; - -static inline struct device_node *kobj_to_device_node(struct kobject *kobj) -{ - return container_of(kobj, struct device_node, kobj); -} - #if defined(CONFIG_OF_DYNAMIC) extern int of_property_notify(int action, struct device_node *np, struct property *prop, struct property *old_prop); From patchwork Thu Oct 5 19:44:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 114989 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp958364qgn; Thu, 5 Oct 2017 12:45:04 -0700 (PDT) X-Received: by 10.98.19.24 with SMTP id b24mr10862994pfj.168.1507232704460; Thu, 05 Oct 2017 12:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507232704; cv=none; d=google.com; s=arc-20160816; b=nmnMu0ELBIdwJ664i+A1M/CikTiieL2NTu1ikfGfUlIgbE+rON+tdazQwnDd0rZ6m4 bfV/yPk0axiuySvVrLGMsk7fMZVmkyiw8mXLuftuKy1zkJDn17a42qyGgI6ywwzg1HY/ DaMoutvYfmvjtU2yXeVKqE5JQMh6N/GflMXCQFp//KaWDZKeoMaCjLdCX3gCAaatj4oI 9Ude/gOQSL6f8g0K8BO6tPTl8xTKMU17PjydIwTwU3buQ1AeWkX9mqZDYnnPhFxMrSvl Y7uxFU1NL/kDHMsiVbYYvU3f/MIurl78LALCG9qvYo12MgvEqr9fJVSTm6TGQS6uCycB E21g== 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=8sllN3AUlmZuMMvfEajBOngUXOVbMrpWM1MB+lufJC8=; b=lYCUhuHwb4rq+QKUvUMzkeh+NzSXQbFZb4TUkGzXdooBag8UvyTIP9jACdbQUBUemS ahnBCStfx0R2fdfIz/N5gqXRzRf7bACVSSN5bEtZJ1BxmqI0kba4HPae+nz1JmjCjnfK coG1HGBCPd2kuAfPEgCaNpyF7EDGALYSkcZybMGeSEogiRlUbg7OILos6DeQTDKJQSgq AJLF1NSEF4S4vA6ppysryQ58KB82i9UvYMBeRg/8MknV9CIzNpR8Y5barcOLiG1tYLp9 0syoak37P5hbNmHGKExd2v/q4PrbXoFA6J/xPW0SzlJ/i6KLPSUzdeQ7p8ZCoB5SnSxc zm8Q== 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 x5si13362483pgp.94.2017.10.05.12.45.04; Thu, 05 Oct 2017 12:45:04 -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 S1752192AbdJETpD (ORCPT + 26 others); Thu, 5 Oct 2017 15:45:03 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:37446 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752133AbdJEToe (ORCPT ); Thu, 5 Oct 2017 15:44:34 -0400 Received: by mail-oi0-f68.google.com with SMTP id h9so9087145oia.4; Thu, 05 Oct 2017 12:44:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8sllN3AUlmZuMMvfEajBOngUXOVbMrpWM1MB+lufJC8=; b=VNrTgZQYQFJCeVJIUxeSpHk3NoINM0ZhyFom6D1p9hR0HISwkuwKLz7TIZUOQ7toXe kvWJa1qj+k7Y2PZFWdnq/HTjf09pLsZGQAgvfXiFP7XpvLZlmsOGOuVXdoR+AkDqWisS zENo6ebsEhoXTZMz/Iku3wHwYGFKRlAKHNtDlq2720qrJnd6a4SX/AnULiaJX6TLObQa 4rwQOOSqefQ60LAw/ZsF0Jr49BYiihzv/lMuk5n9kvOuDPV3Wb06JX/5KlCzpWXi+br4 dvKmVZjdITLWFkY8XA1aE0S8XiRhcBYYed/wsjBOnnZWEYJZEfYPycf/ASxYB3zXTPPW T34w== X-Gm-Message-State: AMCzsaULQptWO7xIS8Fwp8eVkWM7qWHYpJpVsNxb4SwCC7Mvu2nM+N0f H1F8e5ialdhzzVgmYSIHkFuOv3g= X-Google-Smtp-Source: AOwi7QC2bXwOBvLh6KxDJpz4Z4jvzVjYiEb4IQ4soBR/7XRKafPa+xq/w1cn80xtM2QqvvNHkyKxOQ== X-Received: by 10.157.65.204 with SMTP id v12mr11100799oti.365.1507232673051; Thu, 05 Oct 2017 12:44:33 -0700 (PDT) Received: from localhost.localdomain (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id b73sm9011795oii.1.2017.10.05.12.44.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 12:44:32 -0700 (PDT) From: Rob Herring To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Nicolas Pitre , Frank Rowand , Grant Likely Subject: [PATCH 6/6] of: make kobject and bin_attribute support configurable Date: Thu, 5 Oct 2017 14:44:22 -0500 Message-Id: <20171005194422.26224-7-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171005194422.26224-1-robh@kernel.org> References: <20171005194422.26224-1-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Having device_nodes be kobjects is only needed if sysfs or OF_DYNAMIC is enabled. Otherwise, having a kobject in struct device_node is unnecessary bloat in minimal kernel configurations. Likewise, bin_attribute is only needed in struct property when sysfs is enabled, so we can make it configurable too. Cc: Nicolas Pitre Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/Kconfig | 4 ++ drivers/of/Makefile | 1 + drivers/of/base.c | 130 -------------------------------------- drivers/of/dynamic.c | 22 ------- drivers/of/kobj.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/of/of_private.h | 23 +++++++ include/linux/of.h | 22 +++---- 7 files changed, 202 insertions(+), 164 deletions(-) create mode 100644 drivers/of/kobj.c -- 2.11.0 diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index ba7b034b2b91..ad9a9578f9c4 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -46,10 +46,14 @@ config OF_EARLY_FLATTREE config OF_PROMTREE bool +config OF_KOBJ + def_bool SYSFS + # Hardly any platforms need this. It is safe to select, but only do so if you # need it. config OF_DYNAMIC bool "Support for dynamic device trees" if OF_UNITTEST + select OF_KOBJ help On some platforms, the device tree can be manipulated at runtime. While this option is selected automatically on such platforms, you diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 97dc01c81438..83d61a7c5e82 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -1,4 +1,5 @@ obj-y = base.o device.o platform.o property.o +obj-$(CONFIG_OF_KOBJ) += kobj.o obj-$(CONFIG_OF_DYNAMIC) += dynamic.o obj-$(CONFIG_OF_FLATTREE) += fdt.o obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o diff --git a/drivers/of/base.c b/drivers/of/base.c index 9e9bd17121fb..b98f3adffbb0 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -95,105 +95,6 @@ int __weak of_node_to_nid(struct device_node *np) } #endif -#ifndef CONFIG_OF_DYNAMIC -static void of_node_release(struct kobject *kobj) -{ - /* Without CONFIG_OF_DYNAMIC, no nodes gets freed */ -} -#endif /* CONFIG_OF_DYNAMIC */ - -struct kobj_type of_node_ktype = { - .release = of_node_release, -}; - -static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, char *buf, - loff_t offset, size_t count) -{ - struct property *pp = container_of(bin_attr, struct property, attr); - return memory_read_from_buffer(buf, count, &offset, pp->value, pp->length); -} - -/* always return newly allocated name, caller must free after use */ -static const char *safe_name(struct kobject *kobj, const char *orig_name) -{ - const char *name = orig_name; - struct kernfs_node *kn; - int i = 0; - - /* don't be a hero. After 16 tries give up */ - while (i < 16 && (kn = sysfs_get_dirent(kobj->sd, name))) { - sysfs_put(kn); - if (name != orig_name) - kfree(name); - name = kasprintf(GFP_KERNEL, "%s#%i", orig_name, ++i); - } - - if (name == orig_name) { - name = kstrdup(orig_name, GFP_KERNEL); - } else { - pr_warn("Duplicate name in %s, renamed to \"%s\"\n", - kobject_name(kobj), name); - } - return name; -} - -int __of_add_property_sysfs(struct device_node *np, struct property *pp) -{ - int rc; - - /* Important: Don't leak passwords */ - bool secure = strncmp(pp->name, "security-", 9) == 0; - - if (!IS_ENABLED(CONFIG_SYSFS)) - return 0; - - if (!of_kset || !of_node_is_attached(np)) - return 0; - - sysfs_bin_attr_init(&pp->attr); - pp->attr.attr.name = safe_name(&np->kobj, pp->name); - pp->attr.attr.mode = secure ? 0400 : 0444; - pp->attr.size = secure ? 0 : pp->length; - pp->attr.read = of_node_property_read; - - rc = sysfs_create_bin_file(&np->kobj, &pp->attr); - WARN(rc, "error adding attribute %s to node %pOF\n", pp->name, np); - return rc; -} - -int __of_attach_node_sysfs(struct device_node *np) -{ - const char *name; - struct kobject *parent; - struct property *pp; - int rc; - - if (!of_kset) - return 0; - - np->kobj.kset = of_kset; - if (!np->parent) { - /* Nodes without parents are new top level trees */ - name = safe_name(&of_kset->kobj, "base"); - parent = NULL; - } else { - name = safe_name(&np->parent->kobj, kbasename(np->full_name)); - parent = &np->parent->kobj; - } - if (!name) - return -ENOMEM; - rc = kobject_add(&np->kobj, parent, "%s", name); - kfree(name); - if (rc) - return rc; - - for_each_property_of_node(np, pp) - __of_add_property_sysfs(np, pp); - - return 0; -} - void __init of_core_init(void) { struct device_node *np; @@ -1501,22 +1402,6 @@ int __of_remove_property(struct device_node *np, struct property *prop) return 0; } -void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop) -{ - sysfs_remove_bin_file(&np->kobj, &prop->attr); - kfree(prop->attr.attr.name); -} - -void __of_remove_property_sysfs(struct device_node *np, struct property *prop) -{ - if (!IS_ENABLED(CONFIG_SYSFS)) - return; - - /* at early boot, bail here and defer setup to of_init() */ - if (of_kset && of_node_is_attached(np)) - __of_sysfs_remove_bin_file(np, prop); -} - /** * of_remove_property - Remove a property from a node. * @@ -1576,21 +1461,6 @@ int __of_update_property(struct device_node *np, struct property *newprop, return 0; } -void __of_update_property_sysfs(struct device_node *np, struct property *newprop, - struct property *oldprop) -{ - if (!IS_ENABLED(CONFIG_SYSFS)) - return; - - /* At early boot, bail out and defer setup to of_init() */ - if (!of_kset) - return; - - if (oldprop) - __of_sysfs_remove_bin_file(np, oldprop); - __of_add_property_sysfs(np, newprop); -} - /* * of_update_property - Update a property in a node, if the property does * not exist, add it. diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 9d6ba18c529f..39e8cf731764 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -48,28 +48,6 @@ void of_node_put(struct device_node *node) } EXPORT_SYMBOL(of_node_put); -void __of_detach_node_sysfs(struct device_node *np) -{ - struct property *pp; - - if (!IS_ENABLED(CONFIG_SYSFS)) - return; - - BUG_ON(!of_node_is_initialized(np)); - if (!of_kset) - return; - - /* only remove properties if on sysfs */ - if (of_node_is_attached(np)) { - for_each_property_of_node(np, pp) - __of_sysfs_remove_bin_file(np, pp); - kobject_del(&np->kobj); - } - - /* finally remove the kobj_init ref */ - of_node_put(np); -} - static BLOCKING_NOTIFIER_HEAD(of_reconfig_chain); int of_reconfig_notifier_register(struct notifier_block *nb) diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c new file mode 100644 index 000000000000..250fc7bb550f --- /dev/null +++ b/drivers/of/kobj.c @@ -0,0 +1,164 @@ +#include +#include + +#include "of_private.h" + +/* true when node is initialized */ +static int of_node_is_initialized(struct device_node *node) +{ + return node && node->kobj.state_initialized; +} + +/* true when node is attached (i.e. present on sysfs) */ +int of_node_is_attached(struct device_node *node) +{ + return node && node->kobj.state_in_sysfs; +} + + +#ifndef CONFIG_OF_DYNAMIC +static void of_node_release(struct kobject *kobj) +{ + /* Without CONFIG_OF_DYNAMIC, no nodes gets freed */ +} +#endif /* CONFIG_OF_DYNAMIC */ + +struct kobj_type of_node_ktype = { + .release = of_node_release, +}; + +static ssize_t of_node_property_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, char *buf, + loff_t offset, size_t count) +{ + struct property *pp = container_of(bin_attr, struct property, attr); + return memory_read_from_buffer(buf, count, &offset, pp->value, pp->length); +} + +/* always return newly allocated name, caller must free after use */ +static const char *safe_name(struct kobject *kobj, const char *orig_name) +{ + const char *name = orig_name; + struct kernfs_node *kn; + int i = 0; + + /* don't be a hero. After 16 tries give up */ + while (i < 16 && (kn = sysfs_get_dirent(kobj->sd, name))) { + sysfs_put(kn); + if (name != orig_name) + kfree(name); + name = kasprintf(GFP_KERNEL, "%s#%i", orig_name, ++i); + } + + if (name == orig_name) { + name = kstrdup(orig_name, GFP_KERNEL); + } else { + pr_warn("Duplicate name in %s, renamed to \"%s\"\n", + kobject_name(kobj), name); + } + return name; +} + +int __of_add_property_sysfs(struct device_node *np, struct property *pp) +{ + int rc; + + /* Important: Don't leak passwords */ + bool secure = strncmp(pp->name, "security-", 9) == 0; + + if (!IS_ENABLED(CONFIG_SYSFS)) + return 0; + + if (!of_kset || !of_node_is_attached(np)) + return 0; + + sysfs_bin_attr_init(&pp->attr); + pp->attr.attr.name = safe_name(&np->kobj, pp->name); + pp->attr.attr.mode = secure ? 0400 : 0444; + pp->attr.size = secure ? 0 : pp->length; + pp->attr.read = of_node_property_read; + + rc = sysfs_create_bin_file(&np->kobj, &pp->attr); + WARN(rc, "error adding attribute %s to node %pOF\n", pp->name, np); + return rc; +} + +void __of_sysfs_remove_bin_file(struct device_node *np, struct property *prop) +{ + if (!IS_ENABLED(CONFIG_SYSFS)) + return; + + sysfs_remove_bin_file(&np->kobj, &prop->attr); + kfree(prop->attr.attr.name); +} + +void __of_remove_property_sysfs(struct device_node *np, struct property *prop) +{ + /* at early boot, bail here and defer setup to of_init() */ + if (of_kset && of_node_is_attached(np)) + __of_sysfs_remove_bin_file(np, prop); +} + +void __of_update_property_sysfs(struct device_node *np, struct property *newprop, + struct property *oldprop) +{ + /* At early boot, bail out and defer setup to of_init() */ + if (!of_kset) + return; + + if (oldprop) + __of_sysfs_remove_bin_file(np, oldprop); + __of_add_property_sysfs(np, newprop); +} + +int __of_attach_node_sysfs(struct device_node *np) +{ + const char *name; + struct kobject *parent; + struct property *pp; + int rc; + + if (!of_kset) + return 0; + + np->kobj.kset = of_kset; + if (!np->parent) { + /* Nodes without parents are new top level trees */ + name = safe_name(&of_kset->kobj, "base"); + parent = NULL; + } else { + name = safe_name(&np->parent->kobj, kbasename(np->full_name)); + parent = &np->parent->kobj; + } + if (!name) + return -ENOMEM; + rc = kobject_add(&np->kobj, parent, "%s", name); + kfree(name); + if (rc) + return rc; + + for_each_property_of_node(np, pp) + __of_add_property_sysfs(np, pp); + + return 0; +} + +void __of_detach_node_sysfs(struct device_node *np) +{ + struct property *pp; + + BUG_ON(!of_node_is_initialized(np)); + if (!of_kset) + return; + + /* only remove properties if on sysfs */ + if (of_node_is_attached(np)) { + for_each_property_of_node(np, pp) + __of_sysfs_remove_bin_file(np, pp); + kobject_del(&np->kobj); + } + + /* finally remove the kobj_init ref */ + of_node_put(np); +} + diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index cc86a974f35f..43df14f0cbce 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -49,6 +49,29 @@ static inline int of_property_notify(int action, struct device_node *np, } #endif /* CONFIG_OF_DYNAMIC */ +#if defined(CONFIG_OF_KOBJ) +int of_node_is_attached(struct device_node *node); +int __of_add_property_sysfs(struct device_node *np, struct property *pp); +void __of_remove_property_sysfs(struct device_node *np, struct property *prop); +void __of_update_property_sysfs(struct device_node *np, struct property *newprop, + struct property *oldprop); +int __of_attach_node_sysfs(struct device_node *np); +void __of_detach_node_sysfs(struct device_node *np); +#else +static inline int __of_add_property_sysfs(struct device_node *np, struct property *pp) +{ + return 0; +} +static inline void __of_remove_property_sysfs(struct device_node *np, struct property *prop) {} +static inline void __of_update_property_sysfs(struct device_node *np, + struct property *newprop, struct property *oldprop) {} +static inline int __of_attach_node_sysfs(struct device_node *np) +{ + return 0; +} +static inline void __of_detach_node_sysfs(struct device_node *np) {} +#endif + #if defined(CONFIG_OF_UNITTEST) && defined(CONFIG_OF_OVERLAY) extern void __init unittest_unflatten_overlay_base(void); #else diff --git a/include/linux/of.h b/include/linux/of.h index 2d685e769409..7b0f17be7830 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -43,7 +43,9 @@ struct property { #if defined(CONFIG_OF_PROMTREE) unsigned int unique_id; #endif +#if defined(CONFIG_OF_KOBJ) struct bin_attribute attr; +#endif }; #if defined(CONFIG_SPARC) @@ -62,7 +64,9 @@ struct device_node { struct device_node *parent; struct device_node *child; struct device_node *sibling; +#if defined(CONFIG_OF_KOBJ) struct kobject kobj; +#endif unsigned long _flags; void *data; #if defined(CONFIG_SPARC) @@ -107,23 +111,17 @@ extern struct kobj_type of_node_ktype; extern const struct fwnode_operations of_fwnode_ops; static inline void of_node_init(struct device_node *node) { +#if defined(CONFIG_OF_KOBJ) kobject_init(&node->kobj, &of_node_ktype); +#endif node->fwnode.ops = &of_fwnode_ops; } +#if defined(CONFIG_OF_KOBJ) #define of_node_kobj(n) (&(n)->kobj) - -/* true when node is initialized */ -static inline int of_node_is_initialized(struct device_node *node) -{ - return node && node->kobj.state_initialized; -} - -/* true when node is attached (i.e. present on sysfs) */ -static inline int of_node_is_attached(struct device_node *node) -{ - return node && node->kobj.state_in_sysfs; -} +#else +#define of_node_kobj(n) NULL +#endif #ifdef CONFIG_OF_DYNAMIC extern struct device_node *of_node_get(struct device_node *node);