Input: bfin_rotary - move pin lists into into platform data
authorSonic Zhang <sonic.zhang@analog.com>
Fri, 6 Feb 2015 05:23:10 +0000 (21:23 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 16 Feb 2015 00:06:27 +0000 (16:06 -0800)
Newer Blackfin boards use pinctrl API to manage pins and the legacy
peripherial lists are not useful on them. Let's move pin lists into
platform data so older boards can still use them and newer boards can use
the modern API.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
arch/blackfin/mach-bf527/boards/ad7160eval.c
arch/blackfin/mach-bf527/boards/ezkit.c
drivers/input/misc/bfin_rotary.c
include/linux/platform_data/bfin_rotary.h

index beb011b6d2b3b014b69a5f8f763214c404afb404..029a0506b66992a92c1ac9e10073b72c1d1f5436 100644 (file)
@@ -668,6 +668,13 @@ static struct platform_device bfin_sport1_uart_device = {
 #if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
 #include <linux/platform_data/bfin_rotary.h>
 
+static const u16 per_cnt[] = {
+       P_CNT_CUD,
+       P_CNT_CDG,
+       P_CNT_CZM,
+       0
+};
+
 static struct bfin_rotary_platform_data bfin_rotary_data = {
        /*.rotary_up_key     = KEY_UP,*/
        /*.rotary_down_key   = KEY_DOWN,*/
@@ -676,6 +683,7 @@ static struct bfin_rotary_platform_data bfin_rotary_data = {
        .debounce          = 10,        /* 0..17 */
        .mode              = ROT_QUAD_ENC | ROT_DEBE,
        .pm_wakeup         = 1,
+       .pin_list          = per_cnt,
 };
 
 static struct resource bfin_rotary_resources[] = {
index 728cda46995261a1aa250ccd836cd0a368a7443e..cc80c5ba9f6793b28d50779c7b0ac0868a1d98a2 100644 (file)
@@ -1094,6 +1094,13 @@ static struct platform_device bfin_device_gpiokeys = {
 #if IS_ENABLED(CONFIG_INPUT_BFIN_ROTARY)
 #include <linux/platform_data/bfin_rotary.h>
 
+static const u16 per_cnt[] = {
+       P_CNT_CUD,
+       P_CNT_CDG,
+       P_CNT_CZM,
+       0
+};
+
 static struct bfin_rotary_platform_data bfin_rotary_data = {
        /*.rotary_up_key     = KEY_UP,*/
        /*.rotary_down_key   = KEY_DOWN,*/
@@ -1102,6 +1109,7 @@ static struct bfin_rotary_platform_data bfin_rotary_data = {
        .debounce          = 10,        /* 0..17 */
        .mode              = ROT_QUAD_ENC | ROT_DEBE,
        .pm_wakeup         = 1,
+       .pin_list          = per_cnt,
 };
 
 static struct resource bfin_rotary_resources[] = {
index 35ead69521a09a421ce42f5a499190d7b0c0d27d..8312b29ab18d628ae9caeda8b2f9c50aed129b2e 100644 (file)
 
 #include <asm/portmux.h>
 
-static const u16 per_cnt[] = {
-       P_CNT_CUD,
-       P_CNT_CDG,
-       P_CNT_CZM,
-       0
-};
-
 struct bfin_rot {
        struct input_dev *input;
        int irq;
@@ -90,7 +83,8 @@ static irqreturn_t bfin_rotary_isr(int irq, void *dev_id)
 
 static int bfin_rotary_probe(struct platform_device *pdev)
 {
-       struct bfin_rotary_platform_data *pdata = dev_get_platdata(&pdev->dev);
+       const struct bfin_rotary_platform_data *pdata =
+                                       dev_get_platdata(&pdev->dev);
        struct bfin_rot *rotary;
        struct input_dev *input;
        int error;
@@ -101,10 +95,13 @@ static int bfin_rotary_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       error = peripheral_request_list(per_cnt, dev_name(&pdev->dev));
-       if (error) {
-               dev_err(&pdev->dev, "requesting peripherals failed\n");
-               return error;
+       if (pdata->pin_list) {
+               error = peripheral_request_list(pdata->pin_list,
+                                               dev_name(&pdev->dev));
+               if (error) {
+                       dev_err(&pdev->dev, "requesting peripherals failed\n");
+                       return error;
+               }
        }
 
        rotary = kzalloc(sizeof(struct bfin_rot), GFP_KERNEL);
@@ -189,13 +186,16 @@ out2:
 out1:
        input_free_device(input);
        kfree(rotary);
-       peripheral_free_list(per_cnt);
+       if (pdata->pin_list)
+               peripheral_free_list(pdata->pin_list);
 
        return error;
 }
 
 static int bfin_rotary_remove(struct platform_device *pdev)
 {
+       const struct bfin_rotary_platform_data *pdata =
+                                       dev_get_platdata(&pdev->dev);
        struct bfin_rot *rotary = platform_get_drvdata(pdev);
 
        bfin_write_CNT_CONFIG(0);
@@ -203,7 +203,9 @@ static int bfin_rotary_remove(struct platform_device *pdev)
 
        free_irq(rotary->irq, rotary);
        input_unregister_device(rotary->input);
-       peripheral_free_list(per_cnt);
+
+       if (pdata->pin_list)
+               peripheral_free_list(pdata->pin_list);
 
        kfree(rotary);
 
index 8895a750c70c6511c29507c7f6532b30aff3479d..98829370fee28a4d92e88daaac3de852d8555419 100644 (file)
@@ -40,6 +40,7 @@ struct bfin_rotary_platform_data {
        unsigned short debounce;        /* 0..17 */
        unsigned short mode;
        unsigned short pm_wakeup;
+       unsigned short *pin_list;
 };
 
 /* CNT_CONFIG bitmasks */