Re: [PATCH] device property: don't bother the drivers with struct property_set

From: Andy Shevchenko
Date: Fri Feb 26 2016 - 09:34:49 EST


On Fri, 2016-02-26 at 13:20 +0200, Heikki Krogerus wrote:
> Since device_add_property_set() now always takes a copy of
> the property_set, and also since the fwnode type is always
> hard coded to be FWNODE_PDATA, there is no need for the
> drivers to deliver the entire struct property_set. The
> function can just create the instance of it on its own and
> bind the properties from the drivers to it on the spot.
>
> This renames device_add_property_set() to
> device_add_properties(). The function now takes struct
> property_entry as its parameter instead of struct
> property_set.

Rationale IIUC is the eliminating of an extra structure definition in
users.

FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>


>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> ---
> Âarch/arm/mach-tegra/board-paz00.c |ÂÂ6 +-----
> Âdrivers/base/platform.cÂÂÂÂÂÂÂÂÂÂÂ| 19 ++++++++++---------
> Âdrivers/base/property.cÂÂÂÂÂÂÂÂÂÂÂ| 35 ++++++++++++++++++++++-------
> ------
> Âdrivers/mfd/intel-lpss-acpi.cÂÂÂÂÂ|ÂÂ6 +-----
> Âdrivers/mfd/intel-lpss-pci.cÂÂÂÂÂÂ| 14 +++-----------
> Âdrivers/mfd/intel-lpss.cÂÂÂÂÂÂÂÂÂÂ|ÂÂ2 +-
> Âdrivers/mfd/intel-lpss.hÂÂÂÂÂÂÂÂÂÂ|ÂÂ2 +-
> Âdrivers/mfd/mfd-core.cÂÂÂÂÂÂÂÂÂÂÂÂ|ÂÂ4 ++--
> Âinclude/linux/mfd/core.hÂÂÂÂÂÂÂÂÂÂ|ÂÂ2 +-
> Âinclude/linux/platform_device.hÂÂÂ|ÂÂ4 ++--
> Âinclude/linux/property.hÂÂÂÂÂÂÂÂÂÂ| 15 +++------------
> Â11 files changed, 47 insertions(+), 62 deletions(-)
>
> Hi Rafael,
>
> This depends on Johannes' wireless next tree:
> git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git
>
>
> diff --git a/arch/arm/mach-tegra/board-paz00.c b/arch/arm/mach-
> tegra/board-paz00.c
> index 52db8bf..7478f6f 100644
> --- a/arch/arm/mach-tegra/board-paz00.c
> +++ b/arch/arm/mach-tegra/board-paz00.c
> @@ -29,10 +29,6 @@ static struct property_entry __initdata
> wifi_rfkill_prop[] = {
> Â { },
> Â};
> Â
> -static struct property_set __initdata wifi_rfkill_pset = {
> - .properties = wifi_rfkill_prop,
> -};
> -
> Âstatic struct platform_device wifi_rfkill_device = {
> Â .name = "rfkill_gpio",
> Â .id = -1,
> @@ -49,7 +45,7 @@ static struct gpiod_lookup_table wifi_gpio_lookup =
> {
> Â
> Âvoid __init tegra_paz00_wifikill_init(void)
> Â{
> - platform_device_add_properties(&wifi_rfkill_device,
> &wifi_rfkill_pset);
> + platform_device_add_properties(&wifi_rfkill_device,
> wifi_rfkill_prop);
> Â gpiod_add_lookup_table(&wifi_gpio_lookup);
> Â platform_device_register(&wifi_rfkill_device);
> Â}
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index f437afa..6482d47 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -322,16 +322,16 @@ EXPORT_SYMBOL_GPL(platform_device_add_data);
> Â/**
> Â * platform_device_add_properties - add built-in properties to a
> platform device
> Â * @pdev: platform device to add properties to
> - * @pset: properties to add
> + * @properties: null terminated array of properties to add
> Â *
> - * The function will take deep copy of the properties in @pset and
> attach
> - * the copy to the platform device. The memory associated with
> properties
> - * will be freed when the platform device is released.
> + * The function will take deep copy of @properties and attach the
> copy to the
> + * platform device. The memory associated with properties will be
> freed when the
> + * platform device is released.
> Â */
> Âint platform_device_add_properties(struct platform_device *pdev,
> - ÂÂÂconst struct property_set *pset)
> + ÂÂÂstruct property_entry
> *properties)
> Â{
> - return device_add_property_set(&pdev->dev, pset);
> + return device_add_properties(&pdev->dev, properties);
> Â}
> ÂEXPORT_SYMBOL_GPL(platform_device_add_properties);
> Â
> @@ -447,7 +447,7 @@ void platform_device_del(struct platform_device
> *pdev)
> Â release_resource(r);
> Â }
> Â
> - device_remove_property_set(&pdev->dev);
> + device_remove_properties(&pdev->dev);
> Â }
> Â}
> ÂEXPORT_SYMBOL_GPL(platform_device_del);
> @@ -526,8 +526,9 @@ struct platform_device
> *platform_device_register_full(
> Â if (ret)
> Â goto err;
> Â
> - if (pdevinfo->pset) {
> - ret = platform_device_add_properties(pdev, pdevinfo-
> >pset);
> + if (pdevinfo->properties) {
> + ret = platform_device_add_properties(pdev,
> + ÂÂÂÂÂpdevinfo-
> >properties);
> Â if (ret)
> Â goto err;
> Â }
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index 167f0a9..8442033 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -19,6 +19,11 @@
> Â#include <linux/etherdevice.h>
> Â#include <linux/phy.h>
> Â
> +struct property_set {
> + struct fwnode_handle fwnode;
> + struct property_entry *properties;
> +};
> +
> Âstatic inline bool is_pset_node(struct fwnode_handle *fwnode)
> Â{
> Â return fwnode && fwnode->type == FWNODE_PDATA;
> @@ -797,14 +802,14 @@ static struct property_set *pset_copy_set(const
> struct property_set *pset)
> Â}
> Â
> Â/**
> - * device_remove_property_set - Remove properties from a device
> object.
> + * device_remove_properties - Remove properties from a device
> object.
> Â * @dev: Device whose properties to remove.
> Â *
> Â * The function removes properties previously associated to the
> device
> - * secondary firmware node with device_add_property_set(). Memory
> allocated
> + * secondary firmware node with device_add_properties(). Memory
> allocated
> Â * to the properties will also be released.
> Â */
> -void device_remove_property_set(struct device *dev)
> +void device_remove_properties(struct device *dev)
> Â{
> Â struct fwnode_handle *fwnode;
> Â
> @@ -822,24 +827,28 @@ void device_remove_property_set(struct device
> *dev)
> Â pset_free_set(to_pset_node(fwnode));
> Â set_secondary_fwnode(dev, NULL);
> Â}
> -EXPORT_SYMBOL_GPL(device_remove_property_set);
> +EXPORT_SYMBOL_GPL(device_remove_properties);
> Â
> Â/**
> - * device_add_property_set - Add a collection of properties to a
> device object.
> + * device_add_properties - Add a collection of properties to a
> device object.
> Â * @dev: Device to add properties to.
> - * @pset: Collection of properties to add.
> + * @properties: Collection of properties to add.
> Â *
> - * Associate a collection of device properties represented by @pset
> with @dev
> - * as its secondary firmware node. The function takes a copy of
> @pset.
> + * Associate a collection of device properties represented by
> @properties with
> + * @dev as its secondary firmware node. The function takes a copy of
> + * @properties.
> Â */
> -int device_add_property_set(struct device *dev, const struct
> property_set *pset)
> +int device_add_properties(struct device *dev,
> + ÂÂstruct property_entry *properties)
> Â{
> - struct property_set *p;
> + struct property_set *p, pset;
> Â
> - if (!pset)
> + if (!properties)
> Â return -EINVAL;
> Â
> - p = pset_copy_set(pset);
> + pset.properties = properties;
> +
> + p = pset_copy_set(&pset);
> Â if (IS_ERR(p))
> Â return PTR_ERR(p);
> Â
> @@ -847,7 +856,7 @@ int device_add_property_set(struct device *dev,
> const struct property_set *pset)
> Â set_secondary_fwnode(dev, &p->fwnode);
> Â return 0;
> Â}
> -EXPORT_SYMBOL_GPL(device_add_property_set);
> +EXPORT_SYMBOL_GPL(device_add_properties);
> Â
> Â/**
> Â * device_get_next_child_node - Return the next child node handle
> for a device
> diff --git a/drivers/mfd/intel-lpss-acpi.c b/drivers/mfd/intel-lpss-
> acpi.c
> index 06f00d6..8e94ad2 100644
> --- a/drivers/mfd/intel-lpss-acpi.c
> +++ b/drivers/mfd/intel-lpss-acpi.c
> @@ -31,13 +31,9 @@ static struct property_entry spt_i2c_properties[]
> = {
> Â { },
> Â};
> Â
> -static struct property_set spt_i2c_pset = {
> - .properties = spt_i2c_properties,
> -};
> -
> Âstatic const struct intel_lpss_platform_info spt_i2c_info = {
> Â .clk_rate = 120000000,
> - .pset = &spt_i2c_pset,
> + .properties = spt_i2c_properties,
> Â};
> Â
> Âstatic const struct intel_lpss_platform_info bxt_info = {
> diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-
> pci.c
> index afc7af9..5855cce 100644
> --- a/drivers/mfd/intel-lpss-pci.c
> +++ b/drivers/mfd/intel-lpss-pci.c
> @@ -71,13 +71,9 @@ static struct property_entry spt_i2c_properties[]
> = {
> Â { },
> Â};
> Â
> -static struct property_set spt_i2c_pset = {
> - .properties = spt_i2c_properties,
> -};
> -
> Âstatic const struct intel_lpss_platform_info spt_i2c_info = {
> Â .clk_rate = 120000000,
> - .pset = &spt_i2c_pset,
> + .properties = spt_i2c_properties,
> Â};
> Â
> Âstatic struct property_entry uart_properties[] = {
> @@ -87,14 +83,10 @@ static struct property_entry uart_properties[] =
> {
> Â { },
> Â};
> Â
> -static struct property_set uart_pset = {
> - .properties = uart_properties,
> -};
> -
> Âstatic const struct intel_lpss_platform_info spt_uart_info = {
> Â .clk_rate = 120000000,
> Â .clk_con_id = "baudclk",
> - .pset = &uart_pset,
> + .properties = uart_properties,
> Â};
> Â
> Âstatic const struct intel_lpss_platform_info bxt_info = {
> @@ -104,7 +96,7 @@ static const struct intel_lpss_platform_info
> bxt_info = {
> Âstatic const struct intel_lpss_platform_info bxt_uart_info = {
> Â .clk_rate = 100000000,
> Â .clk_con_id = "baudclk",
> - .pset = &uart_pset,
> + .properties = uart_properties,
> Â};
> Â
> Âstatic const struct intel_lpss_platform_info bxt_i2c_info = {
> diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
> index 1bbbe87..6352aab 100644
> --- a/drivers/mfd/intel-lpss.c
> +++ b/drivers/mfd/intel-lpss.c
> @@ -407,7 +407,7 @@ int intel_lpss_probe(struct device *dev,
> Â if (ret)
> Â return ret;
> Â
> - lpss->cell->pset = info->pset;
> + lpss->cell->properties = info->properties;
> Â
> Â intel_lpss_init_dev(lpss);
> Â
> diff --git a/drivers/mfd/intel-lpss.h b/drivers/mfd/intel-lpss.h
> index 0dcea9e..d064973 100644
> --- a/drivers/mfd/intel-lpss.h
> +++ b/drivers/mfd/intel-lpss.h
> @@ -23,7 +23,7 @@ struct intel_lpss_platform_info {
> Â int irq;
> Â unsigned long clk_rate;
> Â const char *clk_con_id;
> - struct property_set *pset;
> + struct property_entry *properties;
> Â};
> Â
> Âint intel_lpss_probe(struct device *dev,
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 88bd1b1..fc1c1fc 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -193,8 +193,8 @@ static int mfd_add_device(struct device *parent,
> int id,
> Â goto fail_alias;
> Â }
> Â
> - if (cell->pset) {
> - ret = platform_device_add_properties(pdev, cell-
> >pset);
> + if (cell->properties) {
> + ret = platform_device_add_properties(pdev, cell-
> >properties);
> Â if (ret)
> Â goto fail_alias;
> Â }
> diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
> index 1a5a87f..ba9d79f 100644
> --- a/include/linux/mfd/core.h
> +++ b/include/linux/mfd/core.h
> @@ -73,7 +73,7 @@ struct mfd_cell {
> Â size_t pdata_size;
> Â
> Â /* device properties passed to the sub devices drivers */
> - const struct property_set *pset;
> + struct property_entry *properties;
> Â
> Â /*
> Â Â* Device Tree compatible string
> diff --git a/include/linux/platform_device.h
> b/include/linux/platform_device.h
> index 03b7555..66dca60 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -73,7 +73,7 @@ struct platform_device_info {
> Â size_t size_data;
> Â u64 dma_mask;
> Â
> - const struct property_set *pset;
> + struct property_entry *properties;
> Â};
> Âextern struct platform_device *platform_device_register_full(
> Â const struct platform_device_info *pdevinfo);
> @@ -172,7 +172,7 @@ extern int platform_device_add_resources(struct
> platform_device *pdev,
> Âextern int platform_device_add_data(struct platform_device *pdev,
> Â ÂÂÂÂconst void *data, size_t size);
> Âextern int platform_device_add_properties(struct platform_device
> *pdev,
> - ÂÂconst struct property_set
> *pset);
> + ÂÂstruct property_entry
> *properties);
> Âextern int platform_device_add(struct platform_device *pdev);
> Âextern void platform_device_del(struct platform_device *pdev);
> Âextern void platform_device_put(struct platform_device *pdev);
> diff --git a/include/linux/property.h b/include/linux/property.h
> index b51fcd3..ecab11e 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -238,18 +238,9 @@ struct property_entry {
> Â .name = _name_, \
> Â}
> Â
> -/**
> - * struct property_set - Collection of "built-in" device properties.
> - * @fwnode: Handle to be pointed to by the fwnode field of struct
> device.
> - * @properties: Array of properties terminated with a null entry.
> - */
> -struct property_set {
> - struct fwnode_handle fwnode;
> - struct property_entry *properties;
> -};
> -
> -int device_add_property_set(struct device *dev, const struct
> property_set *pset);
> -void device_remove_property_set(struct device *dev);
> +int device_add_properties(struct device *dev,
> + ÂÂstruct property_entry *properties);
> +void device_remove_properties(struct device *dev);
> Â
> Âbool device_dma_supported(struct device *dev);
> Â

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy