diff options
| -rw-r--r-- | drivers/auxdisplay/arm-charlcd.c | 96 | ||||
| -rw-r--r-- | drivers/auxdisplay/max6959.c | 2 |
2 files changed, 29 insertions, 69 deletions
diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c index a7eae99a48f7..30fd2341c628 100644 --- a/drivers/auxdisplay/arm-charlcd.c +++ b/drivers/auxdisplay/arm-charlcd.c @@ -7,14 +7,17 @@ * * Author: Linus Walleij <triad@df.lth.se> */ +#include <linux/completion.h> +#include <linux/container_of.h> +#include <linux/delay.h> +#include <linux/err.h> #include <linux/init.h> #include <linux/interrupt.h> +#include <linux/iopoll.h> +#include <linux/mod_devicetable.h> #include <linux/platform_device.h> -#include <linux/of.h> -#include <linux/completion.h> -#include <linux/delay.h> -#include <linux/io.h> -#include <linux/slab.h> +#include <linux/string.h> +#include <linux/types.h> #include <linux/workqueue.h> #include <generated/utsrelease.h> @@ -56,8 +59,6 @@ /** * struct charlcd - Private data structure * @dev: a pointer back to containing device - * @phybase: the offset to the controller in physical memory - * @physize: the size of the physical page * @virtbase: the offset to the controller in virtual memory * @irq: reserved interrupt number * @complete: completion structure for the last LCD command @@ -65,8 +66,6 @@ */ struct charlcd { struct device *dev; - u32 phybase; - u32 physize; void __iomem *virtbase; int irq; struct completion complete; @@ -100,14 +99,13 @@ static void charlcd_wait_complete_irq(struct charlcd *lcd) if (ret < 0) { dev_err(lcd->dev, - "wait_for_completion_interruptible_timeout() " - "returned %d waiting for ready\n", ret); + "wait_for_completion_interruptible_timeout() returned %d waiting for ready\n", + ret); return; } if (ret == 0) { - dev_err(lcd->dev, "charlcd controller timed out " - "waiting for ready\n"); + dev_err(lcd->dev, "charlcd controller timed out waiting for ready\n"); return; } } @@ -116,20 +114,14 @@ static u8 charlcd_4bit_read_char(struct charlcd *lcd) { u8 data; u32 val; - int i; /* If we can, use an IRQ to wait for the data, else poll */ if (lcd->irq >= 0) charlcd_wait_complete_irq(lcd); else { - i = 0; - val = 0; - while (!(val & CHAR_RAW_VALID) && i < 10) { - udelay(100); - val = readl(lcd->virtbase + CHAR_RAW); - i++; - } - + udelay(100); + readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val, + val & CHAR_RAW_VALID, 100, 1000); writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); } msleep(1); @@ -141,13 +133,9 @@ static u8 charlcd_4bit_read_char(struct charlcd *lcd) * The second read for the low bits does not trigger an IRQ * so in this case we have to poll for the 4 lower bits */ - i = 0; - val = 0; - while (!(val & CHAR_RAW_VALID) && i < 10) { - udelay(100); - val = readl(lcd->virtbase + CHAR_RAW); - i++; - } + udelay(100); + readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val, + val & CHAR_RAW_VALID, 100, 1000); writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); msleep(1); @@ -169,7 +157,8 @@ static bool charlcd_4bit_read_bf(struct charlcd *lcd) writel(0x01, lcd->virtbase + CHAR_MASK); } readl(lcd->virtbase + CHAR_COM); - return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false; + + return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG; } static void charlcd_4bit_wait_busy(struct charlcd *lcd) @@ -266,44 +255,26 @@ static void charlcd_init_work(struct work_struct *work) static int __init charlcd_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct charlcd *lcd; - struct resource *res; - lcd = kzalloc(sizeof(*lcd), GFP_KERNEL); + lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); if (!lcd) return -ENOMEM; lcd->dev = &pdev->dev; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENOENT; - goto out_no_resource; - } - lcd->phybase = res->start; - lcd->physize = resource_size(res); - - if (request_mem_region(lcd->phybase, lcd->physize, - DRIVERNAME) == NULL) { - ret = -EBUSY; - goto out_no_memregion; - } - - lcd->virtbase = ioremap(lcd->phybase, lcd->physize); - if (!lcd->virtbase) { - ret = -ENOMEM; - goto out_no_memregion; - } + lcd->virtbase = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(lcd->virtbase)) + return PTR_ERR(lcd->virtbase); lcd->irq = platform_get_irq(pdev, 0); /* If no IRQ is supplied, we'll survive without it */ if (lcd->irq >= 0) { - if (request_irq(lcd->irq, charlcd_interrupt, 0, - DRIVERNAME, lcd)) { - ret = -EIO; - goto out_no_irq; - } + ret = devm_request_irq(dev, lcd->irq, charlcd_interrupt, 0, DRIVERNAME, lcd); + if (ret) + return ret; } platform_set_drvdata(pdev, lcd); @@ -315,18 +286,7 @@ static int __init charlcd_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); schedule_delayed_work(&lcd->init_work, 0); - dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n", - lcd->phybase); - return 0; - -out_no_irq: - iounmap(lcd->virtbase); -out_no_memregion: - release_mem_region(lcd->phybase, SZ_4K); -out_no_resource: - kfree(lcd); - return ret; } static int charlcd_suspend(struct device *dev) @@ -362,7 +322,7 @@ static struct platform_driver charlcd_driver = { .name = DRIVERNAME, .pm = &charlcd_pm_ops, .suppress_bind_attrs = true, - .of_match_table = of_match_ptr(charlcd_match), + .of_match_table = charlcd_match, }, }; builtin_platform_driver_probe(charlcd_driver, charlcd_probe); diff --git a/drivers/auxdisplay/max6959.c b/drivers/auxdisplay/max6959.c index 962488197b9e..6bbc8d48fb1b 100644 --- a/drivers/auxdisplay/max6959.c +++ b/drivers/auxdisplay/max6959.c @@ -11,13 +11,13 @@ #include <linux/bitrev.h> #include <linux/bits.h> #include <linux/container_of.h> +#include <linux/device/devres.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pm.h> #include <linux/regmap.h> -#include <linux/slab.h> #include <linux/types.h> #include <linux/workqueue.h> |
