From patchwork Thu May 1 17:49:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 29526 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 168B120675 for ; Thu, 1 May 2014 18:47:03 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf7398986qge.4 for ; Thu, 01 May 2014 11:47:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:date :message-id:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=7GZumy3F32gFrYnovR99aOdpdmgLE12ZXTDuPWytfZQ=; b=lfP3kz2vs+2NQMgHf04ByN9ul5DiKfaZJV+p9+7tBVFi44EkWrZ/us04CiXK+ung5E RIuzTV4ONiq3rgoVwIiADg2s2yubV7iVgx0xjN4pxQDkA9B1E2PiTsoHMovDRK6TvuPV xLFbhi+TFztmz+qlsfnCuB5ZY/0wlenGDT0mabtXDyXMXPsaZ6PPm6xFYPBHPKuSSqQK x8djyHP2B6nMBb7yQdtX+wwF5y1KVU7efOOXfyd79koQejoObjkjlk+OlMlcQ4UEqTjx E0CI2On51KXlXndrULNpWwp6qTfl5t8q4U1ObmGGIpV5DZKfbpAkKz9SnK79H6h9Ca08 EKhA== X-Gm-Message-State: ALoCoQkA9rf4nbJNaisRA50hTtHnLxAJmkt4xjQU+AFv+LXPjgj5K3gZKGCC86AW/lwkNxFXOzNJ X-Received: by 10.236.142.101 with SMTP id h65mr5376497yhj.1.1398970022804; Thu, 01 May 2014 11:47:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.239 with SMTP id 102ls1137492qgh.42.gmail; Thu, 01 May 2014 11:47:02 -0700 (PDT) X-Received: by 10.52.142.10 with SMTP id rs10mr7963583vdb.3.1398970022695; Thu, 01 May 2014 11:47:02 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id y10si6210829vei.204.2014.05.01.11.47.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 11:47:02 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id lf12so4376204vcb.13 for ; Thu, 01 May 2014 11:47:02 -0700 (PDT) X-Received: by 10.52.252.43 with SMTP id zp11mr690466vdc.44.1398970022548; Thu, 01 May 2014 11:47:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp45886vcb; Thu, 1 May 2014 11:47:02 -0700 (PDT) X-Received: by 10.66.240.4 with SMTP id vw4mr24309385pac.26.1398970021883; Thu, 01 May 2014 11:47:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hr5si9112432pac.469.2014.05.01.11.47.01; Thu, 01 May 2014 11:47:01 -0700 (PDT) Received-SPF: none (google.com: linux-spi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbaEASrA (ORCPT + 2 others); Thu, 1 May 2014 14:47:00 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:54311 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751408AbaEASrA (ORCPT ); Thu, 1 May 2014 14:47:00 -0400 Received: from [209.133.115.210] (helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Wfw0V-0004SW-GH; Thu, 01 May 2014 18:46:56 +0000 Received: from broonie by finisterre with local (Exim 4.82) (envelope-from ) id 1Wfv6u-0001MB-1r; Thu, 01 May 2014 10:49:28 -0700 From: Mark Brown To: Ricardo Ribalda Delgado , Geert Uytterhoeven Cc: linux-spi@vger.kernel.org, linaro-kerne@lists.linaro.org, Mark Brown Date: Thu, 1 May 2014 10:49:27 -0700 Message-Id: <1398966567-5182-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 1.9.2 X-SA-Exim-Connect-IP: 209.133.115.210 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Subject: [PATCH] spi: core: Don't destroy master queue if we fail to create it X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-spi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: broonie@kernel.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mark Brown If we fail to create the master queue for some reason we should not attempt to clean it up since attempting to stop a kthread that was not created will hang and it's just generally bad practice. Unfortunately at present we call spi_destroy_queue() even in cases where the creation fails. Fix this by fixing the error handling in spi_master_initialize_queue() so that we only flag the master as queued or destroy the queue if creation succeeded. The change to the flag is done since the general master cleanup uses this to destroy the queue. Reported-by: Ricardo Ribalda Delgado Signed-off-by: Mark Brown Acked-by: Geert Uytterhoeven --- This has been compile tested only but it should hopefully be more robust in the long term than just skipping the queue deletion inside the destructor. drivers/spi/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 38ba75a..bc42e27 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1151,7 +1151,6 @@ static int spi_master_initialize_queue(struct spi_master *master) { int ret; - master->queued = true; master->transfer = spi_queued_transfer; if (!master->transfer_one_message) master->transfer_one_message = spi_transfer_one_message; @@ -1162,6 +1161,7 @@ static int spi_master_initialize_queue(struct spi_master *master) dev_err(&master->dev, "problem initializing queue\n"); goto err_init_queue; } + master->queued = true; ret = spi_start_queue(master); if (ret) { dev_err(&master->dev, "problem starting queue\n"); @@ -1171,8 +1171,8 @@ static int spi_master_initialize_queue(struct spi_master *master) return 0; err_start_queue: -err_init_queue: spi_destroy_queue(master); +err_init_queue: return ret; }