From patchwork Wed Feb 1 17:31:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9550337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2FC8604A7 for ; Wed, 1 Feb 2017 17:33:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A30422040D for ; Wed, 1 Feb 2017 17:33:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97F8728435; Wed, 1 Feb 2017 17:33:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DF1B2040D for ; Wed, 1 Feb 2017 17:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753188AbdBARbe (ORCPT ); Wed, 1 Feb 2017 12:31:34 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35018 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753544AbdBARba (ORCPT ); Wed, 1 Feb 2017 12:31:30 -0500 Received: by mail-pf0-f193.google.com with SMTP id f144so32268979pfa.2; Wed, 01 Feb 2017 09:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fczHgYNWd2B260O/2kWDYXiJJ+/LrXaGV/JHhz36P0E=; b=pDglE3ZjzsxgxRRkvM+gdNQMI5lO3ah/p0YH75td5HNrCeju3JYs8+2URrm1k1ps7g LuoBKiAZ+7n6Iy3SVHNhD+iewvJYAHrq8s++FqMu+lxI0yqRLLSlJBAF2oTjFISZ59kj dayVBGtayZUmX05CXQtLQa6wUbJHqzPrN71L1qEyxaG0ZcwM0927TKONppyISuQUTX8v /vSjKhKLTEagYcsfSt0KLGxxzJOQNEugcAdLzlYRr29WU00f/zstKBPMZK9m/0Jjcayt rGlhp/ePJezjS+oKDRPsSymNUOHGexSyD5VRKjiEJ9e6KgNMKvyn4dC2oqTLCFkQYSPB ziMQ== 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=fczHgYNWd2B260O/2kWDYXiJJ+/LrXaGV/JHhz36P0E=; b=F69qdsWn1TpDEw7VmXo3HTxr3O2Vl1f/logtZxBPxF99idTYncIavgfTilc9J8Ekee URsou3X/2lILgUYIrAXhjoe26OKGZVqQvAe6PfsPQDQEEjy1ksO1cMATmAsZ6XgAoIeW x2UfRAIE0LYmPGmfe87QXHeP+8PmlDZgDp84eQwn5ZJTy5WKz14Pr9wG/6OEixYdDCv5 IYUhHnwBR0Oy3ZY+LKBL2kAQz8+JCWmwfCOject8rCIHOKb+VX9bbtcNxO/QUB7AJrCp HxxM+KyuekmMfh3cM6hjwTwmjQyRZ2cL21KJ1egaNxo5z41XPKUc2cITYW22PsgiwfJx I2AQ== X-Gm-Message-State: AIkVDXI27KzqJ2QhO7mKaeHY5auovW7VDSw9RDDAYTihKXDvPp4BqW4JQUP8l2PKpvRkAQ== X-Received: by 10.99.222.17 with SMTP id f17mr5126405pgg.127.1485970289212; Wed, 01 Feb 2017 09:31:29 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id u14sm51170803pfg.18.2017.02.01.09.31.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Feb 2017 09:31:28 -0800 (PST) From: Dmitry Torokhov To: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Hans de Goede , Wolfram Sang Subject: [PATCH v3 2/4] device property: allow to constify properties Date: Wed, 1 Feb 2017 09:31:23 -0800 Message-Id: <20170201173125.40354-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170201173125.40354-1-dmitry.torokhov@gmail.com> References: <20170201173125.40354-1-dmitry.torokhov@gmail.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no reason why statically defined properties should be modifiable, so let's make device_add_properties() and the rest of pset_*() functions to take const pointers to properties. This will allow us to mark properties as const/__initconst at definition sites. Reviewed-by: Mika Westerberg Reviewed-by: Andy Shevchenko Signed-off-by: Dmitry Torokhov --- drivers/base/property.c | 35 ++++++++++++++++++----------------- include/linux/property.h | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 934845fc72e5..edc09854520b 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -21,7 +21,7 @@ struct property_set { struct fwnode_handle fwnode; - struct property_entry *properties; + const struct property_entry *properties; }; static inline bool is_pset_node(struct fwnode_handle *fwnode) @@ -35,10 +35,10 @@ static inline struct property_set *to_pset_node(struct fwnode_handle *fwnode) container_of(fwnode, struct property_set, fwnode) : NULL; } -static struct property_entry *pset_prop_get(struct property_set *pset, - const char *name) +static const struct property_entry *pset_prop_get(struct property_set *pset, + const char *name) { - struct property_entry *prop; + const struct property_entry *prop; if (!pset || !pset->properties) return NULL; @@ -50,11 +50,11 @@ static struct property_entry *pset_prop_get(struct property_set *pset, return NULL; } -static void *pset_prop_find(struct property_set *pset, const char *propname, - size_t length) +static const void *pset_prop_find(struct property_set *pset, + const char *propname, size_t length) { - struct property_entry *prop; - void *pointer; + const struct property_entry *prop; + const void *pointer; prop = pset_prop_get(pset, propname); if (!prop) @@ -74,7 +74,7 @@ static int pset_prop_read_u8_array(struct property_set *pset, const char *propname, u8 *values, size_t nval) { - void *pointer; + const void *pointer; size_t length = nval * sizeof(*values); pointer = pset_prop_find(pset, propname, length); @@ -89,7 +89,7 @@ static int pset_prop_read_u16_array(struct property_set *pset, const char *propname, u16 *values, size_t nval) { - void *pointer; + const void *pointer; size_t length = nval * sizeof(*values); pointer = pset_prop_find(pset, propname, length); @@ -104,7 +104,7 @@ static int pset_prop_read_u32_array(struct property_set *pset, const char *propname, u32 *values, size_t nval) { - void *pointer; + const void *pointer; size_t length = nval * sizeof(*values); pointer = pset_prop_find(pset, propname, length); @@ -119,7 +119,7 @@ static int pset_prop_read_u64_array(struct property_set *pset, const char *propname, u64 *values, size_t nval) { - void *pointer; + const void *pointer; size_t length = nval * sizeof(*values); pointer = pset_prop_find(pset, propname, length); @@ -133,7 +133,7 @@ static int pset_prop_read_u64_array(struct property_set *pset, static int pset_prop_count_elems_of_size(struct property_set *pset, const char *propname, size_t length) { - struct property_entry *prop; + const struct property_entry *prop; prop = pset_prop_get(pset, propname); if (!prop) @@ -146,7 +146,7 @@ static int pset_prop_read_string_array(struct property_set *pset, const char *propname, const char **strings, size_t nval) { - void *pointer; + const void *pointer; size_t length = nval * sizeof(*strings); pointer = pset_prop_find(pset, propname, length); @@ -160,8 +160,8 @@ static int pset_prop_read_string_array(struct property_set *pset, static int pset_prop_read_string(struct property_set *pset, const char *propname, const char **strings) { - struct property_entry *prop; - const char **pointer; + const struct property_entry *prop; + const char * const *pointer; prop = pset_prop_get(pset, propname); if (!prop) @@ -880,7 +880,8 @@ EXPORT_SYMBOL_GPL(device_remove_properties); * @dev as its secondary firmware node. The function takes a copy of * @properties. */ -int device_add_properties(struct device *dev, struct property_entry *properties) +int device_add_properties(struct device *dev, + const struct property_entry *properties) { struct property_set *p, pset; diff --git a/include/linux/property.h b/include/linux/property.h index 48f154ae7e99..5746e9927016 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -247,7 +247,7 @@ property_entries_dup(const struct property_entry *properties); void property_entries_free(const struct property_entry *properties); int device_add_properties(struct device *dev, - struct property_entry *properties); + const struct property_entry *properties); void device_remove_properties(struct device *dev); bool device_dma_supported(struct device *dev);