From patchwork Thu Apr 25 17:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13643591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBE8CC4345F for ; Thu, 25 Apr 2024 17:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jIlspmiIwWaySm1V49aMF//znkQjAprRd81xvUK5GgA=; b=R1j89s87m2/ByL Wj1kKRdycGhDo9f8VEylqVmVPwLDd1X6Qt1R1YUala4hgzgZkjAtAsfaM8aQyEM8FWOzAD5piquGq KGgoQsLTqHDn9MX6uCbjesY/fC0WoHFxOgy+swtRdNw3I4iK1EUpRDfSE0kYi3iLPKOfr8aVSYAAP 3s0NYQVrJ0pUMhWCaWJtlziW4KIrH5xTutJSlSkrtTUaEqUaXOWvh2Nj6nSrS/mkiBcmN9zPrlcvc eBC1bnS7kcqkAmvpfjxI/YZn7XvnrOBzoNwTx4+Ub4UXx9pBmjt7USNuo2HivaAQzzrJc4ZaG8Vfc OwrH4/PsrK1CseF7q47g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02aq-00000009W71-3Ni6; Thu, 25 Apr 2024 17:09:08 +0000 Received: from mgamail.intel.com ([192.198.163.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02ao-00000009W5S-1u2V for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2024 17:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714064946; x=1745600946; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6/9sO9GFWOtUcX+qVb91FNhPTDtt7A0IxEGeFO8MRB4=; b=evC2b2kXQtnIthKjPw+j4ePKR8hEWMA4/2aAj4ws2uPYvWshlV7TdHg6 S54DKHqG0Am/fvUANrlmszCUeiJ8Zxen8l5Av+tvWpfbZPUsPSOZ12CdB Sw4gaEHef3pxepQDZbkjiPmgkom//weeE9FrauWznxcpM9/Zb6N6yJN4V sWwHk9JQbIs71aOWGFTozNuBKaysMdb1eytZ2RJ8xQJOOFZEZyrkkc42c yBcmm4zEWJt4cVzIkD2NyyS+BdHS2YkeQhI06pYmEtl/x+1JcKk92uWHD ruECAzLSdaSlH0FfM8LgeYX+TBZ0ZJFGD4ZS6uktvci34ZS7OIOYazTNc Q==; X-CSE-ConnectionGUID: 8xUxq8UGREaRX6h4qr5vyw== X-CSE-MsgGUID: NJveIfvxS9S9Sb1vK4JTwA== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="13554446" X-IronPort-AV: E=Sophos;i="6.07,230,1708416000"; d="scan'208";a="13554446" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2024 10:09:04 -0700 X-CSE-ConnectionGUID: A7RDrk70SrC9wW9Ti6eYng== X-CSE-MsgGUID: b3d9/hPPTBuJlM+wJhImhQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,230,1708416000"; d="scan'208";a="29595990" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 25 Apr 2024 10:09:02 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8343787; Thu, 25 Apr 2024 20:09:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] mmc: atmel-mci: Incapsulate used to be a platform data into host structure Date: Thu, 25 Apr 2024 20:08:44 +0300 Message-ID: <20240425170900.3767990-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240425170900.3767990-1-andriy.shevchenko@linux.intel.com> References: <20240425170900.3767990-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240425_100906_531300_077BA266 X-CRM114-Status: GOOD ( 19.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aubin Constans , Ulf Hansson , Alexandre Belloni , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After platform data is gone, we always allocate memory for the slot information. Incapsulate the array of the latter into the host structure, so we allocate memory only once. This makes code simpler. Signed-off-by: Andy Shevchenko --- drivers/mmc/host/atmel-mci.c | 61 ++++++++++++++---------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 3aed57c392fa..9ae3ce14db50 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -224,14 +224,6 @@ struct mci_slot_pdata { bool non_removable; }; -/** - * struct mci_platform_data - board-specific MMC/SDcard configuration - * @slot: Per-slot configuration data. - */ -struct mci_platform_data { - struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS]; -}; - struct atmel_mci_caps { bool has_dma_conf_reg; bool has_pdc; @@ -297,6 +289,7 @@ struct atmel_mci_dma { * @mapbase: Physical address of the MMIO registers. * @mck: The peripheral bus clock hooked up to the MMC controller. * @dev: Device associated with the MMC controller. + * @pdata: Per-slot configuration data. * @slot: Slots sharing this MMC controller. * @caps: MCI capabilities depending on MCI version. * @prepare_data: function to setup MCI before data transfer which @@ -375,6 +368,7 @@ struct atmel_mci { struct clk *mck; struct device *dev; + struct mci_slot_pdata pdata[ATMCI_MAX_NR_SLOTS]; struct atmel_mci_slot *slot[ATMCI_MAX_NR_SLOTS]; struct atmel_mci_caps caps; @@ -630,11 +624,11 @@ static const struct of_device_id atmci_dt_ids[] = { MODULE_DEVICE_TABLE(of, atmci_dt_ids); -static struct mci_platform_data *atmci_of_init(struct device *dev) +static int atmci_of_init(struct atmel_mci *host) { + struct device *dev = host->dev; struct device_node *np = dev->of_node; struct device_node *cnp; - struct mci_platform_data *pdata; u32 slot_id; int err; @@ -643,10 +637,6 @@ static struct mci_platform_data *atmci_of_init(struct device *dev) return ERR_PTR(-EINVAL); } - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - for_each_child_of_node(np, cnp) { if (of_property_read_u32(cnp, "reg", &slot_id)) { dev_warn(dev, "reg property is missing for %pOF\n", cnp); @@ -661,38 +651,38 @@ static struct mci_platform_data *atmci_of_init(struct device *dev) } if (of_property_read_u32(cnp, "bus-width", - &pdata->slot[slot_id].bus_width)) - pdata->slot[slot_id].bus_width = 1; + &host->pdata[slot_id].bus_width)) + host->pdata[slot_id].bus_width = 1; - pdata->slot[slot_id].detect_pin = + host->pdata[slot_id].detect_pin = devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp), "cd", GPIOD_IN, "cd-gpios"); - err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin); + err = PTR_ERR_OR_ZERO(host->pdata[slot_id].detect_pin); if (err) { if (err != -ENOENT) { of_node_put(cnp); - return ERR_PTR(err); + return err; } - pdata->slot[slot_id].detect_pin = NULL; + host->pdata[slot_id].detect_pin = NULL; } - pdata->slot[slot_id].non_removable = + host->pdata[slot_id].non_removable = of_property_read_bool(cnp, "non-removable"); - pdata->slot[slot_id].wp_pin = + host->pdata[slot_id].wp_pin = devm_fwnode_gpiod_get(dev, of_fwnode_handle(cnp), "wp", GPIOD_IN, "wp-gpios"); - err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].wp_pin); + err = PTR_ERR_OR_ZERO(host->pdata[slot_id].wp_pin); if (err) { if (err != -ENOENT) { of_node_put(cnp); - return ERR_PTR(err); + return err; } - pdata->slot[slot_id].wp_pin = NULL; + host->pdata[slot_id].wp_pin = NULL; } } - return pdata; + return 0; } static inline unsigned int atmci_get_version(struct atmel_mci *host) @@ -2456,7 +2446,6 @@ static void atmci_get_cap(struct atmel_mci *host) static int atmci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct mci_platform_data *pdata; struct atmel_mci *host; struct resource *regs; unsigned int nr_slots; @@ -2467,12 +2456,6 @@ static int atmci_probe(struct platform_device *pdev) if (!regs) return -ENXIO; - pdata = atmci_of_init(dev); - if (IS_ERR(pdata)) { - dev_err(dev, "platform data not available\n"); - return PTR_ERR(pdata); - } - irq = platform_get_irq(pdev, 0); if (irq < 0) return irq; @@ -2485,6 +2468,10 @@ static int atmci_probe(struct platform_device *pdev) spin_lock_init(&host->lock); INIT_LIST_HEAD(&host->queue); + ret = atmci_of_init(host); + if (ret) + return dev_err_probe(dev, ret, "Slot information not available\n"); + host->mck = devm_clk_get(dev, "mci_clk"); if (IS_ERR(host->mck)) return PTR_ERR(host->mck); @@ -2544,16 +2531,16 @@ static int atmci_probe(struct platform_device *pdev) /* We need at least one slot to succeed */ nr_slots = 0; ret = -ENODEV; - if (pdata->slot[0].bus_width) { - ret = atmci_init_slot(host, &pdata->slot[0], + if (host->pdata[0].bus_width) { + ret = atmci_init_slot(host, &host->pdata[0], 0, ATMCI_SDCSEL_SLOT_A, ATMCI_SDIOIRQA); if (!ret) { nr_slots++; host->buf_size = host->slot[0]->mmc->max_req_size; } } - if (pdata->slot[1].bus_width) { - ret = atmci_init_slot(host, &pdata->slot[1], + if (host->pdata[1].bus_width) { + ret = atmci_init_slot(host, &host->pdata[1], 1, ATMCI_SDCSEL_SLOT_B, ATMCI_SDIOIRQB); if (!ret) { nr_slots++; From patchwork Thu Apr 25 17:08:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13643593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBDB8C4345F for ; Thu, 25 Apr 2024 17:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O1ynmo8vczOfecm8kfBU/wMXypln4rtxiG4hdyk0YtY=; b=rOjuBdN5HhHhdb O+zxhR37ZOFTCMNTLX3uVNNH/Q1utpXTdsfqcKY11ejfNtAxSCX9vciR+wCNtyzm120rbjwP6p5E5 elKurKyNAWkDJVVI+RiKhxRcWr9YmvRwX+IfKNPB8MJxKwi7VW/AJUTH0IJMWyaNoIi9gs/9Dz6H8 2FVssbRrNkbNy07sl/FIzrJHIf837S4dbdmEAHr+/7ZHpO1uJkxHA9gfrMWRPDf3PYOffACLirV+o lZzuBxa8kn0mCYQ/m4utrNKjZcgFKMTEjstaGrXwHZQmjiIlg/i9WTxgCrYq7aba8xQVvO56GqlQq asrTl1pivFAN7K7S7ebg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02az-00000009W9f-3Yz0; Thu, 25 Apr 2024 17:09:17 +0000 Received: from mgamail.intel.com ([192.198.163.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s02ao-00000009W5T-37Jc for linux-arm-kernel@lists.infradead.org; Thu, 25 Apr 2024 17:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714064946; x=1745600946; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Poecu4f5dpmnBhjDNs+GIeQe2EIjAchr4YDeOe285sY=; b=GNmuC1cVmCvGBfkul0kjpLqN5Ojv9qlnrItTTWFG+TWSmmGPtwOex85v OiTZzrV7X4YtM4nE3IK/653Y2BJGaLIq2lwMZSBpjn4kT+nOMHhz4nNNA 1NlTAsaeUQvr60Ng2w+qLFQBl4pKv3aJVDrDCc/Qj4bOmVm2AtY4egNph 9I8roF9Vnxl7zWoflKAQ9zcHI7Ml1gXCp5Y+IlRyBqM1nOJjrMEl7kBRq Ncq6Na2/uvlrFMxoM73gPMNggC0lXYNGSo9aZvmeuUemJ4iHg9drARt/t xiaNRR2r2uyUSXcDdkwHcAV9mTSE/8q2yzqxj1znmuNbH8O3vsbBLFAsC g==; X-CSE-ConnectionGUID: C4Q5ZVZZSjaYd4lBaLIZaw== X-CSE-MsgGUID: 9CSVuoYJTCCJWX0BvXHjxw== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="9618906" X-IronPort-AV: E=Sophos;i="6.07,230,1708416000"; d="scan'208";a="9618906" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2024 10:09:04 -0700 X-CSE-ConnectionGUID: LqkwhMLARgq9KjVdNaAqPw== X-CSE-MsgGUID: X+Lavs6MTwqvEI8THCiJtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,230,1708416000"; d="scan'208";a="29945986" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 25 Apr 2024 10:09:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8B5E75B2; Thu, 25 Apr 2024 20:09:01 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] mmc: atmel-mci: Switch to use dev_err_probe() Date: Thu, 25 Apr 2024 20:08:45 +0300 Message-ID: <20240425170900.3767990-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240425170900.3767990-1-andriy.shevchenko@linux.intel.com> References: <20240425170900.3767990-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240425_100906_825429_AFCF6547 X-CRM114-Status: GOOD ( 11.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Aubin Constans , Ulf Hansson , Alexandre Belloni , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Switch to use dev_err_probe() to simplify the error path and unify a message template. Signed-off-by: Andy Shevchenko --- drivers/mmc/host/atmel-mci.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 9ae3ce14db50..8199d9620075 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -632,10 +632,8 @@ static int atmci_of_init(struct atmel_mci *host) u32 slot_id; int err; - if (!np) { - dev_err(dev, "device node not found\n"); - return ERR_PTR(-EINVAL); - } + if (!np) + return dev_err_probe(dev, -EINVAL, "device node not found\n"); for_each_child_of_node(np, cnp) { if (of_property_read_u32(cnp, "reg", &slot_id)) { @@ -2551,7 +2549,7 @@ static int atmci_probe(struct platform_device *pdev) } if (!nr_slots) { - dev_err(dev, "init failed: no slot defined\n"); + dev_err_probe(dev, ret, "init failed: no slot defined\n"); goto err_init_slot; } @@ -2560,8 +2558,7 @@ static int atmci_probe(struct platform_device *pdev) &host->buf_phys_addr, GFP_KERNEL); if (!host->buffer) { - ret = -ENOMEM; - dev_err(dev, "buffer allocation failed\n"); + ret = dev_err_probe(dev, -ENOMEM, "buffer allocation failed\n"); goto err_dma_alloc; } }