From patchwork Fri May 8 18:31:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Welling X-Patchwork-Id: 6366771 Return-Path: X-Original-To: patchwork-linux-spi@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 16B09BEEE1 for ; Fri, 8 May 2015 18:31:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CEB42025B for ; Fri, 8 May 2015 18:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10E5E2008F for ; Fri, 8 May 2015 18:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752760AbbEHSbF (ORCPT ); Fri, 8 May 2015 14:31:05 -0400 Received: from mail-ig0-f170.google.com ([209.85.213.170]:35178 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932366AbbEHSbA (ORCPT ); Fri, 8 May 2015 14:31:00 -0400 Received: by igbyr2 with SMTP id yr2so28285987igb.0; Fri, 08 May 2015 11:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=k8ywx5R5gViGLD/ZrLiTJdybnZKNuZi7rZAiAFp4CdY=; b=IYaPzmoEH+nDDaoj/J/kVtmuSsdN+eFYRbVeaUMNyVdfhfT1lI2ef0V9GeR3P+dozf u0XCXyKOh2j4C1nwXjANPeyyMSL7hOKyuPQcfX/PqRyMsvI0VGzLXiAwHw5msdJ0uveD ppWbNlcmlAuajhONdHKjwCBeWaDu+EHwMt4FIoP4DiHFiJIMsV7zX8+AEuktkyM4iHY0 ClvLe27X2m+a43ndvKZnTyG1Z0KtN456+JGSUkH0jkWE53dRjUr9w2HEmvC8s9MLxQoI dYZdePH/tPj11CA4hNMnSECKENhitKjD4lC/lIqi1QbE0t1nVbLwbhhjgxRgoXlXAJJv Ab+Q== X-Received: by 10.107.3.17 with SMTP id 17mr6639341iod.60.1431109860167; Fri, 08 May 2015 11:31:00 -0700 (PDT) Received: from deathray.hitronhub.home (173-22-240-38.client.mchsi.com. [173.22.240.38]) by mx.google.com with ESMTPSA id vk8sm3766igb.4.2015.05.08.11.30.58 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 May 2015 11:30:59 -0700 (PDT) From: Michael Welling To: broonie@kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Welling Subject: [PATCH v2] spi: omap2-mcspi: Add gpio_request and init CS Date: Fri, 8 May 2015 13:31:01 -0500 Message-Id: <1431109861-6853-1-git-send-email-mwelling@ieee.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 If GPIO chip select is specified, request the GPIO in the setup function and release it in the cleanup function. Signed-off-by: Michael Welling --- v2: Adds gpio_free to cleanup function. Broken out of patch series because the other patch in the series was applied. commit b28cb9414db9f8e42ac18c9e360e4e99cda42489 This patch applies on top of that one. drivers/spi/spi-omap2-mcspi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 3ac06ad..90cf7e7 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -35,6 +35,7 @@ #include #include +#include #include @@ -1011,6 +1012,12 @@ static int omap2_mcspi_setup(struct spi_device *spi) return ret; } + if (gpio_is_valid(spi->cs_gpio)) { + if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0) + gpio_direction_output(spi->cs_gpio, + !(spi->mode & SPI_CS_HIGH)); + } + ret = pm_runtime_get_sync(mcspi->dev); if (ret < 0) return ret; @@ -1050,6 +1057,9 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) mcspi_dma->dma_tx = NULL; } } + + if (gpio_is_valid(spi->cs_gpio)) + gpio_free(spi->cs_gpio); } static int omap2_mcspi_work_one(struct omap2_mcspi *mcspi,