From patchwork Tue Aug 12 17:25:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 35303 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A14420540 for ; Tue, 12 Aug 2014 17:26:35 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id v10sf39067791pde.6 for ; Tue, 12 Aug 2014 10:26:34 -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:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=onm93Qat7zniFDth3uJ2dOCvlLb53o1aWFvAQmw2YgE=; b=fXpZG5AVa5j6qPeNqSBtO/6SSXc+F78bF7tNLmjFTyqv4TQg6H1v4ZbFRG+oXdlcP0 FsYmdqGqrUANGqCdukNUv91O3sVla3pjlWyYAtWkOKH1sh/RIGvdzdPeCQrLLoHMmwAb ii6GY9SrTPukh3W7Etqu4+DlE0/+YVGnqYhOquAaBYoFqYcbINGStgy2PQC66e5AOEa+ YF2dESLlHpRVCRrvvI4LxIdC4dsZDUIFrAgargUKUS02NcVB9PXhNHlbNh/Z7BBbpVHf UfKT+454AyfZA8o8iYpIBY7N0QNst5Do9N7ljp3588LTVc7dUFwJW3XpPAKfo4CTab8T vYfQ== X-Gm-Message-State: ALoCoQkCPZwB5saTIdlZGte2OV2uNyEOQ7hi0fPqhAY3ny6zGUbiByIqTDFBw3lFIFsVGtDaLVE7 X-Received: by 10.66.228.70 with SMTP id sg6mr2754702pac.2.1407864394378; Tue, 12 Aug 2014 10:26:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.241 with SMTP id c104ls252830qgd.39.gmail; Tue, 12 Aug 2014 10:26:34 -0700 (PDT) X-Received: by 10.221.48.201 with SMTP id ux9mr2154060vcb.68.1407864394088; Tue, 12 Aug 2014 10:26:34 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id u4si8619414vcs.52.2014.08.12.10.26.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 10:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so13462812vcb.40 for ; Tue, 12 Aug 2014 10:26:34 -0700 (PDT) X-Received: by 10.220.187.134 with SMTP id cw6mr2175556vcb.71.1407864394000; Tue, 12 Aug 2014 10:26:34 -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.221.37.5 with SMTP id tc5csp266499vcb; Tue, 12 Aug 2014 10:26:33 -0700 (PDT) X-Received: by 10.70.96.41 with SMTP id dp9mr2375546pdb.156.1407864392940; Tue, 12 Aug 2014 10:26:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si12944921pdm.29.2014.08.12.10.26.32 for ; Tue, 12 Aug 2014 10:26:32 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-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 S1754070AbaHLR0c (ORCPT ); Tue, 12 Aug 2014 13:26:32 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:41240 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754059AbaHLR0b (ORCPT ); Tue, 12 Aug 2014 13:26:31 -0400 Received: by mail-wi0-f176.google.com with SMTP id bs8so6228678wib.3 for ; Tue, 12 Aug 2014 10:26:30 -0700 (PDT) X-Received: by 10.180.89.100 with SMTP id bn4mr164273wib.34.1407864390368; Tue, 12 Aug 2014 10:26:30 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id cx5sm10649644wjb.8.2014.08.12.10.26.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Aug 2014 10:26:29 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Chris Ball , Ulf Hansson Cc: linux-gpio@vger.kernel.org, Linus Walleij , Alexandre Courbot Subject: [PATCH 3/4] mmc: host: switch OF parser to use gpio descriptors Date: Tue, 12 Aug 2014 19:25:54 +0200 Message-Id: <1407864355-21545-3-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1407864355-21545-1-git-send-email-linus.walleij@linaro.org> References: <1407864355-21545-1-git-send-email-linus.walleij@linaro.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) 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: , This switches the central MMC OF parser to use gpio descriptors instead of grabbing GPIOs explicitly from the device tree. This strips out an unecessary use of the integer-based GPIO API that we want to get rid of, cuts down on code as the gpio descriptor code will handle active low flags. As it is in no way a bug not to supply CD/WP GPIOs the messages about them not being specified have been depromoted from dev_err() to dev_dbg(). Cc: Alexandre Courbot Signed-off-by: Linus Walleij Acked-by: Alexandre Courbot --- drivers/mmc/core/host.c | 68 +++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 95cceae96944..048c6d687cc9 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -310,9 +310,7 @@ int mmc_of_parse(struct mmc_host *host) { struct device_node *np; u32 bus_width; - bool explicit_inv_wp, gpio_inv_wp = false; - enum of_gpio_flags flags; - int len, ret, gpio; + int len, ret; if (!host->parent || !host->parent->of_node) return 0; @@ -360,60 +358,36 @@ int mmc_of_parse(struct mmc_host *host) if (of_find_property(np, "non-removable", &len)) { host->caps |= MMC_CAP_NONREMOVABLE; } else { - bool explicit_inv_cd, gpio_inv_cd = false; - - explicit_inv_cd = of_property_read_bool(np, "cd-inverted"); + if (of_property_read_bool(np, "cd-inverted")) + host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; if (of_find_property(np, "broken-cd", &len)) host->caps |= MMC_CAP_NEEDS_POLL; - gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags); - if (gpio == -EPROBE_DEFER) - return gpio; - if (gpio_is_valid(gpio)) { - if (!(flags & OF_GPIO_ACTIVE_LOW)) - gpio_inv_cd = true; - - ret = mmc_gpio_request_cd(host, gpio, 0); - if (ret < 0) { - dev_err(host->parent, - "Failed to request CD GPIO #%d: %d!\n", - gpio, ret); + ret = mmc_gpiod_request_cd(host, "cd", 0, false, 0); + if (ret) { + if (ret == -EPROBE_DEFER) return ret; - } else { - dev_info(host->parent, "Got CD GPIO #%d.\n", - gpio); - } - } - - if (explicit_inv_cd ^ gpio_inv_cd) - host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; + dev_dbg(host->parent, + "Failed to request CD GPIO: %d\n", + ret); + } else + dev_info(host->parent, "Got CD GPIO\n"); } /* Parse Write Protection */ - explicit_inv_wp = of_property_read_bool(np, "wp-inverted"); + if (of_property_read_bool(np, "wp-inverted")) + host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; - gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags); - if (gpio == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; - goto out; - } - if (gpio_is_valid(gpio)) { - if (!(flags & OF_GPIO_ACTIVE_LOW)) - gpio_inv_wp = true; - - ret = mmc_gpio_request_ro(host, gpio); - if (ret < 0) { - dev_err(host->parent, - "Failed to request WP GPIO: %d!\n", ret); + ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0); + if (ret) { + if (ret == -EPROBE_DEFER) goto out; - } else { - dev_info(host->parent, "Got WP GPIO #%d.\n", - gpio); - } - } - if (explicit_inv_wp ^ gpio_inv_wp) - host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; + dev_dbg(host->parent, + "Failed to request WP GPIO: %d\n", + ret); + } else + dev_info(host->parent, "Got WP GPIO\n"); if (of_find_property(np, "cap-sd-highspeed", &len)) host->caps |= MMC_CAP_SD_HIGHSPEED;