From 0d9ffc979f761c091a23020692b3502fa776eac0 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghiu Date: Mon, 25 Mar 2013 15:46:49 +0200 Subject: sound: oss: uart401: Used kmemdup instead of kmalloc and memcpy Used kmemdup instead of replicating it's behaviour with kmalloc followed by memcpy. Patch found using coccinelle. Signed-off-by: Alexandru Gheorghiu Signed-off-by: Takashi Iwai --- sound/oss/uart401.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sound/oss') diff --git a/sound/oss/uart401.c b/sound/oss/uart401.c index 8e514a676a0d..5433c6f5eca2 100644 --- a/sound/oss/uart401.c +++ b/sound/oss/uart401.c @@ -352,23 +352,26 @@ int probe_uart401(struct address_info *hw_config, struct module *owner) goto cleanup_irq; } conf_printf(name, hw_config); - midi_devs[devc->my_dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL); + midi_devs[devc->my_dev] = kmemdup(&uart401_operations, + sizeof(struct midi_operations), + GFP_KERNEL); if (!midi_devs[devc->my_dev]) { printk(KERN_ERR "uart401: Failed to allocate memory\n"); goto cleanup_unload_mididev; } - memcpy(midi_devs[devc->my_dev], &uart401_operations, sizeof(struct midi_operations)); if (owner) midi_devs[devc->my_dev]->owner = owner; midi_devs[devc->my_dev]->devc = devc; - midi_devs[devc->my_dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL); + midi_devs[devc->my_dev]->converter = kmemdup(&std_midi_synth, + sizeof(struct synth_operations), + GFP_KERNEL); + if (!midi_devs[devc->my_dev]->converter) { printk(KERN_WARNING "uart401: Failed to allocate memory\n"); goto cleanup_midi_devs; } - memcpy(midi_devs[devc->my_dev]->converter, &std_midi_synth, sizeof(struct synth_operations)); strcpy(midi_devs[devc->my_dev]->info.name, name); midi_devs[devc->my_dev]->converter->id = "UART401"; midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; -- cgit v1.2.3-59-g8ed1b From b8e63df919d75ef4ecafd66b5123a798b18cc0e7 Mon Sep 17 00:00:00 2001 From: Alexandru Gheorghiu Date: Mon, 25 Mar 2013 15:50:34 +0200 Subject: sound: oss: sb_common: Used kmemdup instead of kmalloc and memcpy Used kmemdup instead of replicating it's behaviour with kmalloc followed by memcpy. Patch found using coccinelle. Signed-off-by: Alexandru Gheorghiu Signed-off-by: Takashi Iwai --- sound/oss/sb_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound/oss') diff --git a/sound/oss/sb_common.c b/sound/oss/sb_common.c index 7d42c5418d1b..851a1da46be1 100644 --- a/sound/oss/sb_common.c +++ b/sound/oss/sb_common.c @@ -626,13 +626,12 @@ int sb_dsp_detect(struct address_info *hw_config, int pci, int pciio, struct sb_ */ - detected_devc = kmalloc(sizeof(sb_devc), GFP_KERNEL); + detected_devc = kmemdup(devc, sizeof(sb_devc), GFP_KERNEL); if (detected_devc == NULL) { printk(KERN_ERR "sb: Can't allocate memory for device information\n"); return 0; } - memcpy(detected_devc, devc, sizeof(sb_devc)); MDB(printk(KERN_INFO "SB %d.%02d detected OK (%x)\n", devc->major, devc->minor, hw_config->io_base)); return 1; } -- cgit v1.2.3-59-g8ed1b From 4b417cf01657c8dcd03abb0aa49f3825fede6539 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 25 Apr 2013 19:28:50 +0200 Subject: sound: oss/dmabuf: use dma_map_single The virt_to_bus/bus_to_virt functions have been deprecated for as long as I can remember, and they are used in very few remaining instances, usually in obscure ISA device drivers. The OSS sound drivers are the only ones that are still used on the ARM architecture, and only on some of the earliest StrongARM machines. The problem for converting the OSS subsystem to use dma_map_single instead is that the caller of virt_to_bus does not have a device pointer, since the subsystem has never been ported to use the common device infrastructure. Signed-off-by: Arnd Bergmann Signed-off-by: Takashi Iwai --- sound/oss/dmabuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/oss') diff --git a/sound/oss/dmabuf.c b/sound/oss/dmabuf.c index bcc3e8e07122..a59c88818f48 100644 --- a/sound/oss/dmabuf.c +++ b/sound/oss/dmabuf.c @@ -114,7 +114,7 @@ static int sound_alloc_dmap(struct dma_buffparms *dmap) } } dmap->raw_buf = start_addr; - dmap->raw_buf_phys = virt_to_bus(start_addr); + dmap->raw_buf_phys = dma_map_single(NULL, start_addr, dmap->buffsize, DMA_BIDIRECTIONAL); for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++) SetPageReserved(page); @@ -139,6 +139,7 @@ static void sound_free_dmap(struct dma_buffparms *dmap) for (page = virt_to_page(start_addr); page <= virt_to_page(end_addr); page++) ClearPageReserved(page); + dma_unmap_single(NULL, dmap->raw_buf_phys, dmap->buffsize, DMA_BIDIRECTIONAL); free_pages((unsigned long) dmap->raw_buf, sz); dmap->raw_buf = NULL; } -- cgit v1.2.3-59-g8ed1b