From patchwork Wed Nov 21 10:29:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 1779861 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id DFBC0DF288 for ; Wed, 21 Nov 2012 10:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754545Ab2KUKtD (ORCPT ); Wed, 21 Nov 2012 05:49:03 -0500 Received: from 17.mo4.mail-out.ovh.net ([46.105.41.16]:44857 "EHLO mo4.mail-out.ovh.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754124Ab2KUKtC (ORCPT ); Wed, 21 Nov 2012 05:49:02 -0500 X-Greylist: delayed 1056 seconds by postgrey-1.27 at vger.kernel.org; Wed, 21 Nov 2012 05:49:02 EST Received: from mail92.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo4.mail-out.ovh.net (Postfix) with SMTP id EBE54105815E for ; Wed, 21 Nov 2012 11:39:11 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 21 Nov 2012 12:31:24 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 21 Nov 2012 12:31:19 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Cc: Jean-Christophe PLAGNIOL-VILLARD , linux-mmc@vger.kernel.org, Ludovic Desroches X-Ovh-Mailout: 178.32.228.4 (mo4.mail-out.ovh.net) Subject: [PATCH 1/1] mmc:atmel-mci: use devm_gpio_request/free and configure the pin corrently Date: Wed, 21 Nov 2012 11:29:22 +0100 Message-Id: <1353493762-31137-1-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10 X-Ovh-Tracer-Id: 12499459292886051837 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehgedrudeiucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffosedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeehgedrudeiucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffosedttdertdertddt Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org as on DT we do not configure the pin via AT91 custom pinmux as before Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: linux-mmc@vger.kernel.org Cc: Ludovic Desroches --- based on next-20121115 Best Regards, J. drivers/mmc/host/atmel-mci.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 767706b..d97771d 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -2108,6 +2108,7 @@ static int __init atmci_init_slot(struct atmel_mci *host, { struct mmc_host *mmc; struct atmel_mci_slot *slot; + int ret; mmc = mmc_alloc_host(sizeof(struct atmel_mci_slot), &host->pdev->dev); if (!mmc) @@ -2161,12 +2162,20 @@ static int __init atmci_init_slot(struct atmel_mci *host, /* Assume card is present initially */ set_bit(ATMCI_CARD_PRESENT, &slot->flags); if (gpio_is_valid(slot->detect_pin)) { - if (gpio_request(slot->detect_pin, "mmc_detect")) { - dev_dbg(&mmc->class_dev, "no detect pin available\n"); - slot->detect_pin = -EBUSY; - } else if (gpio_get_value(slot->detect_pin) ^ - slot->detect_is_active_high) { - clear_bit(ATMCI_CARD_PRESENT, &slot->flags); + ret = devm_gpio_request(&mmc->class_dev, slot->detect_pin, "mmc_detect"); + if (ret) { + dev_warn(&mmc->class_dev, "can't request detect pin\n"); + slot->detect_pin = ret; + } else { + ret = gpio_direction_input(slot->detect_pin); + if (ret) { + dev_err(&mmc->class_dev, "can't set detect pin direction\n"); + devm_gpio_free(&mmc->class_dev, slot->detect_pin); + slot->detect_pin = -ret; + } else if (gpio_get_value(slot->detect_pin) ^ + slot->detect_is_active_high) { + clear_bit(ATMCI_CARD_PRESENT, &slot->flags); + } } } @@ -2174,9 +2183,17 @@ static int __init atmci_init_slot(struct atmel_mci *host, mmc->caps |= MMC_CAP_NEEDS_POLL; if (gpio_is_valid(slot->wp_pin)) { - if (gpio_request(slot->wp_pin, "mmc_wp")) { - dev_dbg(&mmc->class_dev, "no WP pin available\n"); - slot->wp_pin = -EBUSY; + ret = devm_gpio_request(&mmc->class_dev, slot->wp_pin, "mmc_wp"); + if (ret) { + dev_warn(&mmc->class_dev, "no WP pin available\n"); + slot->wp_pin = ret; + } else { + ret = gpio_direction_output(slot->wp_pin, 0); + if (ret) { + dev_err(&mmc->class_dev, "can't set WP pin direction\n"); + devm_gpio_free(&mmc->class_dev, slot->wp_pin); + slot->wp_pin = ret; + } } } @@ -2197,8 +2214,8 @@ static int __init atmci_init_slot(struct atmel_mci *host, dev_dbg(&mmc->class_dev, "could not request IRQ %d for detect pin\n", gpio_to_irq(slot->detect_pin)); - gpio_free(slot->detect_pin); - slot->detect_pin = -EBUSY; + devm_gpio_free(&mmc->class_dev, slot->detect_pin); + slot->detect_pin = ret; } }