Commit 4152c4d0 authored by Mark Brown's avatar Mark Brown

Merge series "spi: Adding support for software nodes" from Heikki Krogerus...

Merge series "spi: Adding support for software nodes" from Heikki Krogerus <heikki.krogerus@linux.intel.com>:

Hi,

The older API used to supply additional device properties for the
devices - so mainly the function device_add_properties() - is going to
be removed. The reason why the API will be removed is because it gives
false impression that the properties are assigned directly to the
devices, which has actually never been the case - the properties have
always been assigned to a software fwnode which was then just directly
linked with the device when the old API was used. By only accepting
device properties instead of complete software nodes, the subsystems
remove any change of taking advantage of the other features the
software nodes have.

The change that is required from the spi subsystem and the drivers is
trivial. Basically only the "properties" member in struct
spi_board_info, which was a pointer to struct property_entry, is
replaced with a pointer to a complete software node.

thanks,

Heikki Krogerus (4):
  spi: Add support for software nodes
  ARM: pxa: icontrol: Constify the software node
  ARM: pxa: zeus: Constify the software node
  spi: Remove support for dangling device properties

 arch/arm/mach-pxa/icontrol.c | 12 ++++++++----
 arch/arm/mach-pxa/zeus.c     |  6 +++++-
 drivers/spi/spi.c            | 21 ++++++---------------
 include/linux/spi/spi.h      |  7 +++----
 4 files changed, 22 insertions(+), 24 deletions(-)

--
2.30.1

base-commit: a38fd874
parents d11233e0 df41a5da
...@@ -74,13 +74,17 @@ static const struct property_entry mcp251x_properties[] = { ...@@ -74,13 +74,17 @@ static const struct property_entry mcp251x_properties[] = {
{} {}
}; };
static const struct software_node mcp251x_node = {
.properties = mcp251x_properties,
};
static struct spi_board_info mcp251x_board_info[] = { static struct spi_board_info mcp251x_board_info[] = {
{ {
.modalias = "mcp2515", .modalias = "mcp2515",
.max_speed_hz = 6500000, .max_speed_hz = 6500000,
.bus_num = 3, .bus_num = 3,
.chip_select = 0, .chip_select = 0,
.properties = mcp251x_properties, .swnode = &mcp251x_node,
.controller_data = &mcp251x_chip_info1, .controller_data = &mcp251x_chip_info1,
.irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1) .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
}, },
...@@ -89,7 +93,7 @@ static struct spi_board_info mcp251x_board_info[] = { ...@@ -89,7 +93,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.max_speed_hz = 6500000, .max_speed_hz = 6500000,
.bus_num = 3, .bus_num = 3,
.chip_select = 1, .chip_select = 1,
.properties = mcp251x_properties, .swnode = &mcp251x_node,
.controller_data = &mcp251x_chip_info2, .controller_data = &mcp251x_chip_info2,
.irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2) .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
}, },
...@@ -98,7 +102,7 @@ static struct spi_board_info mcp251x_board_info[] = { ...@@ -98,7 +102,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.max_speed_hz = 6500000, .max_speed_hz = 6500000,
.bus_num = 4, .bus_num = 4,
.chip_select = 0, .chip_select = 0,
.properties = mcp251x_properties, .swnode = &mcp251x_node,
.controller_data = &mcp251x_chip_info3, .controller_data = &mcp251x_chip_info3,
.irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3) .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
}, },
...@@ -107,7 +111,7 @@ static struct spi_board_info mcp251x_board_info[] = { ...@@ -107,7 +111,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.max_speed_hz = 6500000, .max_speed_hz = 6500000,
.bus_num = 4, .bus_num = 4,
.chip_select = 1, .chip_select = 1,
.properties = mcp251x_properties, .swnode = &mcp251x_node,
.controller_data = &mcp251x_chip_info4, .controller_data = &mcp251x_chip_info4,
.irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4) .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
} }
......
...@@ -433,10 +433,14 @@ static const struct property_entry mcp251x_properties[] = { ...@@ -433,10 +433,14 @@ static const struct property_entry mcp251x_properties[] = {
{} {}
}; };
static const struct software_node mcp251x_node = {
.properties = mcp251x_properties,
};
static struct spi_board_info zeus_spi_board_info[] = { static struct spi_board_info zeus_spi_board_info[] = {
[0] = { [0] = {
.modalias = "mcp2515", .modalias = "mcp2515",
.properties = mcp251x_properties, .swnode = &mcp251x_node,
.irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO), .irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO),
.max_speed_hz = 1*1000*1000, .max_speed_hz = 1*1000*1000,
.bus_num = 3, .bus_num = 3,
......
...@@ -676,11 +676,10 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, ...@@ -676,11 +676,10 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,
proxy->controller_data = chip->controller_data; proxy->controller_data = chip->controller_data;
proxy->controller_state = NULL; proxy->controller_state = NULL;
if (chip->properties) { if (chip->swnode) {
status = device_add_properties(&proxy->dev, chip->properties); status = device_add_software_node(&proxy->dev, chip->swnode);
if (status) { if (status) {
dev_err(&ctlr->dev, dev_err(&ctlr->dev, "failed to add softwade node to '%s': %d\n",
"failed to add properties to '%s': %d\n",
chip->modalias, status); chip->modalias, status);
goto err_dev_put; goto err_dev_put;
} }
...@@ -688,14 +687,12 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr, ...@@ -688,14 +687,12 @@ struct spi_device *spi_new_device(struct spi_controller *ctlr,
status = spi_add_device(proxy); status = spi_add_device(proxy);
if (status < 0) if (status < 0)
goto err_remove_props; goto err_dev_put;
return proxy; return proxy;
err_remove_props:
if (chip->properties)
device_remove_properties(&proxy->dev);
err_dev_put: err_dev_put:
device_remove_software_node(&proxy->dev);
spi_dev_put(proxy); spi_dev_put(proxy);
return NULL; return NULL;
} }
...@@ -719,6 +716,7 @@ void spi_unregister_device(struct spi_device *spi) ...@@ -719,6 +716,7 @@ void spi_unregister_device(struct spi_device *spi)
} }
if (ACPI_COMPANION(&spi->dev)) if (ACPI_COMPANION(&spi->dev))
acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev)); acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev));
device_remove_software_node(&spi->dev);
device_unregister(&spi->dev); device_unregister(&spi->dev);
} }
EXPORT_SYMBOL_GPL(spi_unregister_device); EXPORT_SYMBOL_GPL(spi_unregister_device);
...@@ -755,7 +753,6 @@ static void spi_match_controller_to_boardinfo(struct spi_controller *ctlr, ...@@ -755,7 +753,6 @@ static void spi_match_controller_to_boardinfo(struct spi_controller *ctlr,
* *
* The board info passed can safely be __initdata ... but be careful of * The board info passed can safely be __initdata ... but be careful of
* any embedded pointers (platform_data, etc), they're copied as-is. * any embedded pointers (platform_data, etc), they're copied as-is.
* Device properties are deep-copied though.
* *
* Return: zero on success, else a negative error code. * Return: zero on success, else a negative error code.
*/ */
...@@ -775,12 +772,6 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n) ...@@ -775,12 +772,6 @@ int spi_register_board_info(struct spi_board_info const *info, unsigned n)
struct spi_controller *ctlr; struct spi_controller *ctlr;
memcpy(&bi->board_info, info, sizeof(*info)); memcpy(&bi->board_info, info, sizeof(*info));
if (info->properties) {
bi->board_info.properties =
property_entries_dup(info->properties);
if (IS_ERR(bi->board_info.properties))
return PTR_ERR(bi->board_info.properties);
}
mutex_lock(&board_lock); mutex_lock(&board_lock);
list_add_tail(&bi->list, &board_list); list_add_tail(&bi->list, &board_list);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <uapi/linux/spi/spi.h> #include <uapi/linux/spi/spi.h>
struct dma_chan; struct dma_chan;
struct property_entry; struct software_node;
struct spi_controller; struct spi_controller;
struct spi_transfer; struct spi_transfer;
struct spi_controller_mem_ops; struct spi_controller_mem_ops;
...@@ -1397,7 +1397,7 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd) ...@@ -1397,7 +1397,7 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
* @modalias: Initializes spi_device.modalias; identifies the driver. * @modalias: Initializes spi_device.modalias; identifies the driver.
* @platform_data: Initializes spi_device.platform_data; the particular * @platform_data: Initializes spi_device.platform_data; the particular
* data stored there is driver-specific. * data stored there is driver-specific.
* @properties: Additional device properties for the device. * @swnode: Software node for the device.
* @controller_data: Initializes spi_device.controller_data; some * @controller_data: Initializes spi_device.controller_data; some
* controllers need hints about hardware setup, e.g. for DMA. * controllers need hints about hardware setup, e.g. for DMA.
* @irq: Initializes spi_device.irq; depends on how the board is wired. * @irq: Initializes spi_device.irq; depends on how the board is wired.
...@@ -1430,12 +1430,11 @@ struct spi_board_info { ...@@ -1430,12 +1430,11 @@ struct spi_board_info {
* *
* platform_data goes to spi_device.dev.platform_data, * platform_data goes to spi_device.dev.platform_data,
* controller_data goes to spi_device.controller_data, * controller_data goes to spi_device.controller_data,
* device properties are copied and attached to spi_device,
* irq is copied too * irq is copied too
*/ */
char modalias[SPI_NAME_SIZE]; char modalias[SPI_NAME_SIZE];
const void *platform_data; const void *platform_data;
const struct property_entry *properties; const struct software_node *swnode;
void *controller_data; void *controller_data;
int irq; int irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment