From patchwork Tue Jun 2 19:11:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kici?ski X-Patchwork-Id: 6530891 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ACCBFC0020 for ; Tue, 2 Jun 2015 19:11:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D4060204CF for ; Tue, 2 Jun 2015 19:11:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F2ECB2053C for ; Tue, 2 Jun 2015 19:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750877AbbFBTLp (ORCPT ); Tue, 2 Jun 2015 15:11:45 -0400 Received: from mx4.wp.pl ([212.77.101.12]:54131 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751380AbbFBTLm (ORCPT ); Tue, 2 Jun 2015 15:11:42 -0400 Received: (wp-smtpd smtp.wp.pl 30817 invoked from network); 2 Jun 2015 21:11:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1433272300; bh=cojAWhZnmaHbmLPCk7lotCQRIA+FO7Y+DsmUEuGk48Y=; h=From:To:Cc:Subject; b=Ht/9A56yaTJLzAcEDRfWOIEZz+rwj2zquluxEN7KUlLjjbONq2BAlAqOGJh/YxF7H 34gWMoavOY7kQ/lUWoAMgjywemt2dUZgJ+nSFOZt/XumOAUoiXeMHsSd8sMfuErV+6 rKrFzN8fzXSo7HPWK8DzkFccznk05HXQn2A9oeJ4= Received: from 89-69-164-220.dynamic.chello.pl (HELO north.moorray.no-ip.org) (moorray3@[89.69.164.220]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 2 Jun 2015 21:11:39 +0200 Received: by north.moorray.no-ip.org (sSMTP sendmail emulation); Tue, 02 Jun 2015 21:11:39 +0200 From: Jakub Kicinski To: Kalle Valo Cc: linux-wireless , Jakub Kicinski Subject: [PATCH 3/4] mt7601u: don't cleanup device second time after .resume() Date: Tue, 2 Jun 2015 21:11:27 +0200 Message-Id: <1433272288-6450-3-git-send-email-moorray3@wp.pl> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433272288-6450-1-git-send-email-moorray3@wp.pl> References: <1433272288-6450-1-git-send-email-moorray3@wp.pl> X-WP-DKIM-Status: good (id: wp.pl) X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [USME] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jakub Kicinski Make sure .disconnect() doesn't cleanup the device if .resume() failed. This may happen when device is removed during suspend. Signed-off-by: Jakub Kicinski --- drivers/net/wireless/mediatek/mt7601u/init.c | 3 +++ drivers/net/wireless/mediatek/mt7601u/usb.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c b/drivers/net/wireless/mediatek/mt7601u/init.c index 1fc86e865c8c..45eb0796a2e5 100644 --- a/drivers/net/wireless/mediatek/mt7601u/init.c +++ b/drivers/net/wireless/mediatek/mt7601u/init.c @@ -427,6 +427,9 @@ err: void mt7601u_cleanup(struct mt7601u_dev *dev) { + if (!test_and_clear_bit(MT7601U_STATE_INITIALIZED, &dev->state)) + return; + mt7601u_stop_hardware(dev); mt7601u_dma_cleanup(dev); mt7601u_mcu_cmd_deinit(dev); diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.c b/drivers/net/wireless/mediatek/mt7601u/usb.c index 99e2b3997bfa..54dba4001865 100644 --- a/drivers/net/wireless/mediatek/mt7601u/usb.c +++ b/drivers/net/wireless/mediatek/mt7601u/usb.c @@ -338,8 +338,15 @@ static int mt7601u_suspend(struct usb_interface *usb_intf, pm_message_t state) static int mt7601u_resume(struct usb_interface *usb_intf) { struct mt7601u_dev *dev = usb_get_intfdata(usb_intf); + int ret; + + ret = mt7601u_init_hardware(dev); + if (ret) + return ret; + + set_bit(MT7601U_STATE_INITIALIZED, &dev->state); - return mt7601u_init_hardware(dev); + return 0; } MODULE_DEVICE_TABLE(usb, mt7601u_device_table);