WARNING in ion_dma_buf_begin_cpu_access
Hello, syzbot found the following crash on: HEAD commit:a16afaf7928b Merge tag 'for-v4.18' of git://git.kernel.org.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1480e36f80 kernel config: https://syzkaller.appspot.com/x/.config?x=314f2150f36c16ca dashboard link: https://syzkaller.appspot.com/bug?extid=55b1d9f811650de944c6 compiler: gcc (GCC) 8.0.1 20180413 (experimental) syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=150b8abf80 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1204efdf80 IMPORTANT: if you fix the bug, please add the following tag to the commit: Reported-by: syzbot+55b1d9f811650de94...@syzkaller.appspotmail.com 1965969 pages RAM 0 pages HighMem/MovableOnly 340001 pages reserved [ cut here ] heap->ops->map_kernel should return ERR_PTR on error WARNING: CPU: 1 PID: 4564 at drivers/staging/android/ion/ion.c:148 ion_buffer_kmap_get drivers/staging/android/ion/ion.c:147 [inline] WARNING: CPU: 1 PID: 4564 at drivers/staging/android/ion/ion.c:148 ion_dma_buf_begin_cpu_access+0x48e/0x5a0 drivers/staging/android/ion/ion.c:328 Kernel panic - not syncing: panic_on_warn set ... CPU: 1 PID: 4564 Comm: syz-executor145 Not tainted 4.17.0+ #93 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1b9/0x294 lib/dump_stack.c:113 panic+0x22f/0x4de kernel/panic.c:184 __warn.cold.8+0x163/0x1b3 kernel/panic.c:536 report_bug+0x252/0x2d0 lib/bug.c:186 fixup_bug arch/x86/kernel/traps.c:178 [inline] do_error_trap+0x1fc/0x4d0 arch/x86/kernel/traps.c:296 do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:316 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:992 RIP: 0010:ion_buffer_kmap_get drivers/staging/android/ion/ion.c:147 [inline] RIP: 0010:ion_dma_buf_begin_cpu_access+0x48e/0x5a0 drivers/staging/android/ion/ion.c:328 Code: ff 41 bc ea ff ff ff 89 de e8 8e b0 ba fb 84 db 75 a8 e8 b5 af ba fb 48 c7 c7 00 05 68 88 c6 05 39 8d d9 03 01 e8 02 c7 86 fb <0f> 0b eb 8c 48 c7 c7 40 09 ef 88 e8 12 a3 f7 fb e9 15 ff ff ff e8 RSP: 0018:8801ac87fb08 EFLAGS: 00010286 RAX: 0034 RBX: RCX: 816191ea RDX: RSI: 8161f4e1 RDI: 8801ac87f7e0 RBP: 8801ac87fb60 R08: 8801d8856480 R09: 0006 R10: 8801d8856480 R11: R12: ffea R13: 8801d977d148 R14: 0001 R15: 89724b80 dma_buf_begin_cpu_access+0x7f/0x160 drivers/dma-buf/dma-buf.c:823 dma_buf_ioctl+0x1aa/0x240 drivers/dma-buf/dma-buf.c:314 vfs_ioctl fs/ioctl.c:46 [inline] file_ioctl fs/ioctl.c:500 [inline] do_vfs_ioctl+0x1cf/0x16f0 fs/ioctl.c:684 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701 __do_sys_ioctl fs/ioctl.c:708 [inline] __se_sys_ioctl fs/ioctl.c:706 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:706 do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x440479 Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 5b 14 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:7fff6df8d2f8 EFLAGS: 0246 ORIG_RAX: 0010 RAX: ffda RBX: RCX: 00440479 RDX: 20fd3ff8 RSI: 40086200 RDI: 0004 RBP: 006cb018 R08: 0001 R09: 7fff6df80031 R10: R11: 0246 R12: 0005 R13: R14: R15: Dumping ftrace buffer: (ftrace buffer empty) Kernel Offset: disabled Rebooting in 86400 seconds.. --- This bug is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at syzkal...@googlegroups.com. syzbot will keep track of this bug report. See: https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with syzbot. syzbot can test patches for this bug, for details see: https://goo.gl/tpsmEJ#testing-patches ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: rts5208: add check on NULL before dereference
On 2018-06-09 15:34, Andy Shevchenko wrote: On Sat, Jun 9, 2018 at 7:58 PM, wrote: On 2018-06-09 12:38, Anton Vasilyev wrote: If rtsx_probe fails to allocate dev->chip, then NULL pointer dereference occurs at rtsx_release_resources(). Patch adds checks chip on NULL before its dereference at rtsx_release_resources and passing with dereference inside rtsx_release_chip. Found by Linux Driver Verification project (linuxtesting.org). I think you should bail out if dev->chip is null rather than adding conditiinals. I'm wondering if it's false positive. At which circumstances that may happen? Only if dev->chip allocation fails. Code tries to cleanup prior resources by calling clean_everything() function which ends up in rtsx_release_resources() ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/8] staging: mt7621-gpio: avoid including 'gpio.h'
Including file '' should be avoided in new drivers code, so just remove it because it is no necessary at all. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index cc08505..433b1e9 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -5,7 +5,6 @@ */ #include -#include #include #include #include -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 8/8] staging: mt7621-gpio: implement high level and low level irqs
This chip support high level and low level interrupts. Those have to be implemented also to get a complete and clean driver. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 57 +-- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 5d082c8..b0cbb30 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -37,6 +37,8 @@ * @bank: gpio bank number for the chip * @rising: mask for rising irqs * @falling: mask for falling irqs + * @hlevel: mask for high level irqs + * @llevel: mask for low level irqs */ struct mtk_gc { struct gpio_chip chip; @@ -44,6 +46,8 @@ struct mtk_gc { int bank; u32 rising; u32 falling; + u32 hlevel; + u32 llevel; }; /** @@ -114,7 +118,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d) int bank = pin / MTK_BANK_WIDTH; struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; - u32 rise, fall; + u32 rise, fall, high, low; if (!rg) return; @@ -122,10 +126,16 @@ mediatek_gpio_irq_unmask(struct irq_data *d) spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE(bank)); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE(bank)); + high = mtk_gpio_r32(rg, GPIO_REG_HLVL(bank)); + low = mtk_gpio_r32(rg, GPIO_REG_LLVL(bank)); mtk_gpio_w32(rg, GPIO_REG_REDGE(bank), rise | (PIN_MASK(pin) & rg->rising)); mtk_gpio_w32(rg, GPIO_REG_FEDGE(bank), fall | (PIN_MASK(pin) & rg->falling)); + mtk_gpio_w32(rg, GPIO_REG_HLVL(bank), +high | (PIN_MASK(pin) & rg->hlevel)); + mtk_gpio_w32(rg, GPIO_REG_LLVL(bank), +low | (PIN_MASK(pin) & rg->llevel)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -137,7 +147,7 @@ mediatek_gpio_irq_mask(struct irq_data *d) int bank = pin / MTK_BANK_WIDTH; struct mtk_gc *rg = &gpio_data->gc_map[bank]; unsigned long flags; - u32 rise, fall; + u32 rise, fall, high, low; if (!rg) return; @@ -145,8 +155,12 @@ mediatek_gpio_irq_mask(struct irq_data *d) spin_lock_irqsave(&rg->lock, flags); rise = mtk_gpio_r32(rg, GPIO_REG_REDGE(bank)); fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE(bank)); + high = mtk_gpio_r32(rg, GPIO_REG_HLVL(bank)); + low = mtk_gpio_r32(rg, GPIO_REG_LLVL(bank)); mtk_gpio_w32(rg, GPIO_REG_FEDGE(bank), fall & ~PIN_MASK(pin)); mtk_gpio_w32(rg, GPIO_REG_REDGE(bank), rise & ~PIN_MASK(pin)); + mtk_gpio_w32(rg, GPIO_REG_REDGE(bank), high & ~PIN_MASK(pin)); + mtk_gpio_w32(rg, GPIO_REG_REDGE(bank), low & ~PIN_MASK(pin)); spin_unlock_irqrestore(&rg->lock, flags); } @@ -163,21 +177,42 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) return -1; if (type == IRQ_TYPE_PROBE) { - if ((rg->rising | rg->falling) & mask) + if ((rg->rising | rg->falling | +rg->hlevel | rg->llevel) & mask) return 0; - type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; + type = (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING | + IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW); } - if (type & IRQ_TYPE_EDGE_RISING) + switch (type) { + case IRQ_TYPE_EDGE_RISING: rg->rising |= mask; - else - rg->rising &= ~mask; - - if (type & IRQ_TYPE_EDGE_FALLING) - rg->falling |= mask; - else rg->falling &= ~mask; + rg->hlevel &= ~mask; + rg->llevel &= ~mask; + break; + case IRQ_TYPE_EDGE_FALLING: + rg->falling |= mask; + rg->rising &= ~mask; + rg->hlevel &= ~mask; + rg->llevel &= ~mask; + break; + case IRQ_TYPE_LEVEL_HIGH: + rg->hlevel |= mask; + rg->rising &= ~mask; + rg->falling &= mask; + rg->llevel &= ~mask; + break; + case IRQ_TYPE_LEVEL_LOW: + rg->llevel |= mask; + rg->rising &= ~mask; + rg->falling &= mask; + rg->hlevel &= ~mask; + break; + default: + return -EINVAL; + } return 0; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/8] staging: mt7621-gpio: add COMPILE_TEST
This driver is actually platform-agnostic. Add COMPILE_TEST for the compilation test coverage. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index f4453e8..835998a 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,6 +1,6 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" - depends on SOC_MT7620 || SOC_MT7621 + depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST select GPIO_GENERIC select ARCH_REQUIRE_GPIOLIB help -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/8] staging: mt7621-gpio: last cleanups
After submiting this driver to try to get mainlined and get out of staging some new cleanups seems to be necessary. According to this main of Linus Walleij: http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html this series tries to fix all of the issues in order to send v2 and give it a new try. Because I don't have to hardware to test my changes I send new cleanups first in staging to make easier to NeilBrown test it and get a feedback about them. Hope this helps. Thanks in advance. Best regards, Sergio Paracuellos Sergio Paracuellos (8): staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC staging: mt7621-gpio: avoid including 'gpio.h' staging: mt7621-gpio: make use of 'builtin_platform_driver' staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions staging: mt7621-gpio: add COMPILE_TEST staging: mt7621-gpio: add kerneldoc for state data containers staging: mt7621-gpio: avoid custom irq_domain for gpio staging: mt7621-gpio: implement high level and low level irqs drivers/staging/mt7621-gpio/Kconfig | 5 +- drivers/staging/mt7621-gpio/gpio-mt7621.c | 375 +++--- 2 files changed, 193 insertions(+), 187 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/8] staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions
When implementing custom irqchips it is important to also implement .irq_request_resources() and .irq_release_resources() and make sure these call gpiochip_[un]lock_as_irq(). Add those two for this driver. Also store struct device pointer in global state structure to be able to use 'dev_err' with the device from 'mediatek_request_resources' function. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 +++ 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 654c9eb..2a1c506 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -40,6 +40,7 @@ struct mtk_gc { }; struct mtk_data { + struct device *dev; void __iomem *gpio_membase; int gpio_irq; struct irq_domain *gpio_irq_domain; @@ -229,12 +230,42 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type) return 0; } +static int mediatek_irq_reqres(struct irq_data *d) +{ + struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; + struct mtk_gc *rg = &gpio_data->gc_map[bank]; + struct gpio_chip *gc = &rg->chip; + int ret; + + ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d)); + if (ret) { + dev_err(gpio_data->dev, "unable to lock HW IRQ %lu for IRQ\n", + irqd_to_hwirq(d)); + return -EINVAL; + } + + return 0; +} + +static void mediatek_irq_relres(struct irq_data *d) +{ + struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); + int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH; + struct mtk_gc *rg = &gpio_data->gc_map[bank]; + struct gpio_chip *gc = &rg->chip; + + gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d)); +} + static struct irq_chip mediatek_gpio_irq_chip = { - .name = "GPIO", - .irq_unmask = mediatek_gpio_irq_unmask, - .irq_mask = mediatek_gpio_irq_mask, - .irq_mask_ack = mediatek_gpio_irq_mask, - .irq_set_type = mediatek_gpio_irq_type, + .name = "GPIO", + .irq_unmask = mediatek_gpio_irq_unmask, + .irq_mask = mediatek_gpio_irq_mask, + .irq_mask_ack = mediatek_gpio_irq_mask, + .irq_set_type = mediatek_gpio_irq_type, + .irq_request_resources = mediatek_irq_reqres, + .irq_release_resources = mediatek_irq_relres, }; static int @@ -282,6 +313,7 @@ mediatek_gpio_probe(struct platform_device *pdev) dev_err(&pdev->dev, "irq_domain_add_linear failed\n"); } + gpio_data->dev = &pdev->dev; platform_set_drvdata(pdev, gpio_data); for_each_child_of_node(np, bank) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/8] staging: mt7621-gpio: avoid custom irq_domain for gpio
Instead of create a custom irq_domain for this chip, use 'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It is ok to call this function several times. You only have to mark the line with 'IRQF_SHARED' and then loop over the three banks until you find a hit. There were some problems with removing an irqchip like that but this driver is a bool so it might work just fine. After this changes the functions 'mediatek_gpio_to_irq' and 'to_mediatek_gpio' are not needed anymore and also the 'gpio_irq_domain' field from the state container. Instead of use the custom irq domain in the irq handler use the associated domain from the gpio_chip in 'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe' has been moved a it to the botton to have all the irq related functions together and avoid some forward declarations to resolve some symbols along the code. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/Kconfig | 2 +- drivers/staging/mt7621-gpio/gpio-mt7621.c | 137 +- 2 files changed, 58 insertions(+), 81 deletions(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index 835998a..b6a921a 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -2,6 +2,6 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST select GPIO_GENERIC - select ARCH_REQUIRE_GPIOLIB + select GPIOLIB_IRQCHIP help Say yes here to support the Mediatek SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 80e618f..5d082c8 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -54,23 +53,15 @@ struct mtk_gc { * @dev: device instance * @gpio_membase: memory base address * @gpio_irq: irq number from the device tree - * @gpio_irq_domain: irq domain for this chip * @gc_map: array of the gpio chips */ struct mtk_data { struct device *dev; void __iomem *gpio_membase; int gpio_irq; - struct irq_domain *gpio_irq_domain; struct mtk_gc gc_map[MTK_BANK_CNT]; }; -static inline struct mtk_gc * -to_mediatek_gpio(struct gpio_chip *chip) -{ - return container_of(chip, struct mtk_gc, chip); -} - static inline void mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) { @@ -89,63 +80,6 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset) return gc->read_reg(gpio_data->gpio_membase + offset); } -static int -mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) -{ - struct mtk_data *gpio_data = gpiochip_get_data(chip); - struct mtk_gc *rg = to_mediatek_gpio(chip); - - return irq_create_mapping(gpio_data->gpio_irq_domain, - pin + (rg->bank * MTK_BANK_WIDTH)); -} - -static int -mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank) -{ - struct mtk_data *gpio_data = dev_get_drvdata(&pdev->dev); - const __be32 *id = of_get_property(bank, "reg", NULL); - struct mtk_gc *rg; - int ret; - - if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) - return -EINVAL; - - rg = &gpio_data->gc_map[be32_to_cpu(*id)]; - memset(rg, 0, sizeof(*rg)); - - spin_lock_init(&rg->lock); - rg->bank = be32_to_cpu(*id); - - ret = bgpio_init(&rg->chip, &pdev->dev, 4, -gpio_data->gpio_membase + GPIO_REG_DATA(rg->bank), -gpio_data->gpio_membase + GPIO_REG_DSET(rg->bank), -gpio_data->gpio_membase + GPIO_REG_DCLR(rg->bank), -gpio_data->gpio_membase + GPIO_REG_CTRL(rg->bank), -gpio_data->gpio_membase + GPIO_REG_CTRL(rg->bank), -0); - if (ret) { - dev_err(&pdev->dev, "bgpio_init() failed\n"); - return ret; - } - - if (gpio_data->gpio_irq_domain) - rg->chip.to_irq = mediatek_gpio_to_irq; - - ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio_data); - if (ret < 0) { - dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n", - rg->chip.ngpio, ret); - return ret; - } - - /* set polarity to low for all gpios */ - mtk_gpio_w32(rg, GPIO_REG_POL(rg->bank), 0); - - dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio); - - return 0; -} - static void mediatek_gpio_irq_handler(struct irq_desc *desc) { @@ -163,7 +97,7 @@ mediatek_gpio_irq_handler(struct irq_desc *desc) pending = mtk_gpio_r32(rg, GPIO_REG_STAT(rg->bank)); for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) { - u32 map = irq_
[PATCH 6/8] staging: mt7621-gpio: add kerneldoc for state data containers
This commit adds kerneldoc for the two data containers in order to better understanding of its existence. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 2a1c506..80e618f 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -31,6 +31,14 @@ #define GPIO_REG_STAT(bank) (((bank) * GPIO_BANK_WIDE) + 0x90) #define GPIO_REG_EDGE(bank) (((bank) * GPIO_BANK_WIDE) + 0xA0) +/** + * struct mtk_gc - data for a single gpio-chip + * @chip: gpio chip instance + * @lock: spinlock to protect the chip + * @bank: gpio bank number for the chip + * @rising: mask for rising irqs + * @falling: mask for falling irqs + */ struct mtk_gc { struct gpio_chip chip; spinlock_t lock; @@ -39,6 +47,16 @@ struct mtk_gc { u32 falling; }; +/** + * struct mtk_data - state container for + * data of the platform driver. It is a + * single irq-chip but 3 separate gpio-chip. + * @dev: device instance + * @gpio_membase: memory base address + * @gpio_irq: irq number from the device tree + * @gpio_irq_domain: irq domain for this chip + * @gc_map: array of the gpio chips + */ struct mtk_data { struct device *dev; void __iomem *gpio_membase; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/8] staging: mt7621-gpio: make use of 'builtin_platform_driver'
This driver was being registered using 'module_platform_driver' but it is not a module at all. Instead of this use 'builtin_platform_driver' which seems to be the correct one. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 433b1e9..654c9eb 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -310,4 +310,4 @@ static struct platform_driver mediatek_gpio_driver = { }, }; -module_platform_driver(mediatek_gpio_driver); +builtin_platform_driver(mediatek_gpio_driver); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/8] staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
Gpio complexity is just masking the fact that offset is always 0..n and writes to bits 0..n of some memory address. Because of this whole thing can just me converted to use GPIO_GENERIC and avoid duplications of a lot of driver custom functions. So use bgpio_init instead of custom code adding GPIO_GENERIC dependency to the Kconfig file. Also to make easier using bgpio_init function offset for each gpio bank, enumeration where register were defined has been replaced in favour of some macros which handle each gpio offset taking into account the bank where are located. Because of this change write and read functions which are being used for remaining irq handling stuff have been updated also as well as its dependencies along the code. Signed-off-by: Sergio Paracuellos --- drivers/staging/mt7621-gpio/Kconfig | 1 + drivers/staging/mt7621-gpio/gpio-mt7621.c | 148 ++ 2 files changed, 47 insertions(+), 102 deletions(-) diff --git a/drivers/staging/mt7621-gpio/Kconfig b/drivers/staging/mt7621-gpio/Kconfig index c741ec3..f4453e8 100644 --- a/drivers/staging/mt7621-gpio/Kconfig +++ b/drivers/staging/mt7621-gpio/Kconfig @@ -1,6 +1,7 @@ config GPIO_MT7621 bool "Mediatek GPIO Support" depends on SOC_MT7620 || SOC_MT7621 + select GPIO_GENERIC select ARCH_REQUIRE_GPIOLIB help Say yes here to support the Mediatek SoC GPIO device diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 0c4fb4a..cc08505 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -19,19 +19,18 @@ #define MTK_BANK_WIDTH 32 #define PIN_MASK(nr) (1UL << ((nr % MTK_BANK_WIDTH))) -enum mediatek_gpio_reg { - GPIO_REG_CTRL = 0, - GPIO_REG_POL, - GPIO_REG_DATA, - GPIO_REG_DSET, - GPIO_REG_DCLR, - GPIO_REG_REDGE, - GPIO_REG_FEDGE, - GPIO_REG_HLVL, - GPIO_REG_LLVL, - GPIO_REG_STAT, - GPIO_REG_EDGE, -}; +#define GPIO_BANK_WIDE 0x04 +#define GPIO_REG_CTRL(bank) (((bank) * GPIO_BANK_WIDE) + 0x00) +#define GPIO_REG_POL(bank) (((bank) * GPIO_BANK_WIDE) + 0x10) +#define GPIO_REG_DATA(bank) (((bank) * GPIO_BANK_WIDE) + 0x20) +#define GPIO_REG_DSET(bank) (((bank) * GPIO_BANK_WIDE) + 0x30) +#define GPIO_REG_DCLR(bank) (((bank) * GPIO_BANK_WIDE) + 0x40) +#define GPIO_REG_REDGE(bank) (((bank) * GPIO_BANK_WIDE) + 0x50) +#define GPIO_REG_FEDGE(bank) (((bank) * GPIO_BANK_WIDE) + 0x60) +#define GPIO_REG_HLVL(bank) (((bank) * GPIO_BANK_WIDE) + 0x70) +#define GPIO_REG_LLVL(bank) (((bank) * GPIO_BANK_WIDE) + 0x80) +#define GPIO_REG_STAT(bank) (((bank) * GPIO_BANK_WIDE) + 0x90) +#define GPIO_REG_EDGE(bank) (((bank) * GPIO_BANK_WIDE) + 0xA0) struct mtk_gc { struct gpio_chip chip; @@ -55,80 +54,21 @@ to_mediatek_gpio(struct gpio_chip *chip) } static inline void -mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val) +mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) { - struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip); - u32 offset = (reg * 0x10) + (rg->bank * 0x4); + struct gpio_chip *gc = &rg->chip; + struct mtk_data *gpio_data = gpiochip_get_data(gc); - iowrite32(val, gpio_data->gpio_membase + offset); + gc->write_reg(gpio_data->gpio_membase + offset, val); } static inline u32 -mtk_gpio_r32(struct mtk_gc *rg, u8 reg) -{ - struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip); - u32 offset = (reg * 0x10) + (rg->bank * 0x4); - - return ioread32(gpio_data->gpio_membase + offset); -} - -static void -mediatek_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - - mtk_gpio_w32(rg, (value) ? GPIO_REG_DSET : GPIO_REG_DCLR, BIT(offset)); -} - -static int -mediatek_gpio_get(struct gpio_chip *chip, unsigned int offset) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - - return !!(mtk_gpio_r32(rg, GPIO_REG_DATA) & BIT(offset)); -} - -static int -mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) -{ - struct mtk_gc *rg = to_mediatek_gpio(chip); - unsigned long flags; - u32 t; - - spin_lock_irqsave(&rg->lock, flags); - t = mtk_gpio_r32(rg, GPIO_REG_CTRL); - t &= ~BIT(offset); - mtk_gpio_w32(rg, GPIO_REG_CTRL, t); - spin_unlock_irqrestore(&rg->lock, flags); - - return 0; -} - -static int -mediatek_gpio_direction_output(struct gpio_chip *chip, - unsigned int offset, int value) +mtk_gpio_r32(struct mtk_gc *rg, u32 offset) { - struct mtk_gc *rg = to_mediatek_gpio(chip); - unsigned long flags; - u32 t; - - spin_lock_irqsave(&rg->lock, flags); - t = mtk_gpio_r32(rg, GPIO_REG_CTRL); - t |= BIT(offset); - mtk_gpio_w32(rg, GPIO_REG_C
Re: [PATCH] staging: rts5208: add check on NULL before dereference
On Sat, Jun 9, 2018 at 7:58 PM, wrote: > On 2018-06-09 12:38, Anton Vasilyev wrote: >> >> If rtsx_probe fails to allocate dev->chip, then NULL pointer >> dereference occurs at rtsx_release_resources(). >> >> Patch adds checks chip on NULL before its dereference at >> rtsx_release_resources and passing with dereference inside >> rtsx_release_chip. >> >> Found by Linux Driver Verification project (linuxtesting.org). > I think you should bail out if dev->chip is null rather than adding > conditiinals. I'm wondering if it's false positive. At which circumstances that may happen? -- With Best Regards, Andy Shevchenko ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Dear Sir/Madam
Dear Sir/Madam, Good day, how are you doing? i hope you're okay today, I am a marketer and a consultant representing some private and large bulk investors based in the Gulf Region and Africa. They are seeking means of expanding and relocating business interest abroad in the following sectors like hotel/leisure, hospitality, real estate, five star malls or five star office complexes or any fast interest generating businesses. It will be my pleasure to talk with you if you have a solid background and idea of making good profit in any of the mentioned business sectors or any other viable business in your Country, Please write me for possible business Co-operation. More so, we are ready to facilitate and fund any business that is capable of generating 3-5% annual return on investment (AROI) Joint Venture partnership and hard loan funding can also be considered. I am available to discuss this proposal with you and to answer any questions you may have in regard to this investment. Thanks for your kind understanding. Contact me in my private email: ( stephenknight...@yahoo.com ) Mr. Knight Stephen ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: rts5208: add check on NULL before dereference
On 2018-06-09 12:38, Anton Vasilyev wrote: If rtsx_probe fails to allocate dev->chip, then NULL pointer dereference occurs at rtsx_release_resources(). Patch adds checks chip on NULL before its dereference at rtsx_release_resources and passing with dereference inside rtsx_release_chip. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- drivers/staging/rts5208/rtsx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 70e0b8623110..952dd0d580cf 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -623,12 +623,13 @@ static void rtsx_release_resources(struct rtsx_dev *dev) I think you should bail out if dev->chip is null rather than adding conditiinals. if (dev->irq > 0) free_irq(dev->irq, (void *)dev); - if (dev->chip->msi_en) + if (dev->chip && dev->chip->msi_en) pci_disable_msi(dev->pci); if (dev->remap_addr) iounmap(dev->remap_addr); + if (dev->chip) + rtsx_release_chip(dev->chip); - rtsx_release_chip(dev->chip); kfree(dev->chip); } ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rts5208: add check on NULL before dereference
If rtsx_probe fails to allocate dev->chip, then NULL pointer dereference occurs at rtsx_release_resources(). Patch adds checks chip on NULL before its dereference at rtsx_release_resources and passing with dereference inside rtsx_release_chip. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- drivers/staging/rts5208/rtsx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 70e0b8623110..952dd0d580cf 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -623,12 +623,13 @@ static void rtsx_release_resources(struct rtsx_dev *dev) if (dev->irq > 0) free_irq(dev->irq, (void *)dev); - if (dev->chip->msi_en) + if (dev->chip && dev->chip->msi_en) pci_disable_msi(dev->pci); if (dev->remap_addr) iounmap(dev->remap_addr); + if (dev->chip) + rtsx_release_chip(dev->chip); - rtsx_release_chip(dev->chip); kfree(dev->chip); } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] staging: pi433: add mutex fixing concurrency issues.
> > After discussing this issue on the kernel newbies mailing list[0] we > > came to the conclusion that it is very unlikely that pi433_release and > > pi433_ioctl would ever run concurrently in this case. This is also > > true for read/write. Unless one can find a situation where this might > > happen, I think we should not add this potentially unnecessary lock. > > Yes, so we should than drop the TODO comment on this issue? Well, after taking a closer look it appears that I misunderstood the TODO. What this TODO means is that we might run into a whole world of issues if the device is _removed_ while we're running ioctl or I guess pretty much any function that accesses the struct pi433_device. So the issue doesn't come from pi433_release and pi433_ioctl running concurrently, but rather pi433_ioctl and pi433_remove. Whether this situation is likely to happen or not is another question which I am currently taking a look at. Also, during my work on this driver I found what I'd consider as another issue: In pi433_ioctl we execute case PI433_IOC_WR_TX_CFG: if (copy_from_user(&instance->tx_cfg, argp, sizeof(struct pi433_tx_cfg))) return -EFAULT; break; without any synchronization. What if two ioctl syscalls are called with command PI433_IOC_WR_TX_CFG ? instance->tx_cfg might get corrupt unless copy_from_user provides some kind of synchronization, right ? I have prepared a patch but couldn't test it because I don't have test devices. -- Hugo Lefeuvre (hle)|www.owl.eu.com 4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: Improved readability of function comedi_nsamples_left.
On Sat, Jun 09, 2018 at 04:23:21PM +0200, Chris Opperman wrote: > Signed-off-by: Chris Opperman > --- > drivers/staging/comedi/drivers.c | 29 ++--- > 1 file changed, 14 insertions(+), 15 deletions(-) I can not take patches without any changelog text at all :( ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: mt7621-pci: Fix coding style error
This patch removes space after * to fix the following checkpatch error: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Abdun Nihaal --- drivers/staging/mt7621-pci/pci-mt7621.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 17f2105ec698..0543ff7d7f40 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -184,7 +184,7 @@ static int pcie_link_status = 0; #define PCI_ACCESS_WRITE_4 5 static int config_access(unsigned char access_type, struct pci_bus *bus, - unsigned int devfn, unsigned int where, u32 * data) + unsigned int devfn, unsigned int where, u32 *data) { unsigned int slot = PCI_SLOT(devfn); u8 func = PCI_FUNC(devfn); @@ -225,19 +225,19 @@ static int config_access(unsigned char access_type, struct pci_bus *bus, } static int -read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 * val) +read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val) { return config_access(PCI_ACCESS_READ_1, bus, devfn, (unsigned int)where, (u32 *)val); } static int -read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 * val) +read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val) { return config_access(PCI_ACCESS_READ_2, bus, devfn, (unsigned int)where, (u32 *)val); } static int -read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * val) +read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val) { return config_access(PCI_ACCESS_READ_4, bus, devfn, (unsigned int)where, (u32 *)val); } @@ -270,7 +270,7 @@ write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) } static int -pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 * val) +pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { switch (size) { case 1: -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: comedi: Improved readability of function comedi_nsamples_left.
Signed-off-by: Chris Opperman --- drivers/staging/comedi/drivers.c | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9d73347..3207ae2 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -468,26 +468,25 @@ EXPORT_SYMBOL_GPL(comedi_nscans_left); * Returns the number of samples remaining to complete the command, or the * specified expected number of samples (@nsamples), whichever is fewer. */ -unsigned int comedi_nsamples_left(struct comedi_subdevice *s, - unsigned int nsamples) +u32 comedi_nsamples_left(struct comedi_subdevice *s, u32 nsamples) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; + u32 scans_left; + u64 samples_left; - if (cmd->stop_src == TRIG_COUNT) { - unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); - unsigned int scan_pos = - comedi_bytes_to_samples(s, async->scan_progress); - unsigned long long samples_left = 0; - - if (scans_left) { - samples_left = ((unsigned long long)scans_left * - cmd->scan_end_arg) - scan_pos; - } + if (cmd->stop_src != TRIG_COUNT) + return nsamples; - if (samples_left < nsamples) - nsamples = samples_left; - } + scans_left = __comedi_nscans_left(s, cmd->stop_arg); + if (!scans_left) + return 0; + + samples_left = ((u64)scans_left * cmd->scan_end_arg) - + comedi_bytes_to_samples(s, async->scan_progress); + + if (samples_left < nsamples) + return samples_left; return nsamples; } EXPORT_SYMBOL_GPL(comedi_nsamples_left); -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: shortened a long line
Hi Joe, Thank you for the feedback! I understand better now and will resend the patch. Regards, Chris Opperman ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: shortened a long line
On Sat, 2018-06-09 at 12:54 +0200, Chris Opperman wrote: > Shortened a long line to improve readability in > drivers/staging/comedi/drivers.c Hi Chris. Look at the whole function and see if you can find a better way to write it instead of merely doing what a brainless tool like checkpatch asks. > diff --git a/drivers/staging/comedi/drivers.c > b/drivers/staging/comedi/drivers.c [] > @@ -475,7 +475,8 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice > *s, > struct comedi_cmd *cmd = &async->cmd; > > if (cmd->stop_src == TRIG_COUNT) { > - unsigned int scans_left = __comedi_nscans_left(s, > cmd->stop_arg); > + unsigned int scans_left = > + __comedi_nscans_left(s, cmd->stop_arg); > unsigned int scan_pos = > comedi_bytes_to_samples(s, async->scan_progress); > unsigned long long samples_left = 0; For instance, this is the existing function: unsigned int comedi_nsamples_left(struct comedi_subdevice *s, unsigned int nsamples) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; if (cmd->stop_src == TRIG_COUNT) { unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); unsigned int scan_pos = comedi_bytes_to_samples(s, async->scan_progress); unsigned long long samples_left = 0; if (scans_left) { samples_left = ((unsigned long long)scans_left * cmd->scan_end_arg) - scan_pos; } if (samples_left < nsamples) nsamples = samples_left; } return nsamples; } EXPORT_SYMBOL_GPL(comedi_nsamples_left); By using multiple returns and removing indentation, this could become something that doesn't fits neatly on 80 columns. It's the same number of vertical lines too. unsigned int comedi_nsamples_left(struct comedi_subdevice *s, unsigned int nsamples) { struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int scans_left; u64 samples_left; if (cmd->stop_src != TRIG_COUNT) return nsamples; scans_left = __comedi_nscans_left(s, cmd->stop_arg); if (scans_left == 0) return 0; samples_left = (u64)scans_left * cmd->scan_end_arg - comedi_bytes_to_samples(s, s->async->scan_progress); if (samples_left < nsamples) return samples_left; return nsamples; } EXPORT_SYMBOL_GPL(comedi_nsamples_left); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: comedi: shortened a long line
Shortened a long line to improve readability in drivers/staging/comedi/drivers.c Signed-off-by: Chris Opperman --- drivers/staging/comedi/drivers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 9d73347..90ee974 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -475,7 +475,8 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s, struct comedi_cmd *cmd = &async->cmd; if (cmd->stop_src == TRIG_COUNT) { - unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); + unsigned int scans_left = + __comedi_nscans_left(s, cmd->stop_arg); unsigned int scan_pos = comedi_bytes_to_samples(s, async->scan_progress); unsigned long long samples_left = 0; -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Fixed coding style problems.
Thanks for the feedback! I will retry the submission. Regards, Chris ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] staging: pi433: add mutex fixing concurrency issues.
On Thu, Jun 07, 2018 at 08:45:03AM -0400, Hugo Lefeuvre wrote: > After discussing this issue on the kernel newbies mailing list[0] we > came to the conclusion that it is very unlikely that pi433_release and > pi433_ioctl would ever run concurrently in this case. This is also > true for read/write. Unless one can find a situation where this might > happen, I think we should not add this potentially unnecessary lock. Yes, so we should than drop the TODO comment on this issue? -- Valentin ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 2/2] staging: rtl8192e: fix line over 80 characters
On Sat, 2018-06-09 at 15:07 +0900, thtlwlsmsgk...@gmail.com wrote: > *fix checkpatch.pl warnings: > WARNING: line over 80 characters Consider using a temporary for these ieee->current_network. dereferences. > diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c > b/drivers/staging/rtl8192e/rtllib_softmac.c [] > @@ -2596,7 +2596,8 @@ static void rtllib_start_ibss_wq(void *data) > > if (ieee->current_network.ssid_len == 0) { > strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); > - ieee->current_network.ssid_len = > strlen(RTLLIB_DEFAULT_TX_ESSID); > + ieee->current_network.ssid_len = > + strlen(RTLLIB_DEFAULT_TX_ESSID); > ieee->ssid_set = 1; > } For instance: Adding a temporary for all ieee->current_network deferences actually reduces line count in this file. --- drivers/staging/rtl8192e/rtllib_softmac.c | 281 +++--- 1 file changed, 139 insertions(+), 142 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 919231fec09c..5733a1ab59d1 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -157,10 +157,10 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee) u16 i; u8 QueryRate = 0; u8 BasicRate; + struct rtllib_network *cur_net = &ieee->current_network; - - for (i = 0; i < ieee->current_network.rates_len; i++) { - BasicRate = ieee->current_network.rates[i]&0x7F; + for (i = 0; i < cur_net->rates_len; i++) { + BasicRate = cur_net->rates[i] & 0x7F; if (!rtllib_is_cck_rate(BasicRate)) { if (QueryRate == 0) { QueryRate = BasicRate; @@ -338,8 +338,9 @@ static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) u8 *tag; struct sk_buff *skb; struct rtllib_probe_request *req; + struct rtllib_network *cur_net = &ieee->current_network; - len = ieee->current_network.ssid_len; + len = cur_net->ssid_len; rate_len = rtllib_MFIE_rate_len(ieee); @@ -363,7 +364,7 @@ static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee) *tag++ = MFIE_TYPE_SSID; *tag++ = len; - memcpy(tag, ieee->current_network.ssid, len); + memcpy(tag, cur_net->ssid, len); tag += len; rtllib_MFIE_Brate(ieee, &tag); @@ -377,6 +378,7 @@ static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee); static void rtllib_send_beacon(struct rtllib_device *ieee) { struct sk_buff *skb; + struct rtllib_network *cur_net = &ieee->current_network; if (!ieee->ieee_up) return; @@ -389,7 +391,7 @@ static void rtllib_send_beacon(struct rtllib_device *ieee) if (ieee->beacon_txing && ieee->ieee_up) mod_timer(&ieee->beacon_timer, jiffies + - (msecs_to_jiffies(ieee->current_network.beacon_interval - 5))); + (msecs_to_jiffies(cur_net->beacon_interval - 5))); } @@ -578,7 +580,8 @@ static void rtllib_softmac_scan_wq(void *data) { struct rtllib_device *ieee = container_of_dwork_rsl(data, struct rtllib_device, softmac_scan_wq); - u8 last_channel = ieee->current_network.channel; + struct rtllib_network *cur_net = &ieee->current_network; + u8 last_channel = cur_net->channel; rtllib_update_active_chan_map(ieee); @@ -597,22 +600,20 @@ static void rtllib_softmac_scan_wq(void *data) } do { - ieee->current_network.channel = - (ieee->current_network.channel + 1) % - MAX_CHANNEL_NUMBER; + cur_net->channel = (cur_net->channel + 1) % MAX_CHANNEL_NUMBER; if (ieee->scan_watch_dog++ > MAX_CHANNEL_NUMBER) { - if (!ieee->active_channel_map[ieee->current_network.channel]) - ieee->current_network.channel = 6; + if (!ieee->active_channel_map[cur_net->channel]) + cur_net->channel = 6; goto out; /* no good chans */ } - } while (!ieee->active_channel_map[ieee->current_network.channel]); + } while (!ieee->active_channel_map[cur_net->channel]); if (ieee->scanning_continue == 0) goto out; - ieee->set_chan(ieee->dev, ieee->current_network.channel); + ieee->set_chan(ieee->dev, cur_net->channel); - if (ieee->active_channel_map[ieee->current_network.channel] == 1) + if (ieee->active_channel_map[cur_net->channel] == 1) rtllib_send_probe_requests(ieee, 0); schedule_delayed_work(&ieee->softmac_scan_wq, @@ -624,7 +625,7 @@ static