Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1564730 > unrolled thread
| Started by | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| First post | 2017-01-23 08:40 +0100 |
| Last post | 2017-01-23 16:10 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/2] device property: allow constify properties Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-01-23 08:40 +0100
Re: [PATCH 2/2] device property: allow constify properties Mika Westerberg <mika.westerberg@linux.intel.com> - 2017-01-23 15:50 +0100
Re: [PATCH 2/2] device property: allow constify properties Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-01-23 16:10 +0100
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2017-01-23 08:40 +0100 |
| Subject | [PATCH 2/2] device property: allow constify properties |
| Message-ID | <t2Hol-3y2-5@gated-at.bofh.it> |
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.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
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 ee22ded63e06..4cbf99cb8ef6 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)
@@ -867,7 +867,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 f7fa5891a8c3..3aeb4d7acd68 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -245,7 +245,7 @@ struct property_entry *property_entries_dup(
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);
--
2.11.0.483.g087da7b7c-goog
[toc] | [next] | [standalone]
| From | Mika Westerberg <mika.westerberg@linux.intel.com> |
|---|---|
| Date | 2017-01-23 15:50 +0100 |
| Message-ID | <t2O6u-7EI-3@gated-at.bofh.it> |
| In reply to | #1564730 |
On Sun, Jan 22, 2017 at 11:38:49PM -0800, Dmitry Torokhov wrote: > 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. > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andriy.shevchenko@linux.intel.com> |
|---|---|
| Date | 2017-01-23 16:10 +0100 |
| Message-ID | <t2OpS-812-69@gated-at.bofh.it> |
| In reply to | #1564730 |
On Sun, 2017-01-22 at 23:38 -0800, Dmitry Torokhov wrote:
> 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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 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 ee22ded63e06..4cbf99cb8ef6 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)
> @@ -867,7 +867,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 f7fa5891a8c3..3aeb4d7acd68 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -245,7 +245,7 @@ struct property_entry *property_entries_dup(
> 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);
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web