Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: renesas_usbhs: Use struct assignment instead of memcpy()

To avoid the error-proneness of calls to sizeof() in the memcpy,
this patch uses struct assignment instead of memcpy.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>---
This patch is based on Greg's linux-usb.git / usb-next branch.
Note that mod_host.c also has memcpy but we cannot use struct assignment
for it because the type of urb->setup_patcket is just "unsigned char *".

drivers/usb/renesas_usbhs/common.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Yoshihiro Shimoda and committed by
Greg Kroah-Hartman
743344a9 d46a6024

+4 -9
+4 -9
drivers/usb/renesas_usbhs/common.c
··· 651 651 return NULL; 652 652 653 653 dparam = &info->driver_param; 654 - memcpy(dparam, &data->param, sizeof(data->param)); 655 - memcpy(&info->platform_callback, data->platform_callback, 656 - sizeof(*data->platform_callback)); 654 + *dparam = data->param; 655 + info->platform_callback = *data->platform_callback; 657 656 658 657 if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp)) 659 658 dparam->buswait_bwait = tmp; ··· 713 714 * care platform info 714 715 */ 715 716 716 - memcpy(&priv->dparam, 717 - &info->driver_param, 718 - sizeof(struct renesas_usbhs_driver_param)); 717 + priv->dparam = info->driver_param; 719 718 720 719 if (!info->platform_callback.get_id) { 721 720 dev_err(&pdev->dev, "no platform callbacks"); 722 721 return -EINVAL; 723 722 } 724 - memcpy(&priv->pfunc, 725 - &info->platform_callback, 726 - sizeof(struct renesas_usbhs_platform_callback)); 723 + priv->pfunc = info->platform_callback; 727 724 728 725 /* set driver callback functions for platform */ 729 726 dfunc = &info->driver_callback;