From patchwork Mon Mar 8 11:55:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Ellis X-Patchwork-Id: 84054 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o28DEAJO029146 for ; Mon, 8 Mar 2010 13:14:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753701Ab0CHNOJ (ORCPT ); Mon, 8 Mar 2010 08:14:09 -0500 Received: from pan.gwi.net ([207.5.128.165]:2164 "EHLO pan.gwi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752463Ab0CHNOI (ORCPT ); Mon, 8 Mar 2010 08:14:08 -0500 Received: from [192.168.10.4] (66-63-88-74.static.suscom-maine.net [66.63.88.74]) by pan.gwi.net (8.13.1/8.13.1) with ESMTP id o28BtJ3x098541 for ; Mon, 8 Mar 2010 06:55:19 -0500 (EST) (envelope-from scott@jumpnowtek.com) Subject: [PATCH] omap2_mcspi.c: Checks in omap2_mcspi_cleanup From: Scott Ellis To: linux-omap@vger.kernel.org Date: Mon, 08 Mar 2010 06:55:19 -0500 Message-ID: <1268049319.2558.74.camel@quad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 08 Mar 2010 13:14:10 +0000 (UTC) diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c index 715c518..fe1b56d 100644 --- a/drivers/spi/omap2_mcspi.c +++ b/drivers/spi/omap2_mcspi.c @@ -748,22 +748,26 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) struct omap2_mcspi_dma *mcspi_dma; struct omap2_mcspi_cs *cs; - mcspi = spi_master_get_devdata(spi->master); - mcspi_dma = &mcspi->dma_channels[spi->chip_select]; + if (spi->controller_state) { + /* Unlink controller state from context save list */ + cs = spi->controller_state; + list_del(&cs->node); - /* Unlink controller state from context save list */ - cs = spi->controller_state; - list_del(&cs->node); + kfree(spi->controller_state); + } - kfree(spi->controller_state); + if (spi->chip_select < spi->master->num_chipselect) { + mcspi = spi_master_get_devdata(spi->master); + mcspi_dma = &mcspi->dma_channels[spi->chip_select]; - if (mcspi_dma->dma_rx_channel != -1) { - omap_free_dma(mcspi_dma->dma_rx_channel); - mcspi_dma->dma_rx_channel = -1; - } - if (mcspi_dma->dma_tx_channel != -1) { - omap_free_dma(mcspi_dma->dma_tx_channel); - mcspi_dma->dma_tx_channel = -1; + if (mcspi_dma->dma_rx_channel != -1) { + omap_free_dma(mcspi_dma->dma_rx_channel); + mcspi_dma->dma_rx_channel = -1; + } + if (mcspi_dma->dma_tx_channel != -1) { + omap_free_dma(mcspi_dma->dma_tx_channel); + mcspi_dma->dma_tx_channel = -1; + } } }