Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2222399imm; Thu, 7 Jun 2018 07:17:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIlB163FA9p7NtX83FTFbLMz8OnqB8NgDqSmx/OHLWjWrt4UZlNDpuYHccjKoCXqK6wEdg X-Received: by 2002:a63:61d6:: with SMTP id v205-v6mr1768109pgb.432.1528381078239; Thu, 07 Jun 2018 07:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528381078; cv=none; d=google.com; s=arc-20160816; b=mWNtl/2mH4+XWY45bqzV4RIWPU+lHylTkWH/aPMbUi27tEJDzIIvVbzVuH5ouj8cM3 ZKi58/nzuchQVb6lVPMtpUWlEcMiajkdOqd5fy0YLeNNaA9VcQ8C0u96moG2Cux8PcXe d/nNEyuulpxrsOUEQdLgmCI2IBpHKA2QqqE0PBdgg8G9bUzwHsWYIizWCAi+N8BPVus5 PfyX+EvWhVvWL9DhnFd9eqFeRwNTAQzG1Jzzeyn22pD5OyduSZ/3p5zgxR7tlxn8renw jwCEtxG40tslMrskJmUXAawrYpC2aD45lm5fRFIQ2zQzw60P4AMhfynKOXJR76gQ+/+Z wRgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=P9rdQkB9TNDEGu2pz0a6M2dk6z/rA3jf1UzfMzWpgK4=; b=G2rhd8DekMJDPAI9PFnKDGYqlDia73MXVh8+am8upqDMHoP2dQ3LsC+h0lB5lhHk9s el/Y35xShu5DVnJT5o+4JyfZcRPHB8zt3ziA/j7CJ/UeaOsi1KWCpQjbk1FQ8nCmPQAx tMDRieUqsXdy1Su3AyvFHZHTt3/h+6z78+/fqMNJNztZMFh8J3NZkaaQt65CQ0Mfz27/ ZNPEBO+kEpUtv5Q6uuUUZ9Ni9lorvc/jVT5U3qNE7YAdvxMNtGuM0x95K+6vfcejDzd4 kdqG2LllnEBPx6WBsqvbCVnkH9vfv6iZf9hyiMf4Zasyooh4PxggvuAhLepRF5Z8vR9T eOUQ== 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 b2-v6si10029208pgt.611.2018.06.07.07.17.44; Thu, 07 Jun 2018 07:17:58 -0700 (PDT) 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 S933335AbeFGOQW (ORCPT + 99 others); Thu, 7 Jun 2018 10:16:22 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39557 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933101AbeFGOJO (ORCPT ); Thu, 7 Jun 2018 10:09:14 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbD-0005Zk-FH; Thu, 07 Jun 2018 15:09:11 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbA-00039q-Fr; Thu, 07 Jun 2018 15:09:08 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Shawn Lin" , "Ulf Hansson" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 302/410] mmc: dw_mmc: Factor out dw_mci_init_slot_caps In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Lin commit a4faa4929ed3be15e2d500d2405f992f6dedc8eb upstream. Factor out dw_mci_init_slot_caps to consolidate parsing all differents types of capabilities from host contrllers. No functional change intended. Signed-off-by: Shawn Lin Fixes: 800d78bfccb3 ("mmc: dw_mmc: add support for implementation specific callbacks") Signed-off-by: Ulf Hansson [bwh: Backported to 3.16: - We don't set MMC_CAP_ERASE or MMC_CAP2_SDIO_IRQ_NOTHREAD capabilities - Fold in required changes to the exit path from commits 51da2240906c "mmc: dw_mmc: use mmc_regulator_get_supply to handle regulators" and 3cf890fc42b2 "mmc: dw_mmc: Pass back errors from mmc_of_parse()" - Adjust context] Signed-off-by: Ben Hutchings --- --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2044,12 +2044,40 @@ static struct device_node *dw_mci_of_fin } #endif /* CONFIG_OF */ +static int dw_mci_init_slot_caps(struct dw_mci_slot *slot) +{ + struct dw_mci *host = slot->host; + const struct dw_mci_drv_data *drv_data = host->drv_data; + struct mmc_host *mmc = slot->mmc; + int ctrl_id; + + if (host->pdata->caps) + mmc->caps = host->pdata->caps; + + if (host->pdata->pm_caps) + mmc->pm_caps = host->pdata->pm_caps; + + if (host->dev->of_node) { + ctrl_id = of_alias_get_id(host->dev->of_node, "mshc"); + if (ctrl_id < 0) + ctrl_id = 0; + } else { + ctrl_id = to_platform_device(host->dev)->id; + } + if (drv_data && drv_data->caps) + mmc->caps |= drv_data->caps[ctrl_id]; + + if (host->pdata->caps2) + mmc->caps2 = host->pdata->caps2; + + return 0; +} + static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) { struct mmc_host *mmc; struct dw_mci_slot *slot; - const struct dw_mci_drv_data *drv_data = host->drv_data; - int ctrl_id, ret; + int ret; u32 freq[2]; mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), host->dev); @@ -2076,27 +2104,12 @@ static int dw_mci_init_slot(struct dw_mc mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; - if (host->pdata->caps) - mmc->caps = host->pdata->caps; - - if (host->pdata->pm_caps) - mmc->pm_caps = host->pdata->pm_caps; - - if (host->dev->of_node) { - ctrl_id = of_alias_get_id(host->dev->of_node, "mshc"); - if (ctrl_id < 0) - ctrl_id = 0; - } else { - ctrl_id = to_platform_device(host->dev)->id; - } - if (drv_data && drv_data->caps) - mmc->caps |= drv_data->caps[ctrl_id]; - - if (host->pdata->caps2) - mmc->caps2 = host->pdata->caps2; - mmc_of_parse(mmc); + ret = dw_mci_init_slot_caps(slot); + if (ret) + goto err_host_allocated; + if (host->pdata->blk_settings) { mmc->max_segs = host->pdata->blk_settings->max_segs; mmc->max_blk_size = host->pdata->blk_settings->max_blk_size; @@ -2127,7 +2140,7 @@ static int dw_mci_init_slot(struct dw_mc ret = mmc_add_host(mmc); if (ret) - goto err_setup_bus; + goto err_host_allocated; #if defined(CONFIG_DEBUG_FS) dw_mci_init_debugfs(slot); @@ -2138,9 +2151,9 @@ static int dw_mci_init_slot(struct dw_mc return 0; -err_setup_bus: +err_host_allocated: mmc_free_host(mmc); - return -EINVAL; + return ret; } static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id)