]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/gpio/gpio-stp-xway.c
Merge tag 'for-5.4-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
[linux.git] / drivers / gpio / gpio-stp-xway.c
index 24c4783923942e9836880cefcccfe23033c4874f..9e23a5ae8108ce51a59490483ec2a258dc20e987 100644 (file)
@@ -15,8 +15,6 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 
-#include <lantiq_soc.h>
-
 /*
  * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a
  * peripheral controller used to drive external shift register cascades. At most
@@ -71,8 +69,7 @@
 #define xway_stp_r32(m, reg)           __raw_readl(m + reg)
 #define xway_stp_w32(m, val, reg)      __raw_writel(val, m + reg)
 #define xway_stp_w32_mask(m, clear, set, reg) \
-               ltq_w32((ltq_r32(m + reg) & ~(clear)) | (set), \
-               m + reg)
+               xway_stp_w32(m, (xway_stp_r32(m, reg) & ~(clear)) | (set), reg)
 
 struct xway_stp {
        struct gpio_chip gc;
@@ -156,9 +153,9 @@ static int xway_stp_request(struct gpio_chip *gc, unsigned gpio)
 
 /**
  * xway_stp_hw_init() - Configure the STP unit and enable the clock gate
- * @virt: pointer to the remapped register range
+ * @chip: Pointer to the xway_stp chip structure
  */
-static int xway_stp_hw_init(struct xway_stp *chip)
+static void xway_stp_hw_init(struct xway_stp *chip)
 {
        /* sane defaults */
        xway_stp_w32(chip->virt, 0, XWAY_STP_AR);
@@ -201,8 +198,6 @@ static int xway_stp_hw_init(struct xway_stp *chip)
        if (chip->reserved)
                xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK,
                        XWAY_STP_UPD_FPI, XWAY_STP_CON1);
-
-       return 0;
 }
 
 static int xway_stp_probe(struct platform_device *pdev)
@@ -258,21 +253,27 @@ static int xway_stp_probe(struct platform_device *pdev)
        if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
                chip->edge = XWAY_STP_FALLING;
 
-       clk = clk_get(&pdev->dev, NULL);
+       clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "Failed to get clock\n");
                return PTR_ERR(clk);
        }
-       clk_enable(clk);
 
-       ret = xway_stp_hw_init(chip);
-       if (!ret)
-               ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
+       ret = clk_prepare_enable(clk);
+       if (ret)
+               return ret;
 
-       if (!ret)
-               dev_info(&pdev->dev, "Init done\n");
+       xway_stp_hw_init(chip);
 
-       return ret;
+       ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
+       if (ret) {
+               clk_disable_unprepare(clk);
+               return ret;
+       }
+
+       dev_info(&pdev->dev, "Init done\n");
+
+       return 0;
 }
 
 static const struct of_device_id xway_stp_match[] = {