From patchwork Thu Jun 13 11:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10992305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CC5615E6 for ; Thu, 13 Jun 2019 15:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E5F4212DB for ; Thu, 13 Jun 2019 15:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42E3E21C9A; Thu, 13 Jun 2019 15:29:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=AC_FROM_MANY_DOTS,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E969E212DB for ; Thu, 13 Jun 2019 15:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729362AbfFMP3w (ORCPT ); Thu, 13 Jun 2019 11:29:52 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:22282 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728643AbfFMLTM (ORCPT ); Thu, 13 Jun 2019 07:19:12 -0400 X-IronPort-AV: E=Sophos;i="5.62,369,1554735600"; d="scan'208";a="18384428" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 13 Jun 2019 20:19:10 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 86BC2427E065; Thu, 13 Jun 2019 20:19:10 +0900 (JST) From: Yoshihiro Shimoda To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH] usb: renesas_usbhs: Use struct assignment instead of memcpy() Date: Thu, 13 Jun 2019 20:18:48 +0900 Message-Id: <1560424728-13929-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Simon Horman --- 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(-) diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index a501ea6..ebbe322 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c @@ -651,9 +651,8 @@ static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev) return NULL; dparam = &info->driver_param; - memcpy(dparam, &data->param, sizeof(data->param)); - memcpy(&info->platform_callback, data->platform_callback, - sizeof(*data->platform_callback)); + *dparam = data->param; + info->platform_callback = *data->platform_callback; if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp)) dparam->buswait_bwait = tmp; @@ -714,17 +713,13 @@ static int usbhs_probe(struct platform_device *pdev) * care platform info */ - memcpy(&priv->dparam, - &info->driver_param, - sizeof(struct renesas_usbhs_driver_param)); + priv->dparam = info->driver_param; if (!info->platform_callback.get_id) { dev_err(&pdev->dev, "no platform callbacks"); return -EINVAL; } - memcpy(&priv->pfunc, - &info->platform_callback, - sizeof(struct renesas_usbhs_platform_callback)); + priv->pfunc = info->platform_callback; /* set driver callback functions for platform */ dfunc = &info->driver_callback;