From patchwork Fri May 3 17:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13653149 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 2239CC4345F for ; Fri, 3 May 2024 17:04:03 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0vmOiFIYoMP8ipiPPtKzsVKe3OHLDnlqXhMOEo53x8Y=; b=XWnb1AHNuk0S5n i5jjmoFWChAcZb7qDd613s4F5SyEfFCppZJoWIxIGfwv42DGp8mXlFf49pRIQjA27An0DwF6eP/yI 1SXdzJY5jTPzMU1bLBFECmMhr2nWX3jqo0yablYrXJ8ZLIKUa0YCtfZOqTQl+XhJb/xqiDyPgQvil 4fP8t4OuHVvkCx6x26YL2ojO4kx4RgrreVzeiNUA+XZxcHfgOWXUjr/1tODIvaGcrteHz1h4u0eXd +8rlWQvrgPxo7Wz4EAUVYTuB6R8mESJ93sHhNg8wwisGBNufzDyPOnzAUGJKAnIf+cEUrdDoJT+DU /tsoxn/3PCjnGtHxkCuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2wK6-0000000HJsh-1umD; Fri, 03 May 2024 17:03:50 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2wK2-0000000HJs9-2hyD for linux-arm-kernel@lists.infradead.org; Fri, 03 May 2024 17:03:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2052C61DD7; Fri, 3 May 2024 17:03:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39073C116B1; Fri, 3 May 2024 17:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714755824; bh=ebY4raDCgXSCqHp41gpFuMzedeR8oJ9TC1L5bdF4D+Y=; h=From:To:Cc:Subject:Date:From; b=pxnJX/jQwnHsK1otuXwC8ozxaflrpYLSnxvGbhCo/A9cYiDTRrgk5KuADScWnv+ZV lzXVgc+z2LC8nLF0B3+qd6abZQobu4aAT/bV/D07fVvapdJj2mgoMVusVo1p67FzIi BVWI+6qSl2OO75O9ic6YCqc+n9zQPUlw19I5PrYA3N/jxor9fKoDsR5iTYAP3zvMtI bkf7zyhK7WsmrmNi9S965g+1aLJKV6VUicnXrpXGyhnHzRX2n4NWisLD0oZOgeonMz feDeMhpuKo3UV1LQ3mRcNNybl2xe1yMQptSfXda3XGy9M8RN5ld1sfVCBr8EYWYlxm whdX6Re0dOhJw== From: Lorenzo Bianconi To: linux-spi@vger.kernel.org Cc: broonie@kernel.org, andy.shevchenko@gmail.com, lorenzo.bianconi83@gmail.com, linux-arm-kernel@lists.infradead.org, upstream@airoha.com Subject: [PATCH] spi: airoha: initialize as_ctrl at pointer declaration Date: Fri, 3 May 2024 19:03:08 +0200 Message-ID: <580665ed95340031d0d42d1a4a16f7fcd5d150d7.1714755642.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_100346_799562_21C67EF8 X-CRM114-Status: GOOD ( 14.64 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch introduces just two cosmetic changes to airoha spi-nand driver: - move airoha_snand_ids definition after airoha_snand_probe routine - always initialize airoha_snand_ctrl pointer similar to airoha_snand_dev one Signed-off-by: Lorenzo Bianconi Reviewed-by: Andy Shevchenko --- drivers/spi/spi-airoha-snfi.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c index 9d97ec98881c..7fc3be6d4a6a 100644 --- a/drivers/spi/spi-airoha-snfi.c +++ b/drivers/spi/spi-airoha-snfi.c @@ -638,9 +638,9 @@ static ssize_t airoha_snand_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { struct spi_device *spi = desc->mem->spi; + struct airoha_snand_ctrl *as_ctrl = spi_controller_get_devdata(spi->controller); struct airoha_snand_dev *as_dev = spi_get_ctldata(spi); struct spi_mem_op *op = &desc->info.op_tmpl; - struct airoha_snand_ctrl *as_ctrl; u32 val, rd_mode; int err; @@ -661,7 +661,6 @@ static ssize_t airoha_snand_dirmap_read(struct spi_mem_dirmap_desc *desc, break; } - as_ctrl = spi_controller_get_devdata(spi->controller); err = airoha_snand_set_mode(as_ctrl, SPI_MODE_DMA); if (err < 0) return err; @@ -768,13 +767,12 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, const void *buf) { struct spi_device *spi = desc->mem->spi; + struct airoha_snand_ctrl *as_ctrl = spi_controller_get_devdata(spi->controller); struct airoha_snand_dev *as_dev = spi_get_ctldata(spi); struct spi_mem_op *op = &desc->info.op_tmpl; - struct airoha_snand_ctrl *as_ctrl; u32 wr_mode, val; int err; - as_ctrl = spi_controller_get_devdata(spi->controller); err = airoha_snand_set_mode(as_ctrl, SPI_MODE_MANUAL); if (err < 0) return err; @@ -885,12 +883,12 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc, static int airoha_snand_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) { - struct airoha_snand_dev *as_dev = spi_get_ctldata(mem->spi); + struct spi_device *spi = mem->spi; + struct airoha_snand_ctrl *as_ctrl = spi_controller_get_devdata(spi->controller); + struct airoha_snand_dev *as_dev = spi_get_ctldata(spi); u8 data[8], cmd, opcode = op->cmd.opcode; - struct airoha_snand_ctrl *as_ctrl; int i, err; - as_ctrl = spi_controller_get_devdata(mem->spi->controller); if (opcode == SPI_NAND_OP_PROGRAM_EXECUTE && op->addr.val == as_dev->cur_page_num) { as_dev->data_need_update = true; @@ -965,11 +963,9 @@ static const struct spi_controller_mem_ops airoha_snand_mem_ops = { static int airoha_snand_setup(struct spi_device *spi) { - struct airoha_snand_ctrl *as_ctrl; + struct airoha_snand_ctrl *as_ctrl = spi_controller_get_devdata(spi->controller); struct airoha_snand_dev *as_dev; - as_ctrl = spi_controller_get_devdata(spi->controller); - as_dev = devm_kzalloc(as_ctrl->dev, sizeof(*as_dev), GFP_KERNEL); if (!as_dev) return -ENOMEM; @@ -994,10 +990,9 @@ static int airoha_snand_setup(struct spi_device *spi) static void airoha_snand_cleanup(struct spi_device *spi) { + struct airoha_snand_ctrl *as_ctrl = spi_controller_get_devdata(spi->controller); struct airoha_snand_dev *as_dev = spi_get_ctldata(spi); - struct airoha_snand_ctrl *as_ctrl; - as_ctrl = spi_controller_get_devdata(spi->controller); dma_unmap_single(as_ctrl->dev, as_dev->dma_addr, as_dev->buf_len, DMA_BIDIRECTIONAL); spi_set_ctldata(spi, NULL); @@ -1049,12 +1044,6 @@ static const struct regmap_config spi_nfi_regmap_config = { .max_register = REG_SPI_NFI_SNF_NFI_CNFG, }; -static const struct of_device_id airoha_snand_ids[] = { - { .compatible = "airoha,en7581-snand" }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, airoha_snand_ids); - static int airoha_snand_probe(struct platform_device *pdev) { struct airoha_snand_ctrl *as_ctrl; @@ -1114,6 +1103,12 @@ static int airoha_snand_probe(struct platform_device *pdev) return devm_spi_register_controller(dev, ctrl); } +static const struct of_device_id airoha_snand_ids[] = { + { .compatible = "airoha,en7581-snand" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, airoha_snand_ids); + static struct platform_driver airoha_snand_driver = { .driver = { .name = "airoha-spi",