From patchwork Wed Jul 4 04:51:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaejoong Kim X-Patchwork-Id: 10505853 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 31AEE601D7 for ; Wed, 4 Jul 2018 04:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D1F428862 for ; Wed, 4 Jul 2018 04:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10EBB28877; Wed, 4 Jul 2018 04:51:45 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 93FF428862 for ; Wed, 4 Jul 2018 04:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608AbeGDEvn (ORCPT ); Wed, 4 Jul 2018 00:51:43 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33337 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbeGDEvm (ORCPT ); Wed, 4 Jul 2018 00:51:42 -0400 Received: by mail-pg0-f67.google.com with SMTP id e11-v6so1948964pgq.0 for ; Tue, 03 Jul 2018 21:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l3smk6/vT7ZIftf+k1SHkuKU2Ff9ryF5V/WEEx7WbJ0=; b=Tc+y0X/yAREN5k0UFqxkfiE0CcY2+ePaCeyCYPTmA7JxEiMz8P/kd0bcFl8GDXGqaS ZDslXXzzT9csg1lVAu8ZnOwFPrH3cTA+U9uQuD7QhcfB0fo4uUclBeyX5ZODCbwE81u8 u9o4IQTiXPSKV051gTbzaGYrca7DUxpfOf1viSdW2san3k/8No1Y+G8OqEJPaA1SBJ+B A5jMgnB33qj4nIWepH8vpK/cBgK2glTOEPicyDFAshHUOl/UsZaj3VWxPSoDzwYIjWk8 wfTf2Gwqtx9OY7y9hyQsS7tsT37IcUbDf27ytmLBc4w7SDxZrgCEuCpOxfkNLrnQzk1p lTHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l3smk6/vT7ZIftf+k1SHkuKU2Ff9ryF5V/WEEx7WbJ0=; b=VbFxc1ccyFk1+AeqbDT+kLLiBJKaEM5YQkJdSlZm69UTFVIgdo+90YcsXbucQA1w9n 3zYw8WvmmWiW8TR64xU2luMlWqRlmR9tBZHT3/B7oU1ZsqqsH1ZmVdeSiN3qGK0viHDT 7yujcE7XdpfBqllk5110ZEtcTODozgZ7zxMe4r7YeMJ45QBnKiknkKvTnJOw3H+daDI7 UuDvVFvLeGpopfnfJ+hE59e/uwG2TYF7TR3CUBWo1w6B32Z2G47mEEnzhgHTKYpLGEBc s5iErYP11/xamegq28FM0gaMyu3MNdPwxmC2svHnLw8mDx8/nUb5gg1K3XGchlX885da PiBQ== X-Gm-Message-State: APt69E2bdzpOv/t5Ky8WPXttVDTwi+du+i7L+qkcPwO6JwyNWGcf9czJ WvFjjBcwto0d5JE0nJ4tQys= X-Google-Smtp-Source: AAOMgpey0XAM/BXcmIBdWbz8o0IcRemQrjpQlztkEMGmmnyNf1XXs4E3WJRcmUJ4Q2z+qDmUZLHxxA== X-Received: by 2002:a63:4d5:: with SMTP id 204-v6mr486969pge.129.1530679901756; Tue, 03 Jul 2018 21:51:41 -0700 (PDT) Received: from climb.lge.net ([27.122.242.77]) by smtp.gmail.com with ESMTPSA id j5-v6sm4882292pfc.56.2018.07.03.21.51.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Jul 2018 21:51:41 -0700 (PDT) From: Jaejoong Kim To: =?UTF-8?q?Micha=C5=82=20Nazarewicz?= , Alan Stern , Felipe Balbi , Greg KH , Krzysztof Opasiak Cc: USB list Subject: [PATCH V2 2/2] usb: gadget: storage: Remove reference counting Date: Wed, 4 Jul 2018 13:51:28 +0900 Message-Id: <1530679888-19939-3-git-send-email-climbbb.kim@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530679888-19939-1-git-send-email-climbbb.kim@gmail.com> References: <1530679888-19939-1-git-send-email-climbbb.kim@gmail.com> 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 The kref used to be needed because sharing of fsg_common among multiple USB function instances was handled by fsg. Now this is managed by configfs, we don't need it anymore. So let's eliminate kref from this driver. Signed-off-by: Jaejoong Kim Acked-by: Michal Nazarewicz Acked-by: Alan Stern --- Changes in V2: - Rewrite commit title & message. - Remove kref instead of removing unused kref EXPORT_SYMBOL (Alan and Michal) V1 patches https://patchwork.kernel.org/patch/10463709/ https://patchwork.kernel.org/patch/10463713/ drivers/usb/gadget/function/f_mass_storage.c | 27 +++++---------------------- drivers/usb/gadget/function/f_mass_storage.h | 4 ---- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 1b580eb..ca8a4b5 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -206,7 +206,6 @@ #include #include #include -#include #include #include #include @@ -312,8 +311,6 @@ struct fsg_common { void *private_data; char inquiry_string[INQUIRY_STRING_LEN]; - - struct kref ref; }; struct fsg_dev { @@ -2551,25 +2548,11 @@ static DEVICE_ATTR(file, 0, file_show, file_store); /****************************** FSG COMMON ******************************/ -static void fsg_common_release(struct kref *ref); - static void fsg_lun_release(struct device *dev) { /* Nothing needs to be done */ } -void fsg_common_get(struct fsg_common *common) -{ - kref_get(&common->ref); -} -EXPORT_SYMBOL_GPL(fsg_common_get); - -void fsg_common_put(struct fsg_common *common) -{ - kref_put(&common->ref, fsg_common_release); -} -EXPORT_SYMBOL_GPL(fsg_common_put); - static struct fsg_common *fsg_common_setup(struct fsg_common *common) { if (!common) { @@ -2582,7 +2565,6 @@ static struct fsg_common *fsg_common_setup(struct fsg_common *common) } init_rwsem(&common->filesem); spin_lock_init(&common->lock); - kref_init(&common->ref); init_completion(&common->thread_notifier); init_waitqueue_head(&common->io_wait); init_waitqueue_head(&common->fsg_wait); @@ -2870,9 +2852,8 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, } EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string); -static void fsg_common_release(struct kref *ref) +static void fsg_common_release(struct fsg_common *common) { - struct fsg_common *common = container_of(ref, struct fsg_common, ref); int i; /* If the thread isn't already dead, tell it to exit now */ @@ -3346,7 +3327,7 @@ static void fsg_free_inst(struct usb_function_instance *fi) struct fsg_opts *opts; opts = fsg_opts_from_func_inst(fi); - fsg_common_put(opts->common); + fsg_common_release(opts->common); kfree(opts); } @@ -3370,7 +3351,7 @@ static struct usb_function_instance *fsg_alloc_inst(void) rc = fsg_common_set_num_buffers(opts->common, CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS); if (rc) - goto release_opts; + goto release_common; pr_info(FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); @@ -3393,6 +3374,8 @@ static struct usb_function_instance *fsg_alloc_inst(void) release_buffers: fsg_common_free_buffers(opts->common); +release_common: + kfree(opts->common); release_opts: kfree(opts); return ERR_PTR(rc); diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h index 58857fc..3b8c4ce 100644 --- a/drivers/usb/gadget/function/f_mass_storage.h +++ b/drivers/usb/gadget/function/f_mass_storage.h @@ -115,10 +115,6 @@ fsg_opts_from_func_inst(const struct usb_function_instance *fi) return container_of(fi, struct fsg_opts, func_inst); } -void fsg_common_get(struct fsg_common *common); - -void fsg_common_put(struct fsg_common *common); - void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs); int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n);