From 57a4a3d7f7568c487d5db3e26540bff958000255 Mon Sep 17 00:00:00 2001 From: Himangi Saraogi Date: Tue, 27 May 2014 03:02:07 +0530 Subject: display7seg: Introduce the use of the managed version of kzalloc This patch moves data allocated using kzalloc to managed data allocated using devm_kzalloc and cleans now unnecessary kfrees in probe and remove functions. The header file is added to make the devm function explicitly available. The following Coccinelle semantic patch was used for making a part of the change: @platform@ identifier p, probefn, removefn; @@ struct platform_driver p = { .probe = probefn, .remove = removefn, }; @prb@ identifier platform.probefn, pdev; expression e, e1, e2; @@ probefn(struct platform_device *pdev, ...) { <+... - e = kzalloc(e1, e2) + e = devm_kzalloc(&pdev->dev, e1, e2) ... ?-kfree(e); ...+> } @rem depends on prb@ identifier platform.removefn; expression e; @@ removefn(...) { <... - kfree(e); ...> } Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall Acked-by: Sam Ravnborg Signed-off-by: David S. Miller --- drivers/sbus/char/display7seg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index 7c71e7b4feb..b48899ce850 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c @@ -4,6 +4,7 @@ * Copyright (c) 2000 Eric Brower (ebrower@usa.net) */ +#include #include #include #include @@ -180,7 +181,7 @@ static int d7s_probe(struct platform_device *op) if (d7s_device) goto out; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); err = -ENOMEM; if (!p) goto out; @@ -231,7 +232,6 @@ out_iounmap: of_iounmap(&op->resource[0], p->regs, sizeof(u8)); out_free: - kfree(p); goto out; } @@ -251,7 +251,6 @@ static int d7s_remove(struct platform_device *op) misc_deregister(&d7s_miscdev); of_iounmap(&op->resource[0], p->regs, sizeof(u8)); - kfree(p); return 0; } -- cgit v1.2.3-70-g09d2 From 54dcf0ceb8a21a898cd436617483e5646f2edcc6 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Thu, 19 Jun 2014 14:31:52 +0200 Subject: drivers/sbus/char: Micro-optimization in display7seg.c Flipping a bit doesn't need four lines of code; and gcc seems to actually generate two branches. Signed-off-by: Rasmus Villemoes Signed-off-by: David S. Miller --- drivers/sbus/char/display7seg.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index b48899ce850..2b0ce7c350e 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c @@ -144,10 +144,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case D7SIOCTM: /* toggle device mode-- flip display orientation */ - if (regs & D7S_FLIP) - regs &= ~D7S_FLIP; - else - regs |= D7S_FLIP; + regs ^= D7S_FLIP; writeb(regs, p->regs); break; } -- cgit v1.2.3-70-g09d2 From d650471a399e65e423967e0b7692c86228211522 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Jul 2014 13:38:58 +0200 Subject: sparcspkr: use sbus_*() primitives for IO The memory are mapped using of_ioremap() which is an indication this is sbus memory. Shift all uses of inb/outb to the sbus variants. The inb/outb methods uses ASI_PHYS_BYPASS_EC_E_L, whereas sbus_ variants uses ASI_PHYS_BYPASS_EC_E. The difference is if the reads/writes are done in native or little endian. But for byte reads/writes there is no difference so this does not matter for inb/outb - and this driver only uses the byte variants. Signed-off-by: Sam Ravnborg Signed-off-by: David S. Miller --- drivers/input/misc/sparcspkr.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c index 65fd3150919..179ff1cd6f6 100644 --- a/drivers/input/misc/sparcspkr.c +++ b/drivers/input/misc/sparcspkr.c @@ -86,13 +86,13 @@ static int bbc_spkr_event(struct input_dev *dev, unsigned int type, unsigned int spin_lock_irqsave(&state->lock, flags); if (count) { - outb(0x01, info->regs + 0); - outb(0x00, info->regs + 2); - outb((count >> 16) & 0xff, info->regs + 3); - outb((count >> 8) & 0xff, info->regs + 4); - outb(0x00, info->regs + 5); + sbus_writeb(0x01, info->regs + 0); + sbus_writeb(0x00, info->regs + 2); + sbus_writeb((count >> 16) & 0xff, info->regs + 3); + sbus_writeb((count >> 8) & 0xff, info->regs + 4); + sbus_writeb(0x00, info->regs + 5); } else { - outb(0x00, info->regs + 0); + sbus_writeb(0x00, info->regs + 0); } spin_unlock_irqrestore(&state->lock, flags); @@ -123,15 +123,15 @@ static int grover_spkr_event(struct input_dev *dev, unsigned int type, unsigned if (count) { /* enable counter 2 */ - outb(inb(info->enable_reg) | 3, info->enable_reg); + sbus_writeb(sbus_readb(info->enable_reg) | 3, info->enable_reg); /* set command for counter 2, 2 byte write */ - outb(0xB6, info->freq_regs + 1); + sbus_writeb(0xB6, info->freq_regs + 1); /* select desired HZ */ - outb(count & 0xff, info->freq_regs + 0); - outb((count >> 8) & 0xff, info->freq_regs + 0); + sbus_writeb(count & 0xff, info->freq_regs + 0); + sbus_writeb((count >> 8) & 0xff, info->freq_regs + 0); } else { /* disable counter 2 */ - outb(inb_p(info->enable_reg) & 0xFC, info->enable_reg); + sbus_writeb(sbus_readb(info->enable_reg) & 0xFC, info->enable_reg); } spin_unlock_irqrestore(&state->lock, flags); -- cgit v1.2.3-70-g09d2 From 5cdceab3d5e02eb69ea0f5d8fa9181800baf6f77 Mon Sep 17 00:00:00 2001 From: Christopher Alexander Tobias Schulze Date: Sun, 3 Aug 2014 15:44:52 +0200 Subject: bbc-i2c: Fix BBC I2C envctrl on SunBlade 2000 Fix regression in bbc i2c temperature and fan control on some Sun systems that causes the driver to refuse to load due to the bbc_i2c_bussel resource not being present on the (second) i2c bus where the temperature sensors and fan control are located. (The check for the number of resources was removed when the driver was ported to a pure OF driver in mid 2008.) Signed-off-by: Christopher Alexander Tobias Schulze Signed-off-by: David S. Miller --- drivers/sbus/char/bbc_envctrl.c | 6 ++++++ drivers/sbus/char/bbc_i2c.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index 160e7510aca..0787b975616 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -452,6 +452,9 @@ static void attach_one_temp(struct bbc_i2c_bus *bp, struct platform_device *op, if (!tp) return; + INIT_LIST_HEAD(&tp->bp_list); + INIT_LIST_HEAD(&tp->glob_list); + tp->client = bbc_i2c_attach(bp, op); if (!tp->client) { kfree(tp); @@ -497,6 +500,9 @@ static void attach_one_fan(struct bbc_i2c_bus *bp, struct platform_device *op, if (!fp) return; + INIT_LIST_HEAD(&fp->bp_list); + INIT_LIST_HEAD(&fp->glob_list); + fp->client = bbc_i2c_attach(bp, op); if (!fp->client) { kfree(fp); diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c index c7763e482eb..812b5f0361b 100644 --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c @@ -300,13 +300,18 @@ static struct bbc_i2c_bus * attach_one_i2c(struct platform_device *op, int index if (!bp) return NULL; + INIT_LIST_HEAD(&bp->temps); + INIT_LIST_HEAD(&bp->fans); + bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs"); if (!bp->i2c_control_regs) goto fail; - bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel"); - if (!bp->i2c_bussel_reg) - goto fail; + if (op->num_resources == 2) { + bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel"); + if (!bp->i2c_bussel_reg) + goto fail; + } bp->waiting = 0; init_waitqueue_head(&bp->wq); -- cgit v1.2.3-70-g09d2 From fe418231b195c205701c0cc550a03f6c9758fd9e Mon Sep 17 00:00:00 2001 From: Christopher Alexander Tobias Schulze Date: Sun, 3 Aug 2014 16:01:53 +0200 Subject: sunsab: Fix detection of BREAK on sunsab serial console Fix detection of BREAK on sunsab serial console: BREAK detection was only performed when there were also serial characters received simultaneously. To handle all BREAKs correctly, the check for BREAK and the corresponding call to uart_handle_break() must also be done if count == 0, therefore duplicate this code fragment and pull it out of the loop over the received characters. Patch applies to 3.16-rc6. Signed-off-by: Christopher Alexander Tobias Schulze Signed-off-by: David S. Miller --- drivers/tty/serial/sunsab.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 2f57df9a71d..a1e09c0d46f 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c @@ -157,6 +157,15 @@ receive_chars(struct uart_sunsab_port *up, (up->port.line == up->port.cons->index)) saw_console_brk = 1; + if (count == 0) { + if (unlikely(stat->sreg.isr1 & SAB82532_ISR1_BRK)) { + stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR | + SAB82532_ISR0_FERR); + up->port.icount.brk++; + uart_handle_break(&up->port); + } + } + for (i = 0; i < count; i++) { unsigned char ch = buf[i], flag; -- cgit v1.2.3-70-g09d2