Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp367364ybx; Mon, 4 Nov 2019 21:54:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy+1sMZohZC+9l/juugCWpHWwjedg5sWmjOCRPg289C8aBnv/BXQZuqCF/dK0qBR3AcW4oy X-Received: by 2002:a17:906:4346:: with SMTP id z6mr20419158ejm.71.1572933292135; Mon, 04 Nov 2019 21:54:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572933292; cv=none; d=google.com; s=arc-20160816; b=c0Vpj/qv6n6zFngRWb/ozoGJpmeKC1igUuOCntZJwQWMkZ5r4cmhNrgdKaDRtez87U znKdyeeAolYOlf/XUVWqZ9EStJrDwtVGVRZ9V6HySePYqPIJkcdMRl4IYGI8/AOPfRQ/ A3BVU6gKwUTWYxVtaDfV7LSf/Q+lzeHlnnphhKuhDZN9k+6HRAPrslTfta/UpqgPCFUS sAtDmOM8JeuOoCN6YOAZ8TbPDgnuKFSM4QjamVxW6NDxUy6NuhSbcFmz7iesJsNaGXFW 60Jy6baMZ6wkSzjQVdlIPT9O8c0mCqq8/vvLj8j+u9VlnLOipOsPL0RrSAK9rSC3YbvH 4Gng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=accoXOxPpMfSklNjxTHIj/DG7t6X6wkg7k2xJXY9t7I=; b=bBAjJk2fUXq5PWijmMgPnut5v87CTpNPFXQcSzy9jfaFk0rt180joXRiJ+A6EXnmVA xs8+ePrhiKhUqvTmvyko8BrMMSXKpM8ohJ4RzX35VbMR9apXV4klTq/jtrzpDq51qfZd 9EflrehCrkUF4Dami+SxVeEu73iDcraEQw5wMSzuYL0zqADwB62imOWIvC5BPKIkmBVS 3j0D8f7Rm5LDBuyf1v2EGhdzySbrT5+nMuRgI5WVuFgsDvlDvAKUlB0T5KLlLSBEd/Y+ L69DVbGFiZ8h5kjsjYHHL6euMcNPxpREoOs1ln1ZQxdDTwCvhhNxwHc3QS/sGIcWH0zy A17A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si9980777edd.373.2019.11.04.21.54.27; Mon, 04 Nov 2019 21:54:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730480AbfKEFvR (ORCPT + 99 others); Tue, 5 Nov 2019 00:51:17 -0500 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:50753 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730346AbfKEFvR (ORCPT ); Tue, 5 Nov 2019 00:51:17 -0500 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 2BF163C0591; Tue, 5 Nov 2019 06:51:15 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vcDgZBvjmmhC; Tue, 5 Nov 2019 06:51:09 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id BD2323C0585; Tue, 5 Nov 2019 06:51:09 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 5 Nov 2019 06:51:09 +0100 From: Eugeniu Rosca To: Ulf Hansson , Adrian Hunter , Wolfram Sang , CC: Linus Walleij , Mathieu Malaterre , Pavel Machek , , , Eugeniu Rosca , Eugeniu Rosca Subject: [PATCH 2/3] mmc: host: Compress 'fixed-emmc-driver-type' handling Date: Tue, 5 Nov 2019 06:50:14 +0100 Message-ID: <20191105055015.23656-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105055015.23656-1-erosca@de.adit-jv.com> References: <20191105055015.23656-1-erosca@de.adit-jv.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.72.93.184] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare for reading two additional OF properties (inspired from "fixed-emmc-driver-type"): - fixed-emmc-driver-type-hs200 - fixed-emmc-driver-type-hs400 The parsing mechanism is common too all three, thus factored out. The only functional change is a tiny update in the error message. Cc: Wolfram Sang Signed-off-by: Eugeniu Rosca --- drivers/mmc/core/host.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 105b7a7c0251..54abfdfc69ba 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -161,6 +161,20 @@ static void mmc_retune_timer(struct timer_list *t) mmc_retune_needed(host); } +static void mmc_of_read_drv_type(struct mmc_host *host, char *prop, u32 *val) +{ + struct device *dev = host->parent; + u32 drv_type; + + if (device_property_read_u32(dev, prop, &drv_type)) + return; + + if (host->caps & MMC_CAP_NONREMOVABLE) + *val = drv_type; + else + dev_err(dev, "can't use %s, media is removable\n", prop); +} + /** * mmc_of_parse() - parse host's device-tree node * @host: host whose node should be parsed. @@ -173,7 +187,7 @@ static void mmc_retune_timer(struct timer_list *t) int mmc_of_parse(struct mmc_host *host) { struct device *dev = host->parent; - u32 bus_width, drv_type, cd_debounce_delay_ms; + u32 bus_width, cd_debounce_delay_ms; int ret; bool cd_cap_invert, cd_gpio_invert = false; bool ro_cap_invert, ro_gpio_invert = false; @@ -321,13 +335,7 @@ int mmc_of_parse(struct mmc_host *host) host->caps2 |= MMC_CAP2_NO_MMC; /* Must be after "non-removable" check */ - if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) { - if (host->caps & MMC_CAP_NONREMOVABLE) - host->fixed_drv_type = drv_type; - else - dev_err(host->parent, - "can't use fixed driver type, media is removable\n"); - } + mmc_of_read_drv_type(host, "fixed-emmc-driver-type", &host->fixed_drv_type); host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); if (host->dsr_req && (host->dsr & ~0xffff)) { -- 2.23.0