diff options
author | Shawn Bohrer <shawn.bohrer@gmail.com> | 2009-11-15 22:18:01 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 12:21:47 -0800 |
commit | 7e4d5c13d8048ed37f94dbcdf54228b404a775c7 (patch) | |
tree | 02701e4386ee211cc2130c593ab3039e4a4e97c2 /drivers/staging/line6 | |
parent | c0e6e7c1b2409fd4968b256ae1d979e6df14b3f1 (diff) |
staging: line6: Convert simple_strtoul to strict_strtoul in pod.c
Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/line6')
-rw-r--r-- | drivers/staging/line6/pod.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index 5f5fc025cb79..685c529950eb 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -422,13 +422,21 @@ void pod_transmit_parameter(struct usb_line6_pod *pod, int param, int value) /* Resolve value to memory location. */ -static void pod_resolve(const char *buf, short block0, short block1, unsigned char *location) +static int pod_resolve(const char *buf, short block0, short block1, unsigned char *location) { - int value = simple_strtoul(buf, NULL, 10); - short block = (value < 0x40) ? block0 : block1; + unsigned long value; + short block; + int ret; + + ret = strict_strtoul(buf, 10, &value); + if (ret) + return ret; + + block = (value < 0x40) ? block0 : block1; value &= 0x3f; location[0] = block >> 7; location[1] = value | (block & 0x7f); + return 0; } /* @@ -438,14 +446,20 @@ static ssize_t pod_send_store_command(struct device *dev, const char *buf, size_ { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); - + int ret; int size = 3 + sizeof(pod->prog_data_buf); char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_STORE, size); + if (!sysex) return 0; sysex[SYSEX_DATA_OFS] = 5; /* see pod_dump() */ - pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1); + ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1); + if (ret) { + kfree(sysex); + return ret; + } + memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf, sizeof(pod->prog_data_buf)); line6_send_sysex_message(&pod->line6, sysex, size); @@ -461,13 +475,18 @@ static ssize_t pod_send_retrieve_command(struct device *dev, const char *buf, si { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); + int ret; int size = 4; char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_DUMPMEM, size); if (!sysex) return 0; - pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS); + ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS); + if (ret) { + kfree(sysex); + return ret; + } sysex[SYSEX_DATA_OFS + 2] = 0; sysex[SYSEX_DATA_OFS + 3] = 0; line6_dump_started(&pod->dumpreq, POD_DUMP_MEMORY); @@ -526,7 +545,13 @@ static ssize_t pod_set_channel(struct device *dev, { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); - int value = simple_strtoul(buf, NULL, 10); + unsigned long value; + int ret; + + ret = strict_strtoul(buf, 10, &value); + if (ret) + return ret; + pod_send_channel(pod, value); return count; } @@ -645,6 +670,8 @@ static ssize_t pod_set_system_param(struct usb_line6_pod *pod, const char *buf, char *sysex; static const int size = 5; unsigned short value; + unsigned long result; + int ret; if (((pod->prog_data.control[POD_tuner] & 0x40) == 0) && tuner) return -EINVAL; @@ -653,7 +680,12 @@ static ssize_t pod_set_system_param(struct usb_line6_pod *pod, const char *buf, sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size); if (!sysex) return 0; - value = simple_strtoul(buf, NULL, 10) & mask; + + ret = strict_strtoul(buf, 10, &result); + if (ret) + return ret; + + value = result & mask; sysex[SYSEX_DATA_OFS] = code; sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f; sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f; @@ -812,7 +844,13 @@ static ssize_t pod_set_midi_postprocess(struct device *dev, { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); - int value = simple_strtoul(buf, NULL, 10); + unsigned long value; + int ret; + + ret = strict_strtoul(buf, 10, &value); + if (ret) + return ret; + pod->midi_postprocess = value ? 1 : 0; return count; } |