--- /dev/null
+From 79d2c8bede2c93f9432d7da0bc2f76a195c90fc0 Mon Sep 17 00:00:00 2001
+From: Daniel Drake <drake@endlessm.com>
+Date: Mon, 11 Sep 2017 14:11:56 +0800
+Subject: pinctrl/amd: save pin registers over suspend/resume
+
+From: Daniel Drake <drake@endlessm.com>
+
+commit 79d2c8bede2c93f9432d7da0bc2f76a195c90fc0 upstream.
+
+The touchpad in the Asus laptop models X505BA/BP and X542BA/BP is
+unresponsive after suspend/resume. The following error appears during
+resume:
+
+ i2c_hid i2c-ELAN1300:00: failed to reset device.
+
+The problem here is that i2c_hid does not notice the interrupt being
+generated at this point, because the GPIO is no longer configured
+for interrupts.
+
+Fix this by saving pinctrl-amd pin registers during suspend and
+restoring them at resume time.
+
+Based on code from pinctrl-intel.
+
+Signed-off-by: Daniel Drake <drake@endlessm.com>
+Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pinctrl/pinctrl-amd.c | 75 ++++++++++++++++++++++++++++++++++++++++++
+ drivers/pinctrl/pinctrl-amd.h | 1
+ 2 files changed, 76 insertions(+)
+
+--- a/drivers/pinctrl/pinctrl-amd.c
++++ b/drivers/pinctrl/pinctrl-amd.c
+@@ -36,6 +36,7 @@
+ #include <linux/pinctrl/pinconf.h>
+ #include <linux/pinctrl/pinconf-generic.h>
+
++#include "core.h"
+ #include "pinctrl-utils.h"
+ #include "pinctrl-amd.h"
+
+@@ -725,6 +726,69 @@ static const struct pinconf_ops amd_pinc
+ .pin_config_group_set = amd_pinconf_group_set,
+ };
+
++#ifdef CONFIG_PM_SLEEP
++static bool amd_gpio_should_save(struct amd_gpio *gpio_dev, unsigned int pin)
++{
++ const struct pin_desc *pd = pin_desc_get(gpio_dev->pctrl, pin);
++
++ if (!pd)
++ return false;
++
++ /*
++ * Only restore the pin if it is actually in use by the kernel (or
++ * by userspace).
++ */
++ if (pd->mux_owner || pd->gpio_owner ||
++ gpiochip_line_is_irq(&gpio_dev->gc, pin))
++ return true;
++
++ return false;
++}
++
++int amd_gpio_suspend(struct device *dev)
++{
++ struct platform_device *pdev = to_platform_device(dev);
++ struct amd_gpio *gpio_dev = platform_get_drvdata(pdev);
++ struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
++ int i;
++
++ for (i = 0; i < desc->npins; i++) {
++ int pin = desc->pins[i].number;
++
++ if (!amd_gpio_should_save(gpio_dev, pin))
++ continue;
++
++ gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin*4);
++ }
++
++ return 0;
++}
++
++int amd_gpio_resume(struct device *dev)
++{
++ struct platform_device *pdev = to_platform_device(dev);
++ struct amd_gpio *gpio_dev = platform_get_drvdata(pdev);
++ struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
++ int i;
++
++ for (i = 0; i < desc->npins; i++) {
++ int pin = desc->pins[i].number;
++
++ if (!amd_gpio_should_save(gpio_dev, pin))
++ continue;
++
++ writel(gpio_dev->saved_regs[i], gpio_dev->base + pin*4);
++ }
++
++ return 0;
++}
++
++static const struct dev_pm_ops amd_gpio_pm_ops = {
++ SET_LATE_SYSTEM_SLEEP_PM_OPS(amd_gpio_suspend,
++ amd_gpio_resume)
++};
++#endif
++
+ static struct pinctrl_desc amd_pinctrl_desc = {
+ .pins = kerncz_pins,
+ .npins = ARRAY_SIZE(kerncz_pins),
+@@ -764,6 +828,14 @@ static int amd_gpio_probe(struct platfor
+ return -EINVAL;
+ }
+
++#ifdef CONFIG_PM_SLEEP
++ gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins,
++ sizeof(*gpio_dev->saved_regs),
++ GFP_KERNEL);
++ if (!gpio_dev->saved_regs)
++ return -ENOMEM;
++#endif
++
+ gpio_dev->pdev = pdev;
+ gpio_dev->gc.direction_input = amd_gpio_direction_input;
+ gpio_dev->gc.direction_output = amd_gpio_direction_output;
+@@ -853,6 +925,9 @@ static struct platform_driver amd_gpio_d
+ .driver = {
+ .name = "amd_gpio",
+ .acpi_match_table = ACPI_PTR(amd_gpio_acpi_match),
++#ifdef CONFIG_PM_SLEEP
++ .pm = &amd_gpio_pm_ops,
++#endif
+ },
+ .probe = amd_gpio_probe,
+ .remove = amd_gpio_remove,
+--- a/drivers/pinctrl/pinctrl-amd.h
++++ b/drivers/pinctrl/pinctrl-amd.h
+@@ -97,6 +97,7 @@ struct amd_gpio {
+ unsigned int hwbank_num;
+ struct resource *res;
+ struct platform_device *pdev;
++ u32 *saved_regs;
+ };
+
+ /* KERNCZ configuration*/
--- /dev/null
+From cee7413d84044a0c1919a7c70a2d761ae24390de Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <krzk@kernel.org>
+Date: Thu, 15 Jun 2017 17:46:37 +0200
+Subject: pinctrl: samsung: Fix NULL pointer exception on external interrupts on S3C24xx
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+commit cee7413d84044a0c1919a7c70a2d761ae24390de upstream.
+
+After commit 8b1bd11c1f8f ("pinctrl: samsung: Add the support the
+multiple IORESOURCE_MEM for one pin-bank"), the S3C24xx (and probably
+S3C64xx as well) fails:
+
+ Unable to handle kernel NULL pointer dereference at virtual address 000000a8
+ ...
+ (s3c24xx_demux_eint4_7) from [<c004469c>] (__handle_domain_irq+0x6c/0xcc)
+ (__handle_domain_irq) from [<c0009444>] (s3c24xx_handle_irq+0x6c/0x12c)
+ (s3c24xx_handle_irq) from [<c000e5fc>] (__irq_svc+0x5c/0x78)
+
+Mentioned commit moved the pointer to controller's base IO memory address
+from each controller's driver data (samsung_pinctrl_drv_data) to per-bank
+structure (samsung_pin_bank). The external interrupt demux
+handlers (s3c24xx_demux_eint()) tried to get this base address from opaque
+pointer stored under irq_chip data:
+
+ struct irq_data *irqd = irq_desc_get_irq_data(desc);
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
+ ...
+ pend = readl(bank->eint_base + EINTPEND_REG);
+
+which is wrong because this is hardware irq and it bank was never set
+for this irq_chip.
+
+For S3C24xx and S3C64xx, this partially reverts mentioned commit by
+bringing back the virt_base stored under each controller's driver data
+(samsung_pinctrl_drv_data). This virt_base address will be now
+duplicated:
+ - samsung_pinctrl_drv_data->virt_base: used on S3C24xx and S3C64xx,
+ - samsung_pin_bank->pctl_base: used on Exynos.
+
+Fixes: 8b1bd11c1f8f ("pinctrl: samsung: Add the support the multiple IORESOURCE_MEM for one pin-bank")
+Cc: Sergio Prado <sergio.prado@e-labworks.com>
+Reported-by: Sergio Prado <sergio.prado@e-labworks.com>
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Tested-by: Lihua Yao <ylhuajnu@163.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/pinctrl/samsung/pinctrl-s3c24xx.c | 37 +++++++++++++++------------
+ drivers/pinctrl/samsung/pinctrl-s3c64xx.c | 40 +++++++++++++-----------------
+ drivers/pinctrl/samsung/pinctrl-samsung.c | 6 ++++
+ drivers/pinctrl/samsung/pinctrl-samsung.h | 5 +++
+ 4 files changed, 50 insertions(+), 38 deletions(-)
+
+--- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
++++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
+@@ -151,7 +151,7 @@ static void s3c24xx_eint_set_function(st
+ u32 val;
+
+ /* Make sure that pin is configured as interrupt */
+- reg = bank->pctl_base + bank->pctl_offset;
++ reg = d->virt_base + bank->pctl_offset;
+ shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC];
+ mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1;
+
+@@ -184,7 +184,7 @@ static int s3c24xx_eint_type(struct irq_
+ s3c24xx_eint_set_handler(data, type);
+
+ /* Set up interrupt trigger */
+- reg = bank->eint_base + EINT_REG(index);
++ reg = d->virt_base + EINT_REG(index);
+ shift = EINT_OFFS(index);
+
+ val = readl(reg);
+@@ -259,29 +259,32 @@ static void s3c2410_demux_eint0_3(struct
+ static void s3c2412_eint0_3_ack(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+
+ unsigned long bitval = 1UL << data->hwirq;
+- writel(bitval, bank->eint_base + EINTPEND_REG);
++ writel(bitval, d->virt_base + EINTPEND_REG);
+ }
+
+ static void s3c2412_eint0_3_mask(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned long mask;
+
+- mask = readl(bank->eint_base + EINTMASK_REG);
++ mask = readl(d->virt_base + EINTMASK_REG);
+ mask |= (1UL << data->hwirq);
+- writel(mask, bank->eint_base + EINTMASK_REG);
++ writel(mask, d->virt_base + EINTMASK_REG);
+ }
+
+ static void s3c2412_eint0_3_unmask(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned long mask;
+
+- mask = readl(bank->eint_base + EINTMASK_REG);
++ mask = readl(d->virt_base + EINTMASK_REG);
+ mask &= ~(1UL << data->hwirq);
+- writel(mask, bank->eint_base + EINTMASK_REG);
++ writel(mask, d->virt_base + EINTMASK_REG);
+ }
+
+ static struct irq_chip s3c2412_eint0_3_chip = {
+@@ -316,31 +319,34 @@ static void s3c2412_demux_eint0_3(struct
+ static void s3c24xx_eint_ack(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned char index = bank->eint_offset + data->hwirq;
+
+- writel(1UL << index, bank->eint_base + EINTPEND_REG);
++ writel(1UL << index, d->virt_base + EINTPEND_REG);
+ }
+
+ static void s3c24xx_eint_mask(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned char index = bank->eint_offset + data->hwirq;
+ unsigned long mask;
+
+- mask = readl(bank->eint_base + EINTMASK_REG);
++ mask = readl(d->virt_base + EINTMASK_REG);
+ mask |= (1UL << index);
+- writel(mask, bank->eint_base + EINTMASK_REG);
++ writel(mask, d->virt_base + EINTMASK_REG);
+ }
+
+ static void s3c24xx_eint_unmask(struct irq_data *data)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(data);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned char index = bank->eint_offset + data->hwirq;
+ unsigned long mask;
+
+- mask = readl(bank->eint_base + EINTMASK_REG);
++ mask = readl(d->virt_base + EINTMASK_REG);
+ mask &= ~(1UL << index);
+- writel(mask, bank->eint_base + EINTMASK_REG);
++ writel(mask, d->virt_base + EINTMASK_REG);
+ }
+
+ static struct irq_chip s3c24xx_eint_chip = {
+@@ -356,14 +362,13 @@ static inline void s3c24xx_demux_eint(st
+ {
+ struct s3c24xx_eint_data *data = irq_desc_get_handler_data(desc);
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+- struct irq_data *irqd = irq_desc_get_irq_data(desc);
+- struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
++ struct samsung_pinctrl_drv_data *d = data->drvdata;
+ unsigned int pend, mask;
+
+ chained_irq_enter(chip, desc);
+
+- pend = readl(bank->eint_base + EINTPEND_REG);
+- mask = readl(bank->eint_base + EINTMASK_REG);
++ pend = readl(d->virt_base + EINTPEND_REG);
++ mask = readl(d->virt_base + EINTMASK_REG);
+
+ pend &= ~mask;
+ pend &= range;
+--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
++++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+@@ -280,7 +280,7 @@ static void s3c64xx_irq_set_function(str
+ u32 val;
+
+ /* Make sure that pin is configured as interrupt */
+- reg = bank->pctl_base + bank->pctl_offset;
++ reg = d->virt_base + bank->pctl_offset;
+ shift = pin;
+ if (bank_type->fld_width[PINCFG_TYPE_FUNC] * shift >= 32) {
+ /* 4-bit bank type with 2 con regs */
+@@ -308,8 +308,9 @@ static void s3c64xx_irq_set_function(str
+ static inline void s3c64xx_gpio_irq_set_mask(struct irq_data *irqd, bool mask)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
+- void __iomem *reg = bank->eint_base + EINTMASK_REG(bank->eint_offset);
++ void __iomem *reg = d->virt_base + EINTMASK_REG(bank->eint_offset);
+ u32 val;
+
+ val = readl(reg);
+@@ -333,8 +334,9 @@ static void s3c64xx_gpio_irq_mask(struct
+ static void s3c64xx_gpio_irq_ack(struct irq_data *irqd)
+ {
+ struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ unsigned char index = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
+- void __iomem *reg = bank->eint_base + EINTPEND_REG(bank->eint_offset);
++ void __iomem *reg = d->virt_base + EINTPEND_REG(bank->eint_offset);
+
+ writel(1 << index, reg);
+ }
+@@ -357,7 +359,7 @@ static int s3c64xx_gpio_irq_set_type(str
+ s3c64xx_irq_set_handler(irqd, type);
+
+ /* Set up interrupt trigger */
+- reg = bank->eint_base + EINTCON_REG(bank->eint_offset);
++ reg = d->virt_base + EINTCON_REG(bank->eint_offset);
+ shift = EINT_OFFS(bank->eint_offset) + irqd->hwirq;
+ shift = 4 * (shift / 4); /* 4 EINTs per trigger selector */
+
+@@ -409,8 +411,7 @@ static void s3c64xx_eint_gpio_irq(struct
+ {
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+ struct s3c64xx_eint_gpio_data *data = irq_desc_get_handler_data(desc);
+- struct irq_data *irqd = irq_desc_get_irq_data(desc);
+- struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
++ struct samsung_pinctrl_drv_data *drvdata = data->drvdata;
+
+ chained_irq_enter(chip, desc);
+
+@@ -420,7 +421,7 @@ static void s3c64xx_eint_gpio_irq(struct
+ unsigned int pin;
+ unsigned int virq;
+
+- svc = readl(bank->eint_base + SERVICE_REG);
++ svc = readl(drvdata->virt_base + SERVICE_REG);
+ group = SVC_GROUP(svc);
+ pin = svc & SVC_NUM_MASK;
+
+@@ -515,15 +516,15 @@ static inline void s3c64xx_eint0_irq_set
+ {
+ struct s3c64xx_eint0_domain_data *ddata =
+ irq_data_get_irq_chip_data(irqd);
+- struct samsung_pin_bank *bank = ddata->bank;
++ struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata;
+ u32 val;
+
+- val = readl(bank->eint_base + EINT0MASK_REG);
++ val = readl(d->virt_base + EINT0MASK_REG);
+ if (mask)
+ val |= 1 << ddata->eints[irqd->hwirq];
+ else
+ val &= ~(1 << ddata->eints[irqd->hwirq]);
+- writel(val, bank->eint_base + EINT0MASK_REG);
++ writel(val, d->virt_base + EINT0MASK_REG);
+ }
+
+ static void s3c64xx_eint0_irq_unmask(struct irq_data *irqd)
+@@ -540,10 +541,10 @@ static void s3c64xx_eint0_irq_ack(struct
+ {
+ struct s3c64xx_eint0_domain_data *ddata =
+ irq_data_get_irq_chip_data(irqd);
+- struct samsung_pin_bank *bank = ddata->bank;
++ struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata;
+
+ writel(1 << ddata->eints[irqd->hwirq],
+- bank->eint_base + EINT0PEND_REG);
++ d->virt_base + EINT0PEND_REG);
+ }
+
+ static int s3c64xx_eint0_irq_set_type(struct irq_data *irqd, unsigned int type)
+@@ -551,7 +552,7 @@ static int s3c64xx_eint0_irq_set_type(st
+ struct s3c64xx_eint0_domain_data *ddata =
+ irq_data_get_irq_chip_data(irqd);
+ struct samsung_pin_bank *bank = ddata->bank;
+- struct samsung_pinctrl_drv_data *d = ddata->bank->drvdata;
++ struct samsung_pinctrl_drv_data *d = bank->drvdata;
+ void __iomem *reg;
+ int trigger;
+ u8 shift;
+@@ -566,7 +567,7 @@ static int s3c64xx_eint0_irq_set_type(st
+ s3c64xx_irq_set_handler(irqd, type);
+
+ /* Set up interrupt trigger */
+- reg = bank->eint_base + EINT0CON0_REG;
++ reg = d->virt_base + EINT0CON0_REG;
+ shift = ddata->eints[irqd->hwirq];
+ if (shift >= EINT_MAX_PER_REG) {
+ reg += 4;
+@@ -598,19 +599,14 @@ static struct irq_chip s3c64xx_eint0_irq
+ static inline void s3c64xx_irq_demux_eint(struct irq_desc *desc, u32 range)
+ {
+ struct irq_chip *chip = irq_desc_get_chip(desc);
+- struct irq_data *irqd = irq_desc_get_irq_data(desc);
+- struct s3c64xx_eint0_domain_data *ddata =
+- irq_data_get_irq_chip_data(irqd);
+- struct samsung_pin_bank *bank = ddata->bank;
+-
+ struct s3c64xx_eint0_data *data = irq_desc_get_handler_data(desc);
+-
++ struct samsung_pinctrl_drv_data *drvdata = data->drvdata;
+ unsigned int pend, mask;
+
+ chained_irq_enter(chip, desc);
+
+- pend = readl(bank->eint_base + EINT0PEND_REG);
+- mask = readl(bank->eint_base + EINT0MASK_REG);
++ pend = readl(drvdata->virt_base + EINT0PEND_REG);
++ mask = readl(drvdata->virt_base + EINT0MASK_REG);
+
+ pend = pend & range & ~mask;
+ pend &= range;
+--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
++++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
+@@ -1013,6 +1013,12 @@ samsung_pinctrl_get_soc_data(struct sams
+ bank->eint_base = virt_base[0];
+ bank->pctl_base = virt_base[bdata->pctl_res_idx];
+ }
++ /*
++ * Legacy platforms should provide only one resource with IO memory.
++ * Store it as virt_base because legacy driver needs to access it
++ * through samsung_pinctrl_drv_data.
++ */
++ d->virt_base = virt_base[0];
+
+ for_each_child_of_node(node, np) {
+ if (!of_find_property(np, "gpio-controller", NULL))
+--- a/drivers/pinctrl/samsung/pinctrl-samsung.h
++++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
+@@ -247,6 +247,10 @@ struct samsung_pin_ctrl {
+ /**
+ * struct samsung_pinctrl_drv_data: wrapper for holding driver data together.
+ * @node: global list node
++ * @virt_base: register base address of the controller; this will be equal
++ * to each bank samsung_pin_bank->pctl_base and used on legacy
++ * platforms (like S3C24XX or S3C64XX) which has to access the base
++ * through samsung_pinctrl_drv_data, not samsung_pin_bank).
+ * @dev: device instance representing the controller.
+ * @irq: interrpt number used by the controller to notify gpio interrupts.
+ * @ctrl: pin controller instance managed by the driver.
+@@ -262,6 +266,7 @@ struct samsung_pin_ctrl {
+ */
+ struct samsung_pinctrl_drv_data {
+ struct list_head node;
++ void __iomem *virt_base;
+ struct device *dev;
+ int irq;
+
--- /dev/null
+From 979990c6284814617d8f2179d197f72ff62b5d85 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Tue, 20 Jun 2017 23:10:41 +0200
+Subject: tty: improve tty_insert_flip_char() fast path
+
+From: Arnd Bergmann <arnd@arndb.de>
+
+commit 979990c6284814617d8f2179d197f72ff62b5d85 upstream.
+
+kernelci.org reports a crazy stack usage for the VT code when CONFIG_KASAN
+is enabled:
+
+drivers/tty/vt/keyboard.c: In function 'kbd_keycode':
+drivers/tty/vt/keyboard.c:1452:1: error: the frame size of 2240 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
+
+The problem is that tty_insert_flip_char() gets inlined many times into
+kbd_keycode(), and also into other functions, and each copy requires 128
+bytes for stack redzone to check for a possible out-of-bounds access on
+the 'ch' and 'flags' arguments that are passed into
+tty_insert_flip_string_flags as a variable-length string.
+
+This introduces a new __tty_insert_flip_char() function for the slow
+path, which receives the two arguments by value. This completely avoids
+the problem and the stack usage goes back down to around 100 bytes.
+
+Without KASAN, this is also slightly better, as we don't have to
+spill the arguments to the stack but can simply pass 'ch' and 'flag'
+in registers, saving a few bytes in .text for each call site.
+
+This should be backported to linux-4.0 or later, which first introduced
+the stack sanitizer in the kernel.
+
+Fixes: c420f167db8c ("kasan: enable stack instrumentation")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/tty/tty_buffer.c | 24 ++++++++++++++++++++++++
+ include/linux/tty_flip.h | 3 ++-
+ 2 files changed, 26 insertions(+), 1 deletion(-)
+
+--- a/drivers/tty/tty_buffer.c
++++ b/drivers/tty/tty_buffer.c
+@@ -362,6 +362,30 @@ int tty_insert_flip_string_flags(struct
+ EXPORT_SYMBOL(tty_insert_flip_string_flags);
+
+ /**
++ * __tty_insert_flip_char - Add one character to the tty buffer
++ * @port: tty port
++ * @ch: character
++ * @flag: flag byte
++ *
++ * Queue a single byte to the tty buffering, with an optional flag.
++ * This is the slow path of tty_insert_flip_char.
++ */
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag)
++{
++ struct tty_buffer *tb = port->buf.tail;
++ int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0;
++
++ if (!tty_buffer_request_room(port, 1))
++ return 0;
++
++ *flag_buf_ptr(tb, tb->used) = flag;
++ *char_buf_ptr(tb, tb->used++) = ch;
++
++ return 1;
++}
++EXPORT_SYMBOL(__tty_insert_flip_char);
++
++/**
+ * tty_schedule_flip - push characters to ldisc
+ * @port: tty port to push from
+ *
+--- a/include/linux/tty_flip.h
++++ b/include/linux/tty_flip.h
+@@ -12,6 +12,7 @@ extern int tty_prepare_flip_string(struc
+ unsigned char **chars, size_t size);
+ extern void tty_flip_buffer_push(struct tty_port *port);
+ void tty_schedule_flip(struct tty_port *port);
++int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag);
+
+ static inline int tty_insert_flip_char(struct tty_port *port,
+ unsigned char ch, char flag)
+@@ -26,7 +27,7 @@ static inline int tty_insert_flip_char(s
+ *char_buf_ptr(tb, tb->used++) = ch;
+ return 1;
+ }
+- return tty_insert_flip_string_flags(port, &ch, &flag, 1);
++ return __tty_insert_flip_char(port, ch, flag);
+ }
+
+ static inline int tty_insert_flip_string(struct tty_port *port,