From patchwork Thu Jul 28 07:55:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 9250807 X-Patchwork-Delegate: kvalo@adurom.com 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 338856077C for ; Thu, 28 Jul 2016 08:05:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273D8212DA for ; Thu, 28 Jul 2016 08:05:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BEBD26B39; Thu, 28 Jul 2016 08:05:41 +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=-6.9 required=2.0 tests=BAYES_00,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 F2C27212DA for ; Thu, 28 Jul 2016 08:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758200AbcG1IFi (ORCPT ); Thu, 28 Jul 2016 04:05:38 -0400 Received: from hotel311.server4you.de ([85.25.146.15]:52492 "EHLO hotel311.server4you.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbcG1IF3 (ORCPT ); Thu, 28 Jul 2016 04:05:29 -0400 Received: from hotel311.server4you.de (localhost [127.0.0.1]) by filter.mynetwork.local (Postfix) with ESMTP id A470B1941A6B; Thu, 28 Jul 2016 09:55:33 +0200 (CEST) Received: from localhost (unknown [212.118.206.70]) by hotel311.server4you.de (Postfix) with ESMTPSA id 416E31941A9D; Thu, 28 Jul 2016 09:55:30 +0200 (CEST) From: Daniel Wagner To: Bastien Nocera , Bjorn Andersson , Dmitry Torokhov , Greg Kroah-Hartman , Johannes Berg , Kalle Valo , Ohad Ben-Cohen Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [RFC v0 7/8] Input: ims-pcu: use firmware_stat instead of completion Date: Thu, 28 Jul 2016 09:55:11 +0200 Message-Id: <1469692512-16863-8-git-send-email-wagi@monom.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469692512-16863-1-git-send-email-wagi@monom.org> References: <1469692512-16863-1-git-send-email-wagi@monom.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Wagner Loading firmware is an operation many drivers implement in various ways around the completion API. And most of them do it almost in the same way. Let's reuse the firmware_stat API which is used also by the firmware_class loader. Apart of streamlining the firmware loading states we also document it slightly better. Signed-off-by: Daniel Wagner --- drivers/input/misc/ims-pcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 9c0ea36..cda1fbf 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -109,7 +109,7 @@ struct ims_pcu { u32 fw_start_addr; u32 fw_end_addr; - struct completion async_firmware_done; + struct firmware_stat fw_st; struct ims_pcu_buttons buttons; struct ims_pcu_gamepad *gamepad; @@ -940,7 +940,7 @@ static void ims_pcu_process_async_firmware(const struct firmware *fw, release_firmware(fw); out: - complete(&pcu->async_firmware_done); + fw_loading_done(pcu->fw_st); } /********************************************************************* @@ -1967,7 +1967,7 @@ static int ims_pcu_init_bootloader_mode(struct ims_pcu *pcu) ims_pcu_process_async_firmware); if (error) { /* This error is not fatal, let userspace have another chance */ - complete(&pcu->async_firmware_done); + fw_loading_abort(pcu->fw_st); } return 0; @@ -1976,7 +1976,7 @@ static int ims_pcu_init_bootloader_mode(struct ims_pcu *pcu) static void ims_pcu_destroy_bootloader_mode(struct ims_pcu *pcu) { /* Make sure our initial firmware request has completed */ - wait_for_completion(&pcu->async_firmware_done); + fw_loading_wait(pcu->fw_st); } #define IMS_PCU_APPLICATION_MODE 0 @@ -2000,7 +2000,7 @@ static int ims_pcu_probe(struct usb_interface *intf, pcu->bootloader_mode = id->driver_info == IMS_PCU_BOOTLOADER_MODE; mutex_init(&pcu->cmd_mutex); init_completion(&pcu->cmd_done); - init_completion(&pcu->async_firmware_done); + firmware_stat_init(&pcu->fw_st); error = ims_pcu_parse_cdc_data(intf, pcu); if (error)