Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'auxdisplay-v6.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-auxdisplay

Pull auxdisplay updates from Andy Shevchenko:

- A good refactoring of arm-charlcd to use modern kernel APIs

* tag 'auxdisplay-v6.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-auxdisplay:
auxdisplay: max6959: Replace slab.h with device/devres.h
auxdisplay: arm-charlcd: Remove redundant ternary operators
auxdisplay: arm-charlcd: Join string literals back
auxdisplay: arm-charlcd: Use readl_poll_timeout
auxdisplay: arm-charlcd: Don't use "proxy" headers
auxdisplay: arm-charlcd: drop of_match_ptr()
auxdisplay: arm-charlcd: Remove unneeded info message
auxdisplay: arm-charlcd: convert to use device managed APIs
auxdisplay: arm-charlcd: fix release_mem_region() size

+29 -69
+28 -68
drivers/auxdisplay/arm-charlcd.c
··· 7 7 * 8 8 * Author: Linus Walleij <triad@df.lth.se> 9 9 */ 10 + #include <linux/completion.h> 11 + #include <linux/container_of.h> 12 + #include <linux/delay.h> 13 + #include <linux/err.h> 10 14 #include <linux/init.h> 11 15 #include <linux/interrupt.h> 16 + #include <linux/iopoll.h> 17 + #include <linux/mod_devicetable.h> 12 18 #include <linux/platform_device.h> 13 - #include <linux/of.h> 14 - #include <linux/completion.h> 15 - #include <linux/delay.h> 16 - #include <linux/io.h> 17 - #include <linux/slab.h> 19 + #include <linux/string.h> 20 + #include <linux/types.h> 18 21 #include <linux/workqueue.h> 19 22 #include <generated/utsrelease.h> 20 23 ··· 59 56 /** 60 57 * struct charlcd - Private data structure 61 58 * @dev: a pointer back to containing device 62 - * @phybase: the offset to the controller in physical memory 63 - * @physize: the size of the physical page 64 59 * @virtbase: the offset to the controller in virtual memory 65 60 * @irq: reserved interrupt number 66 61 * @complete: completion structure for the last LCD command ··· 66 65 */ 67 66 struct charlcd { 68 67 struct device *dev; 69 - u32 phybase; 70 - u32 physize; 71 68 void __iomem *virtbase; 72 69 int irq; 73 70 struct completion complete; ··· 99 100 100 101 if (ret < 0) { 101 102 dev_err(lcd->dev, 102 - "wait_for_completion_interruptible_timeout() " 103 - "returned %d waiting for ready\n", ret); 103 + "wait_for_completion_interruptible_timeout() returned %d waiting for ready\n", 104 + ret); 104 105 return; 105 106 } 106 107 107 108 if (ret == 0) { 108 - dev_err(lcd->dev, "charlcd controller timed out " 109 - "waiting for ready\n"); 109 + dev_err(lcd->dev, "charlcd controller timed out waiting for ready\n"); 110 110 return; 111 111 } 112 112 } ··· 114 116 { 115 117 u8 data; 116 118 u32 val; 117 - int i; 118 119 119 120 /* If we can, use an IRQ to wait for the data, else poll */ 120 121 if (lcd->irq >= 0) 121 122 charlcd_wait_complete_irq(lcd); 122 123 else { 123 - i = 0; 124 - val = 0; 125 - while (!(val & CHAR_RAW_VALID) && i < 10) { 126 - udelay(100); 127 - val = readl(lcd->virtbase + CHAR_RAW); 128 - i++; 129 - } 130 - 124 + udelay(100); 125 + readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val, 126 + val & CHAR_RAW_VALID, 100, 1000); 131 127 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); 132 128 } 133 129 msleep(1); ··· 133 141 * The second read for the low bits does not trigger an IRQ 134 142 * so in this case we have to poll for the 4 lower bits 135 143 */ 136 - i = 0; 137 - val = 0; 138 - while (!(val & CHAR_RAW_VALID) && i < 10) { 139 - udelay(100); 140 - val = readl(lcd->virtbase + CHAR_RAW); 141 - i++; 142 - } 144 + udelay(100); 145 + readl_poll_timeout_atomic(lcd->virtbase + CHAR_RAW, val, 146 + val & CHAR_RAW_VALID, 100, 1000); 143 147 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); 144 148 msleep(1); 145 149 ··· 157 169 writel(0x01, lcd->virtbase + CHAR_MASK); 158 170 } 159 171 readl(lcd->virtbase + CHAR_COM); 160 - return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false; 172 + 173 + return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG; 161 174 } 162 175 163 176 static void charlcd_4bit_wait_busy(struct charlcd *lcd) ··· 255 266 256 267 static int __init charlcd_probe(struct platform_device *pdev) 257 268 { 269 + struct device *dev = &pdev->dev; 258 270 int ret; 259 271 struct charlcd *lcd; 260 - struct resource *res; 261 272 262 - lcd = kzalloc(sizeof(*lcd), GFP_KERNEL); 273 + lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL); 263 274 if (!lcd) 264 275 return -ENOMEM; 265 276 266 277 lcd->dev = &pdev->dev; 267 278 268 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 269 - if (!res) { 270 - ret = -ENOENT; 271 - goto out_no_resource; 272 - } 273 - lcd->phybase = res->start; 274 - lcd->physize = resource_size(res); 275 - 276 - if (request_mem_region(lcd->phybase, lcd->physize, 277 - DRIVERNAME) == NULL) { 278 - ret = -EBUSY; 279 - goto out_no_memregion; 280 - } 281 - 282 - lcd->virtbase = ioremap(lcd->phybase, lcd->physize); 283 - if (!lcd->virtbase) { 284 - ret = -ENOMEM; 285 - goto out_no_memregion; 286 - } 279 + lcd->virtbase = devm_platform_ioremap_resource(pdev, 0); 280 + if (IS_ERR(lcd->virtbase)) 281 + return PTR_ERR(lcd->virtbase); 287 282 288 283 lcd->irq = platform_get_irq(pdev, 0); 289 284 /* If no IRQ is supplied, we'll survive without it */ 290 285 if (lcd->irq >= 0) { 291 - if (request_irq(lcd->irq, charlcd_interrupt, 0, 292 - DRIVERNAME, lcd)) { 293 - ret = -EIO; 294 - goto out_no_irq; 295 - } 286 + ret = devm_request_irq(dev, lcd->irq, charlcd_interrupt, 0, DRIVERNAME, lcd); 287 + if (ret) 288 + return ret; 296 289 } 297 290 298 291 platform_set_drvdata(pdev, lcd); ··· 286 315 INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); 287 316 schedule_delayed_work(&lcd->init_work, 0); 288 317 289 - dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n", 290 - lcd->phybase); 291 - 292 318 return 0; 293 - 294 - out_no_irq: 295 - iounmap(lcd->virtbase); 296 - out_no_memregion: 297 - release_mem_region(lcd->phybase, SZ_4K); 298 - out_no_resource: 299 - kfree(lcd); 300 - return ret; 301 319 } 302 320 303 321 static int charlcd_suspend(struct device *dev) ··· 322 362 .name = DRIVERNAME, 323 363 .pm = &charlcd_pm_ops, 324 364 .suppress_bind_attrs = true, 325 - .of_match_table = of_match_ptr(charlcd_match), 365 + .of_match_table = charlcd_match, 326 366 }, 327 367 }; 328 368 builtin_platform_driver_probe(charlcd_driver, charlcd_probe);
+1 -1
drivers/auxdisplay/max6959.c
··· 11 11 #include <linux/bitrev.h> 12 12 #include <linux/bits.h> 13 13 #include <linux/container_of.h> 14 + #include <linux/device/devres.h> 14 15 #include <linux/err.h> 15 16 #include <linux/i2c.h> 16 17 #include <linux/mod_devicetable.h> 17 18 #include <linux/module.h> 18 19 #include <linux/pm.h> 19 20 #include <linux/regmap.h> 20 - #include <linux/slab.h> 21 21 #include <linux/types.h> 22 22 #include <linux/workqueue.h> 23 23