diff mbox series

[v6,36/40] ata: pata_ep93xx: remove legacy pinctrl use

Message ID 20231212-ep93xx-v6-36-c307b8ac9aa8@maquefel.me
State New
Headers show
Series ep93xx device tree conversion | expand

Commit Message

Nikita Shubin via B4 Relay Dec. 12, 2023, 8:20 a.m. UTC
From: Nikita Shubin <nikita.shubin@maquefel.me>

Drop legacy acquire/release since we are using pinctrl for this now.

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
 arch/arm/mach-ep93xx/core.c       | 72 ---------------------------------------
 drivers/ata/pata_ep93xx.c         | 29 +++++-----------
 include/linux/soc/cirrus/ep93xx.h |  4 ---
 3 files changed, 8 insertions(+), 97 deletions(-)

Comments

Andy Shevchenko Dec. 13, 2023, 6:16 p.m. UTC | #1
On Tue, Dec 12, 2023 at 11:20:53AM +0300, Nikita Shubin wrote:
> Drop legacy acquire/release since we are using pinctrl for this now.

...

> -	if (IS_ERR(drv_data->dma_rx_channel)) {
> +	if (PTR_ERR_OR_ZERO(drv_data->dma_rx_channel)) {

This seems incorrect.

>  		ret = PTR_ERR(drv_data->dma_rx_channel);
>  		return dev_err_probe(dev, ret, "rx DMA setup failed");

		return dev_err_probe(...);

>  	}

I think you wanted

	ret = PTR_ERR_OR_ZERO(drv_data->dma_rx_channel);
	if (ret)
		return dev_err_probe(dev, ret, "rx DMA setup failed");

...

>  	drv_data->dma_tx_channel = dma_request_chan(&pdev->dev, "tx");
> -	if (IS_ERR(drv_data->dma_tx_channel)) {
> +	if (PTR_ERR_OR_ZERO(drv_data->dma_tx_channel)) {
>  		ret = PTR_ERR(drv_data->dma_tx_channel);
>  		dev_err_probe(dev, ret, "tx DMA setup failed");
>  		goto fail_release_rx;

Ditto.
Uwe Kleine-König Dec. 13, 2023, 6:33 p.m. UTC | #2
On Wed, Dec 13, 2023 at 08:16:26PM +0200, Andy Shevchenko wrote:
> On Tue, Dec 12, 2023 at 11:20:53AM +0300, Nikita Shubin wrote:
> > Drop legacy acquire/release since we are using pinctrl for this now.
> 
> ...
> 
> > -	if (IS_ERR(drv_data->dma_rx_channel)) {
> > +	if (PTR_ERR_OR_ZERO(drv_data->dma_rx_channel)) {
> 
> This seems incorrect.
> 
> >  		ret = PTR_ERR(drv_data->dma_rx_channel);
> >  		return dev_err_probe(dev, ret, "rx DMA setup failed");
> 
> 		return dev_err_probe(...);
> 
> >  	}
> 
> I think you wanted
> 
> 	ret = PTR_ERR_OR_ZERO(drv_data->dma_rx_channel);
> 	if (ret)
> 		return dev_err_probe(dev, ret, "rx DMA setup failed");

How is that different from

	if (IS_ERR(drv_data->dma_rx_channel))
		return dev_err_probe(dev, PTR_ERR(drv_data->dma_rx_channel), "....");

(which seems to be more idiomatic to me)? While I was involved in
creating PTR_ERR_OR_ZERO, I don't particularily like it (today).

Also note that you want a \n at the end of error messages.

Best regards
Uwe
Andy Shevchenko Dec. 13, 2023, 6:48 p.m. UTC | #3
On Wed, Dec 13, 2023 at 07:33:49PM +0100, Uwe Kleine-König wrote:
> On Wed, Dec 13, 2023 at 08:16:26PM +0200, Andy Shevchenko wrote:
> > On Tue, Dec 12, 2023 at 11:20:53AM +0300, Nikita Shubin wrote:
> > > Drop legacy acquire/release since we are using pinctrl for this now.

...

> > > -	if (IS_ERR(drv_data->dma_rx_channel)) {
> > > +	if (PTR_ERR_OR_ZERO(drv_data->dma_rx_channel)) {
> > 
> > This seems incorrect.
> > 
> > >  		ret = PTR_ERR(drv_data->dma_rx_channel);
> > >  		return dev_err_probe(dev, ret, "rx DMA setup failed");
> > 
> > 		return dev_err_probe(...);
> > 
> > >  	}
> > 
> > I think you wanted
> > 
> > 	ret = PTR_ERR_OR_ZERO(drv_data->dma_rx_channel);
> > 	if (ret)
> > 		return dev_err_probe(dev, ret, "rx DMA setup failed");
> 
> How is that different from
> 
> 	if (IS_ERR(drv_data->dma_rx_channel))
> 		return dev_err_probe(dev, PTR_ERR(drv_data->dma_rx_channel), "....");
> 
> (which seems to be more idiomatic to me)? While I was involved in
> creating PTR_ERR_OR_ZERO, I don't particularily like it (today).

Makes lines shorter, either works for me.

> Also note that you want a \n at the end of error messages.

Indeed.
Uwe Kleine-König Dec. 14, 2023, 10:26 a.m. UTC | #4
On Wed, Dec 13, 2023 at 08:48:55PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 13, 2023 at 07:33:49PM +0100, Uwe Kleine-König wrote:
> > On Wed, Dec 13, 2023 at 08:16:26PM +0200, Andy Shevchenko wrote:
> > > On Tue, Dec 12, 2023 at 11:20:53AM +0300, Nikita Shubin wrote:
> > > > Drop legacy acquire/release since we are using pinctrl for this now.
> 
> ...
> 
> > > I think you wanted
> > > 
> > > 	ret = PTR_ERR_OR_ZERO(drv_data->dma_rx_channel);
> > > 	if (ret)
> > > 		return dev_err_probe(dev, ret, "rx DMA setup failed");
> > 
> > How is that different from
> > 
> > 	if (IS_ERR(drv_data->dma_rx_channel))
> > 		return dev_err_probe(dev, PTR_ERR(drv_data->dma_rx_channel), "....");
> > 
> > (which seems to be more idiomatic to me)? While I was involved in
> > creating PTR_ERR_OR_ZERO, I don't particularily like it (today).
> 
> Makes lines shorter, either works for me.

If you want shorter lines, I'd prefer

	if (IS_ERR(drv_data->dma_rx_channel)) {
		ret = PTR_ERR(drv_data->dma_rx_channel);
		return dev_err_probe(dev, ret, "...\n");
	}

over
	ret = PTR_ERR_OR_ZERO(drv_data->dma_rx_channel);
	if (ret)
		return dev_err_probe(dev, ret, "\n");

even though it's one line longer because the if body needs curly braces.
I think it's easier to parse for a human which IMHO matters more than
the additional line. But I'm aware that might be subjective.

Best regards
Uwe
diff mbox series

Patch

diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 4ddf1a4cba33..9c6154bb37b5 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -779,78 +779,6 @@  void __init ep93xx_register_ide(void)
 	platform_device_register(&ep93xx_ide_device);
 }
 
-int ep93xx_ide_acquire_gpio(struct platform_device *pdev)
-{
-	int err;
-	int i;
-
-	err = gpio_request(EP93XX_GPIO_LINE_EGPIO2, dev_name(&pdev->dev));
-	if (err)
-		return err;
-	err = gpio_request(EP93XX_GPIO_LINE_EGPIO15, dev_name(&pdev->dev));
-	if (err)
-		goto fail_egpio15;
-	for (i = 2; i < 8; i++) {
-		err = gpio_request(EP93XX_GPIO_LINE_E(i), dev_name(&pdev->dev));
-		if (err)
-			goto fail_gpio_e;
-	}
-	for (i = 4; i < 8; i++) {
-		err = gpio_request(EP93XX_GPIO_LINE_G(i), dev_name(&pdev->dev));
-		if (err)
-			goto fail_gpio_g;
-	}
-	for (i = 0; i < 8; i++) {
-		err = gpio_request(EP93XX_GPIO_LINE_H(i), dev_name(&pdev->dev));
-		if (err)
-			goto fail_gpio_h;
-	}
-
-	/* GPIO ports E[7:2], G[7:4] and H used by IDE */
-	ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
-				 EP93XX_SYSCON_DEVCFG_GONIDE |
-				 EP93XX_SYSCON_DEVCFG_HONIDE);
-	return 0;
-
-fail_gpio_h:
-	for (--i; i >= 0; --i)
-		gpio_free(EP93XX_GPIO_LINE_H(i));
-	i = 8;
-fail_gpio_g:
-	for (--i; i >= 4; --i)
-		gpio_free(EP93XX_GPIO_LINE_G(i));
-	i = 8;
-fail_gpio_e:
-	for (--i; i >= 2; --i)
-		gpio_free(EP93XX_GPIO_LINE_E(i));
-	gpio_free(EP93XX_GPIO_LINE_EGPIO15);
-fail_egpio15:
-	gpio_free(EP93XX_GPIO_LINE_EGPIO2);
-	return err;
-}
-EXPORT_SYMBOL(ep93xx_ide_acquire_gpio);
-
-void ep93xx_ide_release_gpio(struct platform_device *pdev)
-{
-	int i;
-
-	for (i = 2; i < 8; i++)
-		gpio_free(EP93XX_GPIO_LINE_E(i));
-	for (i = 4; i < 8; i++)
-		gpio_free(EP93XX_GPIO_LINE_G(i));
-	for (i = 0; i < 8; i++)
-		gpio_free(EP93XX_GPIO_LINE_H(i));
-	gpio_free(EP93XX_GPIO_LINE_EGPIO15);
-	gpio_free(EP93XX_GPIO_LINE_EGPIO2);
-
-
-	/* GPIO ports E[7:2], G[7:4] and H used by GPIO */
-	ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
-			       EP93XX_SYSCON_DEVCFG_GONIDE |
-			       EP93XX_SYSCON_DEVCFG_HONIDE);
-}
-EXPORT_SYMBOL(ep93xx_ide_release_gpio);
-
 /*************************************************************************
  * EP93xx ADC
  *************************************************************************/
diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
index 3f33916c2d23..83c2a0162cb0 100644
--- a/drivers/ata/pata_ep93xx.c
+++ b/drivers/ata/pata_ep93xx.c
@@ -652,13 +652,13 @@  static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data)
 	 * start of new transfer.
 	 */
 	drv_data->dma_rx_channel = dma_request_chan(dev, "rx");
-	if (IS_ERR(drv_data->dma_rx_channel)) {
+	if (PTR_ERR_OR_ZERO(drv_data->dma_rx_channel)) {
 		ret = PTR_ERR(drv_data->dma_rx_channel);
 		return dev_err_probe(dev, ret, "rx DMA setup failed");
 	}
 
 	drv_data->dma_tx_channel = dma_request_chan(&pdev->dev, "tx");
-	if (IS_ERR(drv_data->dma_tx_channel)) {
+	if (PTR_ERR_OR_ZERO(drv_data->dma_tx_channel)) {
 		ret = PTR_ERR(drv_data->dma_tx_channel);
 		dev_err_probe(dev, ret, "tx DMA setup failed");
 		goto fail_release_rx;
@@ -923,28 +923,18 @@  static int ep93xx_pata_probe(struct platform_device *pdev)
 	void __iomem *ide_base;
 	int err;
 
-	err = ep93xx_ide_acquire_gpio(pdev);
-	if (err)
-		return err;
-
 	/* INT[3] (IRQ_EP93XX_EXT3) line connected as pull down */
 	irq = platform_get_irq(pdev, 0);
-	if (irq < 0) {
-		err = irq;
-		goto err_rel_gpio;
-	}
+	if (irq < 0)
+		return irq;
 
 	ide_base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem_res);
-	if (IS_ERR(ide_base)) {
-		err = PTR_ERR(ide_base);
-		goto err_rel_gpio;
-	}
+	if (IS_ERR(ide_base))
+		return PTR_ERR(ide_base);
 
 	drv_data = devm_kzalloc(&pdev->dev, sizeof(*drv_data), GFP_KERNEL);
-	if (!drv_data) {
-		err = -ENOMEM;
-		goto err_rel_gpio;
-	}
+	if (!drv_data)
+		return -ENOMEM;
 
 	drv_data->pdev = pdev;
 	drv_data->ide_base = ide_base;
@@ -1003,8 +993,6 @@  static int ep93xx_pata_probe(struct platform_device *pdev)
 
 err_rel_dma:
 	ep93xx_pata_release_dma(drv_data);
-err_rel_gpio:
-	ep93xx_ide_release_gpio(pdev);
 	return err;
 }
 
@@ -1016,7 +1004,6 @@  static void ep93xx_pata_remove(struct platform_device *pdev)
 	ata_host_detach(host);
 	ep93xx_pata_release_dma(drv_data);
 	ep93xx_pata_clear_regs(drv_data->ide_base);
-	ep93xx_ide_release_gpio(pdev);
 }
 
 static const struct of_device_id ep93xx_pata_of_ids[] = {
diff --git a/include/linux/soc/cirrus/ep93xx.h b/include/linux/soc/cirrus/ep93xx.h
index fc4a2f9d4729..da8bdfc36526 100644
--- a/include/linux/soc/cirrus/ep93xx.h
+++ b/include/linux/soc/cirrus/ep93xx.h
@@ -37,15 +37,11 @@  struct ep93xx_regmap_adev {
 	container_of((_adev), struct ep93xx_regmap_adev, adev)
 
 #ifdef CONFIG_ARCH_EP93XX
-int ep93xx_ide_acquire_gpio(struct platform_device *pdev);
-void ep93xx_ide_release_gpio(struct platform_device *pdev);
 int ep93xx_i2s_acquire(void);
 void ep93xx_i2s_release(void);
 unsigned int ep93xx_chip_revision(void);
 
 #else
-static inline int ep93xx_ide_acquire_gpio(struct platform_device *pdev) { return 0; }
-static inline void ep93xx_ide_release_gpio(struct platform_device *pdev) {}
 static inline int ep93xx_i2s_acquire(void) { return 0; }
 static inline void ep93xx_i2s_release(void) {}
 static inline unsigned int ep93xx_chip_revision(void) { return 0; }