From patchwork Fri Feb 17 20:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 58774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp63230wrn; Fri, 17 Feb 2023 12:54:04 -0800 (PST) X-Google-Smtp-Source: AK7set9N4797oLq/AcUhiJ3yMnn+h/pdR8UZRqFXKhkwDHqvhEAm4qrcfWKTJqBF93sxRScMsHl5 X-Received: by 2002:a05:6a20:69a2:b0:c7:24c5:fb90 with SMTP id t34-20020a056a2069a200b000c724c5fb90mr7747322pzk.27.1676667244317; Fri, 17 Feb 2023 12:54:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676667244; cv=none; d=google.com; s=arc-20160816; b=Tppe3ZTqItTuZ0sj0uEXkrEfVszBwLTYPtwrr8fBXTfsBMAQMuKP7TenrmHVYam8ai LKati495KxhsPDTrCeqw4/J12XtfvS2R4+rx7vTrUEiPoD9S2OGDve1CBir369bkxxiM jIEufFpdSo6N4R1VtUcyvd9dNBdoNIZwcQwBqbMF7fRgtG1plXZIlwyO2l8vy1jRQzfQ W8BvpPs2XP7XGuehwFse5B9Ma/TUU45E9AfgGwLmqADgUkioRYVVW/xu9VekMYdsSwRb tLRLD7WCGSfBOCt0REfXQqxOaY0GBckeC7sZ5I9OstBFQ9gOeWv5KrbGad/KLoo8offc lj6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=fuH69jlg4LfV23Zo8j5+//LYri3/03zc86yy3z3HRPo=; b=sCZ4OTE83rS1T4KNuZ4NVtE3J7J07KfZq8Q4dvlqO/TZR58ohkk4FIj/bgc1iHJOW+ ukxusZClgDj0Ulj9Dl1AIeuoytXQsAM/PyO1PdLGnSlWEr5jc9VgyQT6WCsfGSLStxzz IrgDWmguWl2y9hgOBvNuTQLlJBZB4WZqz0eLnNs4d4ruev/o8CvbVQrJk5JW/z26ZHXb h+WSnAfOGctCRZaSlNkn4STXe038+V2OkxsRzlo1/57V6SIotm0e7GhO9C16cs8VtA6i AcDGTqc2DSbTXOC1dX8pKf4L4naeyoHK4Fvz8YNYdO9TJ10VwDMnFATeDXPcLxLpOs0C czqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q131-20020a632a89000000b004fc1c09c79csi4917607pgq.122.2023.02.17.12.53.41; Fri, 17 Feb 2023 12:54:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229784AbjBQUqU (ORCPT + 99 others); Fri, 17 Feb 2023 15:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjBQUqQ (ORCPT ); Fri, 17 Feb 2023 15:46:16 -0500 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 474696242D; Fri, 17 Feb 2023 12:46:15 -0800 (PST) Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-17172b43531so2621898fac.1; Fri, 17 Feb 2023 12:46:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fuH69jlg4LfV23Zo8j5+//LYri3/03zc86yy3z3HRPo=; b=DmLcMxfbzjZzqTZMuWIs8+AK4rqKvcBJuCywGj9AMlnyjkxy+CdehVCGXkze6fkNgw 9S8Lky9R/sxUz28fTZ4iAY76JQwCPcY4X0Gir+1zRbAvjWsMkuI+4waGbR02/lGp4HUi JihBvoMCdb12Q55+ArzcvCfEwDFF9K14Pn5ZKP70glKl3KdjAfPL4zYS70KzJhxFNM0Y Uh7VdAAlktJ9vMRmUT1Am2WYO5jb+ddl9xxSTLOGfTanPsL2CyqqjOy8Nu+xU4CXiF++ 8sHw7jFhadEiL4NAkyh5/pdVKEnwfJ5122N8XDGZ0CoZs1YAPeTZ59b/Ii1kmo/YFwjE iDNQ== X-Gm-Message-State: AO0yUKX2o9iu6a3LfUGkrgK5nxGEV091dB/KNq5BznUGC01ClLJTP3Cm gIcESiO2BvzYYng7cYlcgw3I9RA61Q== X-Received: by 2002:a05:6870:d287:b0:16e:87e6:4699 with SMTP id d7-20020a056870d28700b0016e87e64699mr3625235oae.55.1676666774060; Fri, 17 Feb 2023 12:46:14 -0800 (PST) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id nx18-20020a056870be9200b0017197602990sm175332oab.11.2023.02.17.12.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 12:46:13 -0800 (PST) Received: (nullmailer pid 1527514 invoked by uid 1000); Fri, 17 Feb 2023 20:46:11 -0000 From: Rob Herring Date: Fri, 17 Feb 2023 14:45:40 -0600 Subject: [PATCH 1/3] spi: mpc5xxx-psc: Remove unused platform_data MIME-Version: 1.0 Message-Id: <20230217-dt-mpc5xxx-spi-v1-1-3be8602fce1e@kernel.org> References: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> In-Reply-To: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758113032168653771?= X-GMAIL-MSGID: =?utf-8?q?1758113032168653771?= The platform_data for the MPC5xxx PSC SPI controllers is never used, so remove it and the resulting code which depends on it. Signed-off-by: Rob Herring --- drivers/spi/spi-mpc512x-psc.c | 28 ++++------------------------ drivers/spi/spi-mpc52xx-psc.c | 39 +++------------------------------------ 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 03630359ce70..0b4d49ef84de 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -22,7 +22,6 @@ #include #include #include -#include #include enum { @@ -51,8 +50,6 @@ enum { __ret; }) struct mpc512x_psc_spi { - void (*cs_control)(struct spi_device *spi, bool on); - /* driver internal data */ int type; void __iomem *psc; @@ -128,26 +125,16 @@ static void mpc512x_psc_spi_activate_cs(struct spi_device *spi) mps->bits_per_word = cs->bits_per_word; if (spi->cs_gpiod) { - if (mps->cs_control) - /* boardfile override */ - mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0); - else - /* gpiolib will deal with the inversion */ - gpiod_set_value(spi->cs_gpiod, 1); + /* gpiolib will deal with the inversion */ + gpiod_set_value(spi->cs_gpiod, 1); } } static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi) { - struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); - if (spi->cs_gpiod) { - if (mps->cs_control) - /* boardfile override */ - mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); - else - /* gpiolib will deal with the inversion */ - gpiod_set_value(spi->cs_gpiod, 0); + /* gpiolib will deal with the inversion */ + gpiod_set_value(spi->cs_gpiod, 0); } } @@ -474,7 +461,6 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, u32 size, unsigned int irq) { - struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct mpc512x_psc_spi *mps; struct spi_master *master; int ret; @@ -490,12 +476,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, mps->type = (int)of_device_get_match_data(dev); mps->irq = irq; - if (pdata) { - mps->cs_control = pdata->cs_control; - master->bus_num = pdata->bus_num; - master->num_chipselect = pdata->max_chipselect; - } - master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; master->setup = mpc512x_psc_spi_setup; master->prepare_transfer_hardware = mpc512x_psc_spi_prep_xfer_hw; diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index 609311231e64..604868df913c 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -28,10 +27,6 @@ #define MCLK 20000000 /* PSC port MClk in hz */ struct mpc52xx_psc_spi { - /* fsl_spi_platform data */ - void (*cs_control)(struct spi_device *spi, bool on); - u32 sysclk; - /* driver internal data */ struct mpc52xx_psc __iomem *psc; struct mpc52xx_psc_fifo __iomem *fifo; @@ -101,17 +96,6 @@ static void mpc52xx_psc_spi_activate_cs(struct spi_device *spi) ccr |= (MCLK / 1000000 - 1) & 0xFF; out_be16((u16 __iomem *)&psc->ccr, ccr); mps->bits_per_word = cs->bits_per_word; - - if (mps->cs_control) - mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0); -} - -static void mpc52xx_psc_spi_deactivate_cs(struct spi_device *spi) -{ - struct mpc52xx_psc_spi *mps = spi_master_get_devdata(spi->master); - - if (mps->cs_control) - mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); } #define MPC52xx_PSC_BUFSIZE (MPC52xx_PSC_RFNUM_MASK + 1) @@ -220,14 +204,9 @@ int mpc52xx_psc_spi_transfer_one_message(struct spi_controller *ctlr, m->actual_length += t->len; spi_transfer_delay_exec(t); - - if (cs_change) - mpc52xx_psc_spi_deactivate_cs(spi); } m->status = status; - if (status || !cs_change) - mpc52xx_psc_spi_deactivate_cs(spi); mpc52xx_psc_spi_transfer_setup(spi, NULL); @@ -269,7 +248,7 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) int ret; /* default sysclk is 512MHz */ - mclken_div = (mps->sysclk ? mps->sysclk : 512000000) / MCLK; + mclken_div = 512000000 / MCLK; ret = mpc52xx_set_psc_clkdiv(psc_id, mclken_div); if (ret) return ret; @@ -317,7 +296,6 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, u32 size, unsigned int irq, s16 bus_num) { - struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct mpc52xx_psc_spi *mps; struct spi_master *master; int ret; @@ -333,19 +311,8 @@ static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; mps->irq = irq; - if (pdata == NULL) { - dev_warn(dev, - "probe called without platform data, no cs_control function will be called\n"); - mps->cs_control = NULL; - mps->sysclk = 0; - master->bus_num = bus_num; - master->num_chipselect = 255; - } else { - mps->cs_control = pdata->cs_control; - mps->sysclk = pdata->sysclk; - master->bus_num = pdata->bus_num; - master->num_chipselect = pdata->max_chipselect; - } + master->bus_num = bus_num; + master->num_chipselect = 255; master->setup = mpc52xx_psc_spi_setup; master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message; master->cleanup = mpc52xx_psc_spi_cleanup; From patchwork Fri Feb 17 20:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 58776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp64087wrn; Fri, 17 Feb 2023 12:56:32 -0800 (PST) X-Google-Smtp-Source: AK7set++M5Ceglqn1dkO0xKGyg+AGMe9iKc2SUDfj6aXtw7K9NM5iJbJqohH4Ir7qExnlP1qhWUH X-Received: by 2002:a17:906:344c:b0:8b1:7e23:5041 with SMTP id d12-20020a170906344c00b008b17e235041mr3926651ejb.39.1676667392282; Fri, 17 Feb 2023 12:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676667392; cv=none; d=google.com; s=arc-20160816; b=b7+QYbIAWDEmLeRJisCXCLerwEytn319AULr8rkv9+p0No6yyGZyOvNPEx/CfEOPZ5 nK2NvBXxPA2HjqDFDV3CauOqlRaCe2BGhQIFewnDXvubM/kwch9dN/E4oWIcYwFzfaLu a7+KbVsb43tDTp4CUZMNnIYWXcuE8CfZo3iibaugUFFeK89+UR4QesLttqNkMQvuD1ns UqbRxT8+oI9trRVznZdrKOI3YTwlvval5adBMVYvEqtoXt1bMixCVUzD2/EYEX26zwDA gdgoOUW7SA9Gmc/9MoE/hU1dMDbBz1CG61q5OxvDj5TTdu8UFmoUD8XUYaVNNP8WbZgb GZDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=Y/Gw+GAu+WGGIPgicZpYCmsAgNJBx9NIhrdXTbIwsPE=; b=CMGOutkBfdQ7KSX9YGffIZYRmqZtLkSHQyQx/e0t4+p4PdRhlY6FXx4/UV0TCT9U8C S4Zi1LrrI4DRYE0TOz7ATpKtTmZ8WOSeSZX+dsEL8hpSE3L/y2P5pDoy1Mc46JAQFC1w lJnzJxp+WHdfLE0LwFmgUyKgjPQREYByByibfGLQ5NQ7oRxJkUwDANU2tZ3o9SudMZMN YmiFKDiLFSuD4XuFrKPT2lzw4lpnizshLcsVls3fGUUQBGHvpzXaEKX0ZYnF2+veYah2 5aZCCnJ9Man/apz0Tf0kps6LUM7arM9UynRRf6aQeVa5uE230+/0F6xM3SFBX+JfbPW7 tRtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a056402048100b004ad6fc891ddsi4707310edv.505.2023.02.17.12.56.08; Fri, 17 Feb 2023 12:56:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229893AbjBQUq1 (ORCPT + 99 others); Fri, 17 Feb 2023 15:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjBQUqS (ORCPT ); Fri, 17 Feb 2023 15:46:18 -0500 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AE95970C; Fri, 17 Feb 2023 12:46:17 -0800 (PST) Received: by mail-ot1-f41.google.com with SMTP id e18-20020a056830201200b0068bd8c1e836so416314otp.3; Fri, 17 Feb 2023 12:46:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y/Gw+GAu+WGGIPgicZpYCmsAgNJBx9NIhrdXTbIwsPE=; b=NHnABYxzLo/L4jvr2154HuhMEiSz2HV1gPdrm91i2awn7G9iXUVICZHlFe/Mn39uVG TpKZy8UlV50FaPsMTTAIijtpp53LmITGKFvO3LHZK/nSPHJWijjYVGlsP9MCWFpX+UKY dkurvjXftqNsynrmLZnMydWmAgYorJDDhcvO2GGu40TxcEkTDTgtZnv8Trv2BR3m5Da9 rH5wvjRo1JY80JOHeSHhPCjcmgahaLim8aNe08r8kkJqVp3diQwvEqpUYRGzEo/sgn5G +o63QxN/JejsGA+c2vLvG5Y626NwVkJJAPZbiVmPYENsm+Ylf1GlMw/KjD+SQH+Yxroj UnvQ== X-Gm-Message-State: AO0yUKVXYqsNrF+fHGzyD2qpFwEWoJsGfkoSTSU8rYOF7yzh/Nc1iYWz +iRFtGfz3S8TBdCVbwNNsgW73HgeUA== X-Received: by 2002:a9d:7d86:0:b0:690:d50a:9b48 with SMTP id j6-20020a9d7d86000000b00690d50a9b48mr4355269otn.11.1676666776689; Fri, 17 Feb 2023 12:46:16 -0800 (PST) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id p14-20020a056830130e00b0068bb7bd2668sm2277988otq.73.2023.02.17.12.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 12:46:16 -0800 (PST) Received: (nullmailer pid 1527516 invoked by uid 1000); Fri, 17 Feb 2023 20:46:11 -0000 From: Rob Herring Date: Fri, 17 Feb 2023 14:45:41 -0600 Subject: [PATCH 2/3] spi: mpc5xxx-psc: Convert probe to use devres functions MIME-Version: 1.0 Message-Id: <20230217-dt-mpc5xxx-spi-v1-2-3be8602fce1e@kernel.org> References: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> In-Reply-To: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758113187627414204?= X-GMAIL-MSGID: =?utf-8?q?1758113187627414204?= Convert the mpc52xx-psc and mpc512x-psc drivers to use the managed devres variants of functions in probe. Also use dev_err_probe() as appropriate. With this, the error handling can be simplified. Signed-off-by: Rob Herring --- drivers/spi/spi-mpc512x-psc.c | 22 +++++++----------- drivers/spi/spi-mpc52xx-psc.c | 53 ++++++++----------------------------------- 2 files changed, 18 insertions(+), 57 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 0b4d49ef84de..c6a610b82d4a 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -467,7 +467,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, void *tempp; struct clk *clk; - master = spi_alloc_master(dev, sizeof(*mps)); + master = devm_spi_alloc_master(dev, sizeof(*mps)); if (master == NULL) return -ENOMEM; @@ -486,28 +486,24 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->dev.of_node = dev->of_node; tempp = devm_ioremap(dev, regaddr, size); - if (!tempp) { - dev_err(dev, "could not ioremap I/O port range\n"); - ret = -EFAULT; - goto free_master; - } + if (!tempp) + return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); mps->psc = tempp; mps->fifo = (struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc)); ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED, "mpc512x-psc-spi", mps); if (ret) - goto free_master; + return ret; init_completion(&mps->txisrdone); clk = devm_clk_get(dev, "mclk"); - if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - goto free_master; - } + if (IS_ERR(clk)) + return PTR_ERR(clk); + ret = clk_prepare_enable(clk); if (ret) - goto free_master; + return ret; mps->clk_mclk = clk; mps->mclk_rate = clk_get_rate(clk); @@ -535,8 +531,6 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, clk_disable_unprepare(mps->clk_ipg); free_mclk_clock: clk_disable_unprepare(mps->clk_mclk); -free_master: - spi_master_put(master); return ret; } diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index 604868df913c..7477fa152da0 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c @@ -300,7 +300,7 @@ static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, struct spi_master *master; int ret; - master = spi_alloc_master(dev, sizeof(*mps)); + master = devm_spi_alloc_master(dev, sizeof(*mps)); if (master == NULL) return -ENOMEM; @@ -318,42 +318,24 @@ static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, master->cleanup = mpc52xx_psc_spi_cleanup; master->dev.of_node = dev->of_node; - mps->psc = ioremap(regaddr, size); - if (!mps->psc) { - dev_err(dev, "could not ioremap I/O port range\n"); - ret = -EFAULT; - goto free_master; - } + mps->psc = devm_ioremap(dev, regaddr, size); + if (!mps->psc) + return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); /* On the 5200, fifo regs are immediately ajacent to the psc regs */ mps->fifo = ((void __iomem *)mps->psc) + sizeof(struct mpc52xx_psc); - ret = request_irq(mps->irq, mpc52xx_psc_spi_isr, 0, "mpc52xx-psc-spi", - mps); + ret = devm_request_irq(dev, mps->irq, mpc52xx_psc_spi_isr, 0, + "mpc52xx-psc-spi", mps); if (ret) - goto free_master; + return ret; ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); - if (ret < 0) { - dev_err(dev, "can't configure PSC! Is it capable of SPI?\n"); - goto free_irq; - } - - init_completion(&mps->done); - - ret = spi_register_master(master); if (ret < 0) - goto free_irq; - - return ret; + return dev_err_probe(dev, ret, "can't configure PSC! Is it capable of SPI?\n"); -free_irq: - free_irq(mps->irq, mps); -free_master: - if (mps->psc) - iounmap(mps->psc); - spi_master_put(master); + init_completion(&mps->done); - return ret; + return devm_spi_register_master(dev, master); } static int mpc52xx_psc_spi_of_probe(struct platform_device *op) @@ -385,20 +367,6 @@ static int mpc52xx_psc_spi_of_probe(struct platform_device *op) irq_of_parse_and_map(op->dev.of_node, 0), id); } -static int mpc52xx_psc_spi_of_remove(struct platform_device *op) -{ - struct spi_master *master = spi_master_get(platform_get_drvdata(op)); - struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); - - spi_unregister_master(master); - free_irq(mps->irq, mps); - if (mps->psc) - iounmap(mps->psc); - spi_master_put(master); - - return 0; -} - static const struct of_device_id mpc52xx_psc_spi_of_match[] = { { .compatible = "fsl,mpc5200-psc-spi", }, { .compatible = "mpc5200-psc-spi", }, /* old */ @@ -409,7 +377,6 @@ MODULE_DEVICE_TABLE(of, mpc52xx_psc_spi_of_match); static struct platform_driver mpc52xx_psc_spi_of_driver = { .probe = mpc52xx_psc_spi_of_probe, - .remove = mpc52xx_psc_spi_of_remove, .driver = { .name = "mpc52xx-psc-spi", .of_match_table = mpc52xx_psc_spi_of_match, From patchwork Fri Feb 17 20:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 58775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp63501wrn; Fri, 17 Feb 2023 12:54:48 -0800 (PST) X-Google-Smtp-Source: AK7set9yTwHgSV6AG8w1H7sgLlp3DKymgp3OSfH3OGpu8iVc274SinqJJyZMenRyv8KYhr/ZpAJx X-Received: by 2002:a17:906:dac1:b0:8b1:2b8b:a1fa with SMTP id xi1-20020a170906dac100b008b12b8ba1famr2746917ejb.47.1676667288413; Fri, 17 Feb 2023 12:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676667288; cv=none; d=google.com; s=arc-20160816; b=FMJpq/qcrjqlGiqCZNwb88qNxvRGNJ007dvqExF/Lc3GXxDdtH2gr3ADI48AjHAViQ m+0tSDqenGTGJQ+eNken2ox4xPtUW2d7XC9e1kv/nNwbKIyMN+hJ1tFf6B7YRH7PKw32 fWqmiZvUsVxxCX603y8wLe8tW/SuiI2/j1KZ1JAgwncxMA7hJE/Mht2YgTwB2Wm6IMGD QGv1N4AajTRY/GVs0VSGCQ3S5W2Y8OX5+zI1DCNeeVBguIvTAkPVDtfZzlmkQDxZCjes QURDSXCl51fgsTROoVXJmz5ZgGJchtDvnES7tQ9yAh2DpbhaARySpF2HTXJVSoQeCjfw Y34w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=PpKp+66L0fbbAMKQqh8biegp8ez57RhVOVDRZ2wuGL8=; b=RqYq0aqVHvEgCHdVr1yIvO+RzsRc81S0628wWU4O0CKDTE+Yo3jH4ZtRAx0cqJl+DI f1oqlAqXaQP4eVw2fxGPU5LZKJny6MPkIXP0N5Vwql/pzV3ZPRLPjEQ8SlSJfkl+A/H9 SI0GQf6af/bLPfCJpS9A1EiHiRTe1belUOK+Ir9prsfK2FXwuc01XZrhvolfnNyhVAtJ vqQe6dwxD517WwQ29QduL3bdXyKjZnhL/F2Mryjv0ehQfwH4ec/y3uC0XhZmTilMbN4B 4rq4qpyaDvJEH8i9/YPb7FLtDfqnjv8FUnTLpbpSp/k3yerHe/9UBCIou/s3uG3Ngog1 Apvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id if6-20020a170906df4600b008b1ce6f5811si3319775ejc.345.2023.02.17.12.54.21; Fri, 17 Feb 2023 12:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229880AbjBQUqY (ORCPT + 99 others); Fri, 17 Feb 2023 15:46:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjBQUqS (ORCPT ); Fri, 17 Feb 2023 15:46:18 -0500 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 839F062FC8; Fri, 17 Feb 2023 12:46:16 -0800 (PST) Received: by mail-oi1-f179.google.com with SMTP id bk11so2351237oib.13; Fri, 17 Feb 2023 12:46:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PpKp+66L0fbbAMKQqh8biegp8ez57RhVOVDRZ2wuGL8=; b=ktySaqwp5fN3rKGlFGqdVib8KFofGzxEip+SZXBMuHkAloj3vAFP9G6yad1OG2qtkB /5haMWz4qe4DG4+y31zHrlnCKBhwakQwuThEwMG50LOnQLXf20aBqglSyizZDjtb0a0J Bl2s5VxtDcPv23wZuwHyGfHxryR0DZ4QJl9f3tQdg0pKWPncwRpY8yjkOUU/9HwgSJtL wwnNDMPANOdpffq/X2Hfdut9ddl6D8pzlrx+Pcp3woOiRbiX1LQlOR32tKZHPXxJmfOQ Mjt72IA85Kudfy3HllnUOZmcSA1LBFzIJYRiwcslBdPTfw9fZx7T5LG/JbnBXRlTk649 t15g== X-Gm-Message-State: AO0yUKXjfwDgFyequo0TFhDnmP0sbPu1eHeHOOO0RkvUwCld/dlUGGin fQW989DGNl/RXdaKnQCYhvd9r4P1+w== X-Received: by 2002:a05:6808:288f:b0:37a:fcd6:5c09 with SMTP id eu15-20020a056808288f00b0037afcd65c09mr141201oib.49.1676666775463; Fri, 17 Feb 2023 12:46:15 -0800 (PST) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id es25-20020a056808279900b0035a9003b8edsm2193359oib.40.2023.02.17.12.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 12:46:15 -0800 (PST) Received: (nullmailer pid 1527518 invoked by uid 1000); Fri, 17 Feb 2023 20:46:11 -0000 From: Rob Herring Date: Fri, 17 Feb 2023 14:45:42 -0600 Subject: [PATCH 3/3] spi: mpc5xxx-psc: Use platform resources instead of parsing DT properties MIME-Version: 1.0 Message-Id: <20230217-dt-mpc5xxx-spi-v1-3-3be8602fce1e@kernel.org> References: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> In-Reply-To: <20230217-dt-mpc5xxx-spi-v1-0-3be8602fce1e@kernel.org> To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758113078542038871?= X-GMAIL-MSGID: =?utf-8?q?1758113078542038871?= The mpc52xx-psc and mpc512x-psc drivers use DT property parsing functions for 'reg' and 'interrupts', but those are available as platform device resources. Convert probe functions to use them and simplify probe to a single function. For 'cell-index', also use the preferred typed property function. Signed-off-by: Rob Herring --- drivers/spi/spi-mpc512x-psc.c | 40 ++++++++-------------------------- drivers/spi/spi-mpc52xx-psc.c | 50 +++++++++++-------------------------------- 2 files changed, 21 insertions(+), 69 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index c6a610b82d4a..5bdfe4a740e9 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -14,11 +14,9 @@ #include #include #include -#include -#include -#include #include #include +#include #include #include #include @@ -458,9 +456,9 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) return IRQ_NONE; } -static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, - u32 size, unsigned int irq) +static int mpc512x_psc_spi_of_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct mpc512x_psc_spi *mps; struct spi_master *master; int ret; @@ -473,8 +471,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, dev_set_drvdata(dev, master); mps = spi_master_get_devdata(master); - mps->type = (int)of_device_get_match_data(dev); - mps->irq = irq; + mps->type = (int)device_get_match_data(dev); master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; master->setup = mpc512x_psc_spi_setup; @@ -485,12 +482,14 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->cleanup = mpc512x_psc_spi_cleanup; master->dev.of_node = dev->of_node; - tempp = devm_ioremap(dev, regaddr, size); + tempp = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); if (!tempp) return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); mps->psc = tempp; mps->fifo = (struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc)); + + mps->irq = platform_get_irq(pdev, 0); ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED, "mpc512x-psc-spi", mps); if (ret) @@ -535,9 +534,9 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, return ret; } -static int mpc512x_psc_spi_do_remove(struct device *dev) +static int mpc512x_psc_spi_of_remove(struct platform_device *pdev) { - struct spi_master *master = dev_get_drvdata(dev); + struct spi_master *master = dev_get_drvdata(&pdev->dev); struct mpc512x_psc_spi *mps = spi_master_get_devdata(master); clk_disable_unprepare(mps->clk_mclk); @@ -546,27 +545,6 @@ static int mpc512x_psc_spi_do_remove(struct device *dev) return 0; } -static int mpc512x_psc_spi_of_probe(struct platform_device *op) -{ - const u32 *regaddr_p; - u64 regaddr64, size64; - - regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); - if (!regaddr_p) { - dev_err(&op->dev, "Invalid PSC address\n"); - return -EINVAL; - } - regaddr64 = of_translate_address(op->dev.of_node, regaddr_p); - - return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64, - irq_of_parse_and_map(op->dev.of_node, 0)); -} - -static int mpc512x_psc_spi_of_remove(struct platform_device *op) -{ - return mpc512x_psc_spi_do_remove(&op->dev); -} - static const struct of_device_id mpc512x_psc_spi_of_match[] = { { .compatible = "fsl,mpc5121-psc-spi", .data = (void *)TYPE_MPC5121 }, { .compatible = "fsl,mpc5125-psc-spi", .data = (void *)TYPE_MPC5125 }, diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index 7477fa152da0..95a4a511c388 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c @@ -11,15 +11,14 @@ #include #include #include -#include -#include +#include +#include #include #include #include #include #include #include -#include #include #include @@ -292,12 +291,12 @@ static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) return IRQ_NONE; } -/* bus_num is used only for the case dev->platform_data == NULL */ -static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, - u32 size, unsigned int irq, s16 bus_num) +static int mpc52xx_psc_spi_of_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct mpc52xx_psc_spi *mps; struct spi_master *master; + u32 bus_num; int ret; master = devm_spi_alloc_master(dev, sizeof(*mps)); @@ -310,20 +309,24 @@ static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, /* the spi->mode bits understood by this driver: */ master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST; - mps->irq = irq; - master->bus_num = bus_num; + ret = of_property_read_u32(dev->of_node, "cell-index", &bus_num); + if (ret || bus_num > 5) + return dev_err_probe(dev, ret ? : -EINVAL, "Invalid cell-index property\n"); + master->bus_num = bus_num + 1; + master->num_chipselect = 255; master->setup = mpc52xx_psc_spi_setup; master->transfer_one_message = mpc52xx_psc_spi_transfer_one_message; master->cleanup = mpc52xx_psc_spi_cleanup; master->dev.of_node = dev->of_node; - mps->psc = devm_ioremap(dev, regaddr, size); + mps->psc = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); if (!mps->psc) return dev_err_probe(dev, -EFAULT, "could not ioremap I/O port range\n"); /* On the 5200, fifo regs are immediately ajacent to the psc regs */ mps->fifo = ((void __iomem *)mps->psc) + sizeof(struct mpc52xx_psc); + mps->irq = platform_get_irq(pdev, 0); ret = devm_request_irq(dev, mps->irq, mpc52xx_psc_spi_isr, 0, "mpc52xx-psc-spi", mps); if (ret) @@ -338,35 +341,6 @@ static int mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, return devm_spi_register_master(dev, master); } -static int mpc52xx_psc_spi_of_probe(struct platform_device *op) -{ - const u32 *regaddr_p; - u64 regaddr64, size64; - s16 id = -1; - - regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL); - if (!regaddr_p) { - dev_err(&op->dev, "Invalid PSC address\n"); - return -EINVAL; - } - regaddr64 = of_translate_address(op->dev.of_node, regaddr_p); - - /* get PSC id (1..6, used by port_config) */ - if (op->dev.platform_data == NULL) { - const u32 *psc_nump; - - psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL); - if (!psc_nump || *psc_nump > 5) { - dev_err(&op->dev, "Invalid cell-index property\n"); - return -EINVAL; - } - id = *psc_nump + 1; - } - - return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, - irq_of_parse_and_map(op->dev.of_node, 0), id); -} - static const struct of_device_id mpc52xx_psc_spi_of_match[] = { { .compatible = "fsl,mpc5200-psc-spi", }, { .compatible = "mpc5200-psc-spi", }, /* old */