From 072de836f53be56a70cecf70b43ae43b7ce17376 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 10:08:36 +0000
Subject: [PATCH] mk-rootfs.sh

---
 kernel/drivers/ata/pata_rb532_cf.c |   54 ++++++++++++------------------------------------------
 1 files changed, 12 insertions(+), 42 deletions(-)

diff --git a/kernel/drivers/ata/pata_rb532_cf.c b/kernel/drivers/ata/pata_rb532_cf.c
index 0416a39..303f8c3 100644
--- a/kernel/drivers/ata/pata_rb532_cf.c
+++ b/kernel/drivers/ata/pata_rb532_cf.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  *  A low-level PATA driver to handle a Compact Flash connected on the
  *  Mikrotik's RouterBoard 532 board.
@@ -12,11 +13,6 @@
  *  Also was based on the driver for Linux 2.4.xx published by Mikrotik for
  *  their RouterBoard 1xx and 5xx series devices. The original Mikrotik code
  *  seems not to have a license.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
  */
 
 #include <linux/gfp.h>
@@ -27,7 +23,7 @@
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 
 #include <linux/libata.h>
 #include <scsi/scsi_host.h>
@@ -49,7 +45,7 @@
 
 struct rb532_cf_info {
 	void __iomem	*iobase;
-	unsigned int	gpio_line;
+	struct gpio_desc *gpio_line;
 	unsigned int	irq;
 };
 
@@ -60,7 +56,7 @@
 	struct ata_host *ah = dev_instance;
 	struct rb532_cf_info *info = ah->private_data;
 
-	if (gpio_get_value(info->gpio_line)) {
+	if (gpiod_get_value(info->gpio_line)) {
 		irq_set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
 		ata_sff_interrupt(info->irq, dev_instance);
 	} else {
@@ -106,10 +102,9 @@
 static int rb532_pata_driver_probe(struct platform_device *pdev)
 {
 	int irq;
-	int gpio;
+	struct gpio_desc *gpiod;
 	struct resource *res;
 	struct ata_host *ah;
-	struct cf_device *pdata;
 	struct rb532_cf_info *info;
 	int ret;
 
@@ -127,23 +122,12 @@
 	if (!irq)
 		return -EINVAL;
 
-	pdata = dev_get_platdata(&pdev->dev);
-	if (!pdata) {
-		dev_err(&pdev->dev, "no platform data specified\n");
-		return -EINVAL;
-	}
-
-	gpio = pdata->gpio_pin;
-	if (gpio < 0) {
+	gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);
+	if (IS_ERR(gpiod)) {
 		dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
-		return -ENOENT;
+		return PTR_ERR(gpiod);
 	}
-
-	ret = gpio_request(gpio, DRV_NAME);
-	if (ret) {
-		dev_err(&pdev->dev, "GPIO request failed\n");
-		return ret;
-	}
+	gpiod_set_consumer_name(gpiod, DRV_NAME);
 
 	/* allocate host */
 	ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS);
@@ -155,43 +139,29 @@
 		return -ENOMEM;
 
 	ah->private_data = info;
-	info->gpio_line = gpio;
+	info->gpio_line = gpiod;
 	info->irq = irq;
 
-	info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
+	info->iobase = devm_ioremap(&pdev->dev, res->start,
 				resource_size(res));
 	if (!info->iobase)
 		return -ENOMEM;
-
-	ret = gpio_direction_input(gpio);
-	if (ret) {
-		dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n",
-				ret);
-		goto err_free_gpio;
-	}
 
 	rb532_pata_setup_ports(ah);
 
 	ret = ata_host_activate(ah, irq, rb532_pata_irq_handler,
 				IRQF_TRIGGER_LOW, &rb532_pata_sht);
 	if (ret)
-		goto err_free_gpio;
+		return ret;
 
 	return 0;
-
-err_free_gpio:
-	gpio_free(gpio);
-
-	return ret;
 }
 
 static int rb532_pata_driver_remove(struct platform_device *pdev)
 {
 	struct ata_host *ah = platform_get_drvdata(pdev);
-	struct rb532_cf_info *info = ah->private_data;
 
 	ata_host_detach(ah);
-	gpio_free(info->gpio_line);
 
 	return 0;
 }

--
Gitblit v1.6.2