From patchwork Sun May 6 23:36:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Nowak X-Patchwork-Id: 10383079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0EDA960236 for ; Sun, 6 May 2018 23:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED00828975 for ; Sun, 6 May 2018 23:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0DB42898F; Sun, 6 May 2018 23:45:13 +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=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham 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 1324328975 for ; Sun, 6 May 2018 23:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbeEFXpL (ORCPT ); Sun, 6 May 2018 19:45:11 -0400 Received: from mail-aws.exablue.com ([52.214.74.137]:33746 "EHLO mail-aws.exablue.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751625AbeEFXpJ (ORCPT ); Sun, 6 May 2018 19:45:09 -0400 X-Greylist: delayed 366 seconds by postgrey-1.27 at vger.kernel.org; Sun, 06 May 2018 19:45:08 EDT Received: from localhost.localdomain (89-70-178-153.dynamic.chello.pl [89.70.178.153]) by mail-aws.exablue.com (Postfix) with ESMTPSA id 4F7AF3E930; Sun, 6 May 2018 23:39:01 +0000 (UTC) From: Lukasz Nowak To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Greg Kroah-Hartman , Lukasz Nowak Subject: [PATCH] usb: gadget: f_ecm: fix host mac address for multiple instances Date: Mon, 7 May 2018 01:36:45 +0200 Message-Id: <20180506233645.14635-1-lukasz.nowak@exablue.com> X-Mailer: git-send-email 2.14.1 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 In case there are multiple ecm instances, either for multiple otg controllers, or multiple virtual links using libcomposite, each instance needs to have its own host mac address string value for iMACAddress. Update the source array (ecm_string_defs), every time before usb_gstrings_attach(). Without that, all links wrongly were getting the same, last allocated, host mac address, rather than the correct one, as requested via configfs. Signed-off-by: Lukasz Nowak --- drivers/usb/gadget/function/f_ecm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index b104ed0c1ab5..6ce044008cf6 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -705,6 +705,8 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) ecm_opts->bound = true; } + ecm_string_defs[1].s = ecm->ethaddr; + us = usb_gstrings_attach(cdev, ecm_strings, ARRAY_SIZE(ecm_string_defs)); if (IS_ERR(us)) @@ -928,7 +930,6 @@ static struct usb_function *ecm_alloc(struct usb_function_instance *fi) mutex_unlock(&opts->lock); return ERR_PTR(-EINVAL); } - ecm_string_defs[1].s = ecm->ethaddr; ecm->port.ioport = netdev_priv(opts->net); mutex_unlock(&opts->lock);