diff options
author | Thomas Meyer <thomas@m3y3r.de> | 2011-11-17 17:12:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-24 18:08:01 -0500 |
commit | 0ceaec188e7784c7f9ab5fca110fecb790837dbc (patch) | |
tree | 4bc85ca8ae3b991cbcddb9099d690a8c797d049b /drivers/media/video/cx25821 | |
parent | 82c80f8371835f861bdbe50eefa5f49888d23210 (diff) |
[media] cx25821: Use kmemdup rather than duplicating its implementation
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx25821')
-rw-r--r-- | drivers/media/video/cx25821/cx25821-audio-upstream.c | 11 | ||||
-rw-r--r-- | drivers/media/video/cx25821/cx25821-video-upstream-ch2.c | 12 | ||||
-rw-r--r-- | drivers/media/video/cx25821/cx25821-video-upstream.c | 10 |
3 files changed, 12 insertions, 21 deletions
diff --git a/drivers/media/video/cx25821/cx25821-audio-upstream.c b/drivers/media/video/cx25821/cx25821-audio-upstream.c index 4dc2a241335c..20c7ca3351a8 100644 --- a/drivers/media/video/cx25821/cx25821-audio-upstream.c +++ b/drivers/media/video/cx25821/cx25821-audio-upstream.c | |||
@@ -733,25 +733,22 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select) | |||
733 | 733 | ||
734 | if (dev->input_audiofilename) { | 734 | if (dev->input_audiofilename) { |
735 | str_length = strlen(dev->input_audiofilename); | 735 | str_length = strlen(dev->input_audiofilename); |
736 | dev->_audiofilename = kmalloc(str_length + 1, GFP_KERNEL); | 736 | dev->_audiofilename = kmemdup(dev->input_audiofilename, |
737 | str_length + 1, GFP_KERNEL); | ||
737 | 738 | ||
738 | if (!dev->_audiofilename) | 739 | if (!dev->_audiofilename) |
739 | goto error; | 740 | goto error; |
740 | 741 | ||
741 | memcpy(dev->_audiofilename, dev->input_audiofilename, | ||
742 | str_length + 1); | ||
743 | |||
744 | /* Default if filename is empty string */ | 742 | /* Default if filename is empty string */ |
745 | if (strcmp(dev->input_audiofilename, "") == 0) | 743 | if (strcmp(dev->input_audiofilename, "") == 0) |
746 | dev->_audiofilename = "/root/audioGOOD.wav"; | 744 | dev->_audiofilename = "/root/audioGOOD.wav"; |
747 | } else { | 745 | } else { |
748 | str_length = strlen(_defaultAudioName); | 746 | str_length = strlen(_defaultAudioName); |
749 | dev->_audiofilename = kmalloc(str_length + 1, GFP_KERNEL); | 747 | dev->_audiofilename = kmemdup(_defaultAudioName, |
748 | str_length + 1, GFP_KERNEL); | ||
750 | 749 | ||
751 | if (!dev->_audiofilename) | 750 | if (!dev->_audiofilename) |
752 | goto error; | 751 | goto error; |
753 | |||
754 | memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1); | ||
755 | } | 752 | } |
756 | 753 | ||
757 | retval = cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, | 754 | retval = cx25821_sram_channel_setup_upstream_audio(dev, sram_ch, |
diff --git a/drivers/media/video/cx25821/cx25821-video-upstream-ch2.c b/drivers/media/video/cx25821/cx25821-video-upstream-ch2.c index 6401ce8be0f5..5a157cf4a95e 100644 --- a/drivers/media/video/cx25821/cx25821-video-upstream-ch2.c +++ b/drivers/media/video/cx25821/cx25821-video-upstream-ch2.c | |||
@@ -747,22 +747,18 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, | |||
747 | 747 | ||
748 | if (dev->input_filename_ch2) { | 748 | if (dev->input_filename_ch2) { |
749 | str_length = strlen(dev->input_filename_ch2); | 749 | str_length = strlen(dev->input_filename_ch2); |
750 | dev->_filename_ch2 = kmalloc(str_length + 1, GFP_KERNEL); | 750 | dev->_filename_ch2 = kmemdup(dev->input_filename_ch2, |
751 | str_length + 1, GFP_KERNEL); | ||
751 | 752 | ||
752 | if (!dev->_filename_ch2) | 753 | if (!dev->_filename_ch2) |
753 | goto error; | 754 | goto error; |
754 | |||
755 | memcpy(dev->_filename_ch2, dev->input_filename_ch2, | ||
756 | str_length + 1); | ||
757 | } else { | 755 | } else { |
758 | str_length = strlen(dev->_defaultname_ch2); | 756 | str_length = strlen(dev->_defaultname_ch2); |
759 | dev->_filename_ch2 = kmalloc(str_length + 1, GFP_KERNEL); | 757 | dev->_filename_ch2 = kmemdup(dev->_defaultname_ch2, |
758 | str_length + 1, GFP_KERNEL); | ||
760 | 759 | ||
761 | if (!dev->_filename_ch2) | 760 | if (!dev->_filename_ch2) |
762 | goto error; | 761 | goto error; |
763 | |||
764 | memcpy(dev->_filename_ch2, dev->_defaultname_ch2, | ||
765 | str_length + 1); | ||
766 | } | 762 | } |
767 | 763 | ||
768 | /* Default if filename is empty string */ | 764 | /* Default if filename is empty string */ |
diff --git a/drivers/media/video/cx25821/cx25821-video-upstream.c b/drivers/media/video/cx25821/cx25821-video-upstream.c index 103226320518..21e7d657f049 100644 --- a/drivers/media/video/cx25821/cx25821-video-upstream.c +++ b/drivers/media/video/cx25821/cx25821-video-upstream.c | |||
@@ -794,20 +794,18 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, | |||
794 | 794 | ||
795 | if (dev->input_filename) { | 795 | if (dev->input_filename) { |
796 | str_length = strlen(dev->input_filename); | 796 | str_length = strlen(dev->input_filename); |
797 | dev->_filename = kmalloc(str_length + 1, GFP_KERNEL); | 797 | dev->_filename = kmemdup(dev->input_filename, str_length + 1, |
798 | GFP_KERNEL); | ||
798 | 799 | ||
799 | if (!dev->_filename) | 800 | if (!dev->_filename) |
800 | goto error; | 801 | goto error; |
801 | |||
802 | memcpy(dev->_filename, dev->input_filename, str_length + 1); | ||
803 | } else { | 802 | } else { |
804 | str_length = strlen(dev->_defaultname); | 803 | str_length = strlen(dev->_defaultname); |
805 | dev->_filename = kmalloc(str_length + 1, GFP_KERNEL); | 804 | dev->_filename = kmemdup(dev->_defaultname, str_length + 1, |
805 | GFP_KERNEL); | ||
806 | 806 | ||
807 | if (!dev->_filename) | 807 | if (!dev->_filename) |
808 | goto error; | 808 | goto error; |
809 | |||
810 | memcpy(dev->_filename, dev->_defaultname, str_length + 1); | ||
811 | } | 809 | } |
812 | 810 | ||
813 | /* Default if filename is empty string */ | 811 | /* Default if filename is empty string */ |