* [PATCH 1/3] spi: s3c64xx: simplify probe function by using local variable for &pdev->dev
@ 2015-08-18 21:05 Heiner Kallweit
2015-08-18 23:56 ` Krzysztof Kozlowski
0 siblings, 1 reply; 3+ messages in thread
From: Heiner Kallweit @ 2015-08-18 21:05 UTC (permalink / raw)
To: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Krzysztof Kozlowski
Simplify the probe function by replacing all occurrences of &pdev->dev
with a local variable.
Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/spi/spi-s3c64xx.c | 58 +++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index cd1cfac..c4d3b06 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1024,39 +1024,39 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
static int s3c64xx_spi_probe(struct platform_device *pdev)
{
+ struct device *dev = &pdev->dev;
struct resource *mem_res;
struct resource *res;
struct s3c64xx_spi_driver_data *sdd;
- struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev);
+ struct s3c64xx_spi_info *sci = dev_get_platdata(dev);
struct spi_master *master;
int ret, irq;
char clk_name[16];
- if (!sci && pdev->dev.of_node) {
- sci = s3c64xx_spi_parse_dt(&pdev->dev);
+ if (!sci && dev->of_node) {
+ sci = s3c64xx_spi_parse_dt(dev);
if (IS_ERR(sci))
return PTR_ERR(sci);
}
if (!sci) {
- dev_err(&pdev->dev, "platform_data missing!\n");
+ dev_err(dev, "platform_data missing!\n");
return -ENODEV;
}
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (mem_res == NULL) {
- dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
+ dev_err(dev, "Unable to get SPI MEM resource\n");
return -ENXIO;
}
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
- dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
+ dev_warn(dev, "Failed to get IRQ: %d\n", irq);
return irq;
}
- master = spi_alloc_master(&pdev->dev,
- sizeof(struct s3c64xx_spi_driver_data));
+ master = spi_alloc_master(dev, sizeof(struct s3c64xx_spi_driver_data));
if (master == NULL) {
dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
return -ENOMEM;
@@ -1071,9 +1071,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
sdd->pdev = pdev;
sdd->sfr_start = mem_res->start;
if (pdev->dev.of_node) {
- ret = of_alias_get_id(pdev->dev.of_node, "spi");
+ ret = of_alias_get_id(dev->of_node, "spi");
if (ret < 0) {
- dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
+ dev_err(dev, "failed to get alias id, errno %d\n",
ret);
goto err0;
}
@@ -1087,14 +1087,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
if (!sdd->pdev->dev.of_node) {
res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!res) {
- dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
+ dev_warn(dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
} else
sdd->tx_dma.dmach = res->start;
res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
if (!res) {
- dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
+ dev_warn(dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
} else
sdd->rx_dma.dmach = res->start;
@@ -1103,7 +1103,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
sdd->tx_dma.direction = DMA_MEM_TO_DEV;
sdd->rx_dma.direction = DMA_DEV_TO_MEM;
- master->dev.of_node = pdev->dev.of_node;
+ master->dev.of_node = dev->of_node;
master->bus_num = sdd->port_id;
master->setup = s3c64xx_spi_setup;
master->cleanup = s3c64xx_spi_cleanup;
@@ -1121,43 +1121,43 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
if (!is_polling(sdd))
master->can_dma = s3c64xx_spi_can_dma;
- sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
+ sdd->regs = devm_ioremap_resource(dev, mem_res);
if (IS_ERR(sdd->regs)) {
ret = PTR_ERR(sdd->regs);
goto err0;
}
if (sci->cfg_gpio && sci->cfg_gpio()) {
- dev_err(&pdev->dev, "Unable to config gpio\n");
+ dev_err(dev, "Unable to config gpio\n");
ret = -EBUSY;
goto err0;
}
/* Setup clocks */
- sdd->clk = devm_clk_get(&pdev->dev, "spi");
+ sdd->clk = devm_clk_get(dev, "spi");
if (IS_ERR(sdd->clk)) {
- dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
+ dev_err(dev, "Unable to acquire clock 'spi'\n");
ret = PTR_ERR(sdd->clk);
goto err0;
}
if (clk_prepare_enable(sdd->clk)) {
- dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
+ dev_err(dev, "Couldn't enable clock 'spi'\n");
ret = -EBUSY;
goto err0;
}
sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
- sdd->src_clk = devm_clk_get(&pdev->dev, clk_name);
+ sdd->src_clk = devm_clk_get(dev, clk_name);
if (IS_ERR(sdd->src_clk)) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"Unable to acquire clock '%s'\n", clk_name);
ret = PTR_ERR(sdd->src_clk);
goto err2;
}
if (clk_prepare_enable(sdd->src_clk)) {
- dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name);
+ dev_err(dev, "Couldn't enable clock '%s'\n", clk_name);
ret = -EBUSY;
goto err2;
}
@@ -1168,10 +1168,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
spin_lock_init(&sdd->lock);
init_completion(&sdd->xfer_completion);
- ret = devm_request_irq(&pdev->dev, irq, s3c64xx_spi_irq, 0,
+ ret = devm_request_irq(dev, irq, s3c64xx_spi_irq, 0,
"spi-s3c64xx", sdd);
if (ret != 0) {
- dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n",
+ dev_err(dev, "Failed to request IRQ %d: %d\n",
irq, ret);
goto err3;
}
@@ -1180,18 +1180,18 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN,
sdd->regs + S3C64XX_SPI_INT_EN);
- pm_runtime_set_active(&pdev->dev);
- pm_runtime_enable(&pdev->dev);
+ pm_runtime_set_active(dev);
+ pm_runtime_enable(dev);
- ret = devm_spi_register_master(&pdev->dev, master);
+ ret = devm_spi_register_master(dev, master);
if (ret != 0) {
- dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret);
+ dev_err(dev, "cannot register SPI master: %d\n", ret);
goto err3;
}
- dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
+ dev_dbg(dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
sdd->port_id, master->num_chipselect);
- dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
+ dev_dbg(dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
sdd->rx_dma.dmach, sdd->tx_dma.dmach);
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] spi: s3c64xx: simplify probe function by using local variable for &pdev->dev
2015-08-18 21:05 [PATCH 1/3] spi: s3c64xx: simplify probe function by using local variable for &pdev->dev Heiner Kallweit
@ 2015-08-18 23:56 ` Krzysztof Kozlowski
[not found] ` <55D3C618.1000305-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2015-08-18 23:56 UTC (permalink / raw)
To: Heiner Kallweit, linux-samsung-soc; +Cc: linux-spi@vger.kernel.org
On 19.08.2015 06:05, Heiner Kallweit wrote:
> Simplify the probe function by replacing all occurrences of &pdev->dev
> with a local variable.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/spi/spi-s3c64xx.c | 58 +++++++++++++++++++++++------------------------
> 1 file changed, 29 insertions(+), 29 deletions(-)
I don't see simplification here (the same number of insertions as
deletions, code is exactly the same). &pdev->dev is a common pattern in
most of platform drivers.
Best regards,
Krzysztof
>
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index cd1cfac..c4d3b06 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -1024,39 +1024,39 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
>
> static int s3c64xx_spi_probe(struct platform_device *pdev)
> {
> + struct device *dev = &pdev->dev;
> struct resource *mem_res;
> struct resource *res;
> struct s3c64xx_spi_driver_data *sdd;
> - struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev);
> + struct s3c64xx_spi_info *sci = dev_get_platdata(dev);
> struct spi_master *master;
> int ret, irq;
> char clk_name[16];
>
> - if (!sci && pdev->dev.of_node) {
> - sci = s3c64xx_spi_parse_dt(&pdev->dev);
> + if (!sci && dev->of_node) {
> + sci = s3c64xx_spi_parse_dt(dev);
> if (IS_ERR(sci))
> return PTR_ERR(sci);
> }
>
> if (!sci) {
> - dev_err(&pdev->dev, "platform_data missing!\n");
> + dev_err(dev, "platform_data missing!\n");
> return -ENODEV;
> }
>
> mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (mem_res == NULL) {
> - dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
> + dev_err(dev, "Unable to get SPI MEM resource\n");
> return -ENXIO;
> }
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0) {
> - dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
> + dev_warn(dev, "Failed to get IRQ: %d\n", irq);
> return irq;
> }
>
> - master = spi_alloc_master(&pdev->dev,
> - sizeof(struct s3c64xx_spi_driver_data));
> + master = spi_alloc_master(dev, sizeof(struct s3c64xx_spi_driver_data));
> if (master == NULL) {
> dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
> return -ENOMEM;
> @@ -1071,9 +1071,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> sdd->pdev = pdev;
> sdd->sfr_start = mem_res->start;
> if (pdev->dev.of_node) {
> - ret = of_alias_get_id(pdev->dev.of_node, "spi");
> + ret = of_alias_get_id(dev->of_node, "spi");
> if (ret < 0) {
> - dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
> + dev_err(dev, "failed to get alias id, errno %d\n",
> ret);
> goto err0;
> }
> @@ -1087,14 +1087,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> if (!sdd->pdev->dev.of_node) {
> res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> if (!res) {
> - dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
> + dev_warn(dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
> sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
> } else
> sdd->tx_dma.dmach = res->start;
>
> res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
> if (!res) {
> - dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
> + dev_warn(dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
> sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
> } else
> sdd->rx_dma.dmach = res->start;
> @@ -1103,7 +1103,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> sdd->tx_dma.direction = DMA_MEM_TO_DEV;
> sdd->rx_dma.direction = DMA_DEV_TO_MEM;
>
> - master->dev.of_node = pdev->dev.of_node;
> + master->dev.of_node = dev->of_node;
> master->bus_num = sdd->port_id;
> master->setup = s3c64xx_spi_setup;
> master->cleanup = s3c64xx_spi_cleanup;
> @@ -1121,43 +1121,43 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> if (!is_polling(sdd))
> master->can_dma = s3c64xx_spi_can_dma;
>
> - sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
> + sdd->regs = devm_ioremap_resource(dev, mem_res);
> if (IS_ERR(sdd->regs)) {
> ret = PTR_ERR(sdd->regs);
> goto err0;
> }
>
> if (sci->cfg_gpio && sci->cfg_gpio()) {
> - dev_err(&pdev->dev, "Unable to config gpio\n");
> + dev_err(dev, "Unable to config gpio\n");
> ret = -EBUSY;
> goto err0;
> }
>
> /* Setup clocks */
> - sdd->clk = devm_clk_get(&pdev->dev, "spi");
> + sdd->clk = devm_clk_get(dev, "spi");
> if (IS_ERR(sdd->clk)) {
> - dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
> + dev_err(dev, "Unable to acquire clock 'spi'\n");
> ret = PTR_ERR(sdd->clk);
> goto err0;
> }
>
> if (clk_prepare_enable(sdd->clk)) {
> - dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
> + dev_err(dev, "Couldn't enable clock 'spi'\n");
> ret = -EBUSY;
> goto err0;
> }
>
> sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
> - sdd->src_clk = devm_clk_get(&pdev->dev, clk_name);
> + sdd->src_clk = devm_clk_get(dev, clk_name);
> if (IS_ERR(sdd->src_clk)) {
> - dev_err(&pdev->dev,
> + dev_err(dev,
> "Unable to acquire clock '%s'\n", clk_name);
> ret = PTR_ERR(sdd->src_clk);
> goto err2;
> }
>
> if (clk_prepare_enable(sdd->src_clk)) {
> - dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name);
> + dev_err(dev, "Couldn't enable clock '%s'\n", clk_name);
> ret = -EBUSY;
> goto err2;
> }
> @@ -1168,10 +1168,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> spin_lock_init(&sdd->lock);
> init_completion(&sdd->xfer_completion);
>
> - ret = devm_request_irq(&pdev->dev, irq, s3c64xx_spi_irq, 0,
> + ret = devm_request_irq(dev, irq, s3c64xx_spi_irq, 0,
> "spi-s3c64xx", sdd);
> if (ret != 0) {
> - dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n",
> + dev_err(dev, "Failed to request IRQ %d: %d\n",
> irq, ret);
> goto err3;
> }
> @@ -1180,18 +1180,18 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
> S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN,
> sdd->regs + S3C64XX_SPI_INT_EN);
>
> - pm_runtime_set_active(&pdev->dev);
> - pm_runtime_enable(&pdev->dev);
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
>
> - ret = devm_spi_register_master(&pdev->dev, master);
> + ret = devm_spi_register_master(dev, master);
> if (ret != 0) {
> - dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret);
> + dev_err(dev, "cannot register SPI master: %d\n", ret);
> goto err3;
> }
>
> - dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
> + dev_dbg(dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
> sdd->port_id, master->num_chipselect);
> - dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
> + dev_dbg(dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
> mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
> sdd->rx_dma.dmach, sdd->tx_dma.dmach);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/3] spi: s3c64xx: simplify probe function by using local variable for &pdev->dev
[not found] ` <55D3C618.1000305-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2015-08-19 5:18 ` Heiner Kallweit
0 siblings, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2015-08-19 5:18 UTC (permalink / raw)
To: Krzysztof Kozlowski, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Am 19.08.2015 um 01:56 schrieb Krzysztof Kozlowski:
> On 19.08.2015 06:05, Heiner Kallweit wrote:
>> Simplify the probe function by replacing all occurrences of &pdev->dev
>> with a local variable.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>> drivers/spi/spi-s3c64xx.c | 58 +++++++++++++++++++++++------------------------
>> 1 file changed, 29 insertions(+), 29 deletions(-)
>
> I don't see simplification here (the same number of insertions as
> deletions, code is exactly the same). &pdev->dev is a common pattern in
> most of platform drivers.
Right, &pdev->dev is a common pattern. I consider the new version better as we
really have a lot of occurrences of &pdev->dev. It reduces complexity in several lines
and might save a few CPU cycles in case the compiler can't hold &pdev->dev in a register
all the time.
Of course your mileage might vary. If you think it's good as it is I'm also fine with it.
Rgds, Heiner
>
> Best regards,
> Krzysztof
>
>
>>
>> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
>> index cd1cfac..c4d3b06 100644
>> --- a/drivers/spi/spi-s3c64xx.c
>> +++ b/drivers/spi/spi-s3c64xx.c
>> @@ -1024,39 +1024,39 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
>>
>> static int s3c64xx_spi_probe(struct platform_device *pdev)
>> {
>> + struct device *dev = &pdev->dev;
>> struct resource *mem_res;
>> struct resource *res;
>> struct s3c64xx_spi_driver_data *sdd;
>> - struct s3c64xx_spi_info *sci = dev_get_platdata(&pdev->dev);
>> + struct s3c64xx_spi_info *sci = dev_get_platdata(dev);
>> struct spi_master *master;
>> int ret, irq;
>> char clk_name[16];
>>
>> - if (!sci && pdev->dev.of_node) {
>> - sci = s3c64xx_spi_parse_dt(&pdev->dev);
>> + if (!sci && dev->of_node) {
>> + sci = s3c64xx_spi_parse_dt(dev);
>> if (IS_ERR(sci))
>> return PTR_ERR(sci);
>> }
>>
>> if (!sci) {
>> - dev_err(&pdev->dev, "platform_data missing!\n");
>> + dev_err(dev, "platform_data missing!\n");
>> return -ENODEV;
>> }
>>
>> mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> if (mem_res == NULL) {
>> - dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
>> + dev_err(dev, "Unable to get SPI MEM resource\n");
>> return -ENXIO;
>> }
>>
>> irq = platform_get_irq(pdev, 0);
>> if (irq < 0) {
>> - dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
>> + dev_warn(dev, "Failed to get IRQ: %d\n", irq);
>> return irq;
>> }
>>
>> - master = spi_alloc_master(&pdev->dev,
>> - sizeof(struct s3c64xx_spi_driver_data));
>> + master = spi_alloc_master(dev, sizeof(struct s3c64xx_spi_driver_data));
>> if (master == NULL) {
>> dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
>> return -ENOMEM;
>> @@ -1071,9 +1071,9 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> sdd->pdev = pdev;
>> sdd->sfr_start = mem_res->start;
>> if (pdev->dev.of_node) {
>> - ret = of_alias_get_id(pdev->dev.of_node, "spi");
>> + ret = of_alias_get_id(dev->of_node, "spi");
>> if (ret < 0) {
>> - dev_err(&pdev->dev, "failed to get alias id, errno %d\n",
>> + dev_err(dev, "failed to get alias id, errno %d\n",
>> ret);
>> goto err0;
>> }
>> @@ -1087,14 +1087,14 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> if (!sdd->pdev->dev.of_node) {
>> res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
>> if (!res) {
>> - dev_warn(&pdev->dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
>> + dev_warn(dev, "Unable to get SPI tx dma resource. Switching to poll mode\n");
>> sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
>> } else
>> sdd->tx_dma.dmach = res->start;
>>
>> res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
>> if (!res) {
>> - dev_warn(&pdev->dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
>> + dev_warn(dev, "Unable to get SPI rx dma resource. Switching to poll mode\n");
>> sdd->port_conf->quirks = S3C64XX_SPI_QUIRK_POLL;
>> } else
>> sdd->rx_dma.dmach = res->start;
>> @@ -1103,7 +1103,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> sdd->tx_dma.direction = DMA_MEM_TO_DEV;
>> sdd->rx_dma.direction = DMA_DEV_TO_MEM;
>>
>> - master->dev.of_node = pdev->dev.of_node;
>> + master->dev.of_node = dev->of_node;
>> master->bus_num = sdd->port_id;
>> master->setup = s3c64xx_spi_setup;
>> master->cleanup = s3c64xx_spi_cleanup;
>> @@ -1121,43 +1121,43 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> if (!is_polling(sdd))
>> master->can_dma = s3c64xx_spi_can_dma;
>>
>> - sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
>> + sdd->regs = devm_ioremap_resource(dev, mem_res);
>> if (IS_ERR(sdd->regs)) {
>> ret = PTR_ERR(sdd->regs);
>> goto err0;
>> }
>>
>> if (sci->cfg_gpio && sci->cfg_gpio()) {
>> - dev_err(&pdev->dev, "Unable to config gpio\n");
>> + dev_err(dev, "Unable to config gpio\n");
>> ret = -EBUSY;
>> goto err0;
>> }
>>
>> /* Setup clocks */
>> - sdd->clk = devm_clk_get(&pdev->dev, "spi");
>> + sdd->clk = devm_clk_get(dev, "spi");
>> if (IS_ERR(sdd->clk)) {
>> - dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
>> + dev_err(dev, "Unable to acquire clock 'spi'\n");
>> ret = PTR_ERR(sdd->clk);
>> goto err0;
>> }
>>
>> if (clk_prepare_enable(sdd->clk)) {
>> - dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
>> + dev_err(dev, "Couldn't enable clock 'spi'\n");
>> ret = -EBUSY;
>> goto err0;
>> }
>>
>> sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
>> - sdd->src_clk = devm_clk_get(&pdev->dev, clk_name);
>> + sdd->src_clk = devm_clk_get(dev, clk_name);
>> if (IS_ERR(sdd->src_clk)) {
>> - dev_err(&pdev->dev,
>> + dev_err(dev,
>> "Unable to acquire clock '%s'\n", clk_name);
>> ret = PTR_ERR(sdd->src_clk);
>> goto err2;
>> }
>>
>> if (clk_prepare_enable(sdd->src_clk)) {
>> - dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name);
>> + dev_err(dev, "Couldn't enable clock '%s'\n", clk_name);
>> ret = -EBUSY;
>> goto err2;
>> }
>> @@ -1168,10 +1168,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> spin_lock_init(&sdd->lock);
>> init_completion(&sdd->xfer_completion);
>>
>> - ret = devm_request_irq(&pdev->dev, irq, s3c64xx_spi_irq, 0,
>> + ret = devm_request_irq(dev, irq, s3c64xx_spi_irq, 0,
>> "spi-s3c64xx", sdd);
>> if (ret != 0) {
>> - dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n",
>> + dev_err(dev, "Failed to request IRQ %d: %d\n",
>> irq, ret);
>> goto err3;
>> }
>> @@ -1180,18 +1180,18 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>> S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN,
>> sdd->regs + S3C64XX_SPI_INT_EN);
>>
>> - pm_runtime_set_active(&pdev->dev);
>> - pm_runtime_enable(&pdev->dev);
>> + pm_runtime_set_active(dev);
>> + pm_runtime_enable(dev);
>>
>> - ret = devm_spi_register_master(&pdev->dev, master);
>> + ret = devm_spi_register_master(dev, master);
>> if (ret != 0) {
>> - dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret);
>> + dev_err(dev, "cannot register SPI master: %d\n", ret);
>> goto err3;
>> }
>>
>> - dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
>> + dev_dbg(dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n",
>> sdd->port_id, master->num_chipselect);
>> - dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
>> + dev_dbg(dev, "\tIOmem=[%pR]\tFIFO %dbytes\tDMA=[Rx-%d, Tx-%d]\n",
>> mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1,
>> sdd->rx_dma.dmach, sdd->tx_dma.dmach);
>>
>>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-19 5:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18 21:05 [PATCH 1/3] spi: s3c64xx: simplify probe function by using local variable for &pdev->dev Heiner Kallweit
2015-08-18 23:56 ` Krzysztof Kozlowski
[not found] ` <55D3C618.1000305-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-08-19 5:18 ` Heiner Kallweit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).