]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: ams_delta_serio: Get FIQ buffer from platform_data
authorJanusz Krzysztofik <jmkrzyszt@gmail.com>
Thu, 21 Jun 2018 22:41:28 +0000 (00:41 +0200)
committerTony Lindgren <tony@atomide.com>
Tue, 3 Jul 2018 06:05:14 +0000 (23:05 -0700)
Instead of exporting the FIQ buffer symbol to be used in
ams-delta-serio driver, pass it to the driver as platform_data.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap1/ams-delta-fiq.c
arch/arm/mach-omap1/board-ams-delta.c
drivers/input/serio/ams_delta_serio.c
include/linux/platform_data/ams-delta-fiq.h

index 82ca4246a5e444650574a1d6046c4126973e7f94..b0dc7ddf5877d70eeda21df28b331acdf99a4cdb 100644 (file)
@@ -40,8 +40,7 @@ static struct fiq_handler fh = {
  * keystrokes received from the qwerty keyboard.  See
  * <linux/platform_data/ams-delta-fiq.h> for details of offsets.
  */
-unsigned int fiq_buffer[1024];
-EXPORT_SYMBOL(fiq_buffer);
+static unsigned int fiq_buffer[1024];
 
 static struct irq_chip *irq_chip;
 static struct irq_data *irq_data[16];
@@ -203,9 +202,10 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip,
        val = omap_readl(OMAP_IH1_BASE + offset) | 1;
        omap_writel(val, OMAP_IH1_BASE + offset);
 
-       /* Initialize serio device IRQ resource */
+       /* Initialize serio device IRQ resource and platform_data */
        serio->resource[0].start = gpiod_to_irq(clk);
        serio->resource[0].end = serio->resource[0].start;
+       serio->dev.platform_data = fiq_buffer;
 
        /*
         * Since FIQ handler performs handling of GPIO registers for
index f453b08ed7ef78143d3748307fb06cf33442eb5f..22f9be297c2a8c634735665b4b0be38a931af0af 100644 (file)
@@ -537,6 +537,14 @@ static struct resource ams_delta_serio_resources[] = {
 static struct platform_device ams_delta_serio_device = {
        .name           = "ams-delta-serio",
        .id             = PLATFORM_DEVID_NONE,
+       .dev            = {
+               /*
+                * Initialize .platform_data explicitly with NULL to
+                * indicate it is going to be used.  It will be replaced
+                * with FIQ buffer address as soon as FIQ is initialized.
+                */
+               .platform_data = NULL,
+       },
        .num_resources  = ARRAY_SIZE(ams_delta_serio_resources),
        .resource       = ams_delta_serio_resources,
 };
index c1f8226f172e2f62bcbe21fc262c21a3c97282e6..f8663d7891f270bb4e3b00b20e6eaf64c312cd5a 100644 (file)
@@ -37,6 +37,7 @@ MODULE_LICENSE("GPL");
 struct ams_delta_serio {
        struct serio *serio;
        struct regulator *vcc;
+       unsigned int *fiq_buffer;
 };
 
 static int check_data(struct serio *serio, int data)
@@ -66,22 +67,23 @@ static int check_data(struct serio *serio, int data)
 static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
 {
        struct ams_delta_serio *priv = dev_id;
-       int *circ_buff = &fiq_buffer[FIQ_CIRC_BUFF];
+       int *circ_buff = &priv->fiq_buffer[FIQ_CIRC_BUFF];
        int data, dfl;
        u8 scancode;
 
-       fiq_buffer[FIQ_IRQ_PEND] = 0;
+       priv->fiq_buffer[FIQ_IRQ_PEND] = 0;
 
        /*
         * Read data from the circular buffer, check it
         * and then pass it on the serio
         */
-       while (fiq_buffer[FIQ_KEYS_CNT] > 0) {
+       while (priv->fiq_buffer[FIQ_KEYS_CNT] > 0) {
 
-               data = circ_buff[fiq_buffer[FIQ_HEAD_OFFSET]++];
-               fiq_buffer[FIQ_KEYS_CNT]--;
-               if (fiq_buffer[FIQ_HEAD_OFFSET] == fiq_buffer[FIQ_BUF_LEN])
-                       fiq_buffer[FIQ_HEAD_OFFSET] = 0;
+               data = circ_buff[priv->fiq_buffer[FIQ_HEAD_OFFSET]++];
+               priv->fiq_buffer[FIQ_KEYS_CNT]--;
+               if (priv->fiq_buffer[FIQ_HEAD_OFFSET] ==
+                   priv->fiq_buffer[FIQ_BUF_LEN])
+                       priv->fiq_buffer[FIQ_HEAD_OFFSET] = 0;
 
                dfl = check_data(priv->serio, data);
                scancode = (u8) (data >> 1) & 0xFF;
@@ -116,6 +118,10 @@ static int ams_delta_serio_init(struct platform_device *pdev)
        if (!priv)
                return -ENOMEM;
 
+       priv->fiq_buffer = pdev->dev.platform_data;
+       if (!priv->fiq_buffer)
+               return -EINVAL;
+
        priv->vcc = devm_regulator_get(&pdev->dev, "vcc");
        if (IS_ERR(priv->vcc)) {
                err = PTR_ERR(priv->vcc);
index dc0f835ea918a20543e53419c4925f715ffbd46f..cf4589ccb72033fbeb6f5a0fa5e38f966b428bfa 100644 (file)
@@ -55,8 +55,4 @@
 
 #define FIQ_CIRC_BUFF          30      /*Start of circular buffer */
 
-#ifndef __ASSEMBLER__
-extern unsigned int fiq_buffer[];
-#endif
-
 #endif