From patchwork Thu May 30 15:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680541 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AF1E17D8A0; Thu, 30 May 2024 15:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081885; cv=none; b=dqPJGdJK8eX4NxQBlPNda8vM3SzQYKXdRjUIm6hcpHokNS7VPnp3/p6tT/gYHWgygL957nbLL0252vVg/oRdVQeG2OcnNcoRVMrOvxOiwFOapPIdpEsl7htu/2C78xRoaKJUjqHjGJNj5hjyqGYkOt2gtFJT3bpVS1SROP78JgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081885; c=relaxed/simple; bh=k3Jy0JpJWn+p7UbeUn2JOtEhZjdt6wmsCwt1uObyvpA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lpR6kWvYKKv/MUrUP64A7MHT6VVk/E1PHs5k2o/j0/EOBwDcRDIOnf7JS1VfSMvfMkr3Qxeb2FawTBCzyeakL+5AzTdRXma679GGpUaGwbwa1LJw7UhQIAVhC0PjPNlAo10ny76ujBjkekjRGXEsbqrz3DpqE9eYfqzOGf/TjgQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZmScHrAw; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZmScHrAw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081883; x=1748617883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k3Jy0JpJWn+p7UbeUn2JOtEhZjdt6wmsCwt1uObyvpA=; b=ZmScHrAw3M+hFiIrvptF5EaBYlM8ZCjf81yaddD0i6nMmB09CmPUwAdS ALbsn9QOp0vcGiPs711vSG/EKMYQuKJ6j3aZLZbTnnTJCFagIjKIQpckl aSPvPxSXiOMue5F5cCJq46Am+ATEJ4bpRaX6Z3TsfLbpVaoDFIlOXoPWR OLQXtmPmVa2ViGgCXkXQunJylCUsyk/B1ouSTwPZ8lIYS+8X1V416nIzO CsoQgpcH4fYiZw0p/txG6+SkUtDdvY29yhDn+9HfMebEfkaSGEKUcprrn OgZo4dY140skcplqGQMtCxceZw1e2kPsixzIBE/pwbuAimB3bbvmGiZx6 Q==; X-CSE-ConnectionGUID: 88tGk9vWSoKQV/jRgiKYAA== X-CSE-MsgGUID: DWqNC1mSRum5pxfG87EjpA== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067913" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067913" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: ygWNtsUCSgCvlGSapsJ15A== X-CSE-MsgGUID: PLdcGkwCRzas9WXXnyuVnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329420" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2268B184; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 01/11] spi: pxa2xx: Wrap pxa_ssp_request() to be device managed resource Date: Thu, 30 May 2024 18:09:57 +0300 Message-ID: <20240530151117.1130792-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In the error path or remove path the reference counter in PXA SSP driver may be dropped before the other resources, that were allocated after bumbing the reference counter. This breaks reversed order of freeing and might have an undesired side effects. Prevent this from happening by wrapping pxa_ssp_request() to be device managed resource. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 50 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index efe76d0c21bb..820a3702447a 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1304,6 +1304,27 @@ pxa2xx_spi_init_ssp(struct platform_device *pdev, struct ssp_device *ssp, enum p return 0; } +static void pxa2xx_spi_ssp_release(void *ssp) +{ + pxa_ssp_free(ssp); +} + +static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) +{ + struct ssp_device *ssp; + int status; + + ssp = pxa_ssp_request(pdev->id, pdev->name); + if (!ssp) + return ssp; + + status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); + if (status) + return ERR_PTR(status); + + return ssp; +} + static struct pxa2xx_spi_controller * pxa2xx_spi_init_pdata(struct platform_device *pdev) { @@ -1331,11 +1352,11 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) type = (enum pxa_ssp_type)value; } else { - ssp = pxa_ssp_request(pdev->id, pdev->name); - if (ssp) { + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) type = ssp->type; - pxa_ssp_free(ssp); - } } /* Validate the SSP type correctness */ @@ -1420,7 +1441,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); - ssp = pxa_ssp_request(pdev->id, pdev->name); + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); if (!ssp) ssp = &platform_info->ssp; @@ -1431,11 +1454,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else controller = devm_spi_alloc_host(dev, sizeof(*drv_data)); + if (!controller) + return dev_err_probe(dev, -ENOMEM, "cannot alloc spi_controller\n"); - if (!controller) { - status = dev_err_probe(dev, -ENOMEM, "cannot alloc spi_controller\n"); - goto out_error_controller_alloc; - } drv_data = spi_controller_get_devdata(controller); drv_data->controller = controller; drv_data->controller_info = platform_info; @@ -1486,10 +1507,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) status = request_irq(ssp->irq, ssp_int, IRQF_SHARED, dev_name(dev), drv_data); - if (status < 0) { - dev_err_probe(dev, status, "cannot get IRQ %d\n", ssp->irq); - goto out_error_controller_alloc; - } + if (status < 0) + return dev_err_probe(dev, status, "cannot get IRQ %d\n", ssp->irq); /* Setup DMA if requested */ if (platform_info->enable_dma) { @@ -1619,8 +1638,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) pxa2xx_spi_dma_release(drv_data); free_irq(ssp->irq, drv_data); -out_error_controller_alloc: - pxa_ssp_free(ssp); return status; } @@ -1646,9 +1663,6 @@ static void pxa2xx_spi_remove(struct platform_device *pdev) /* Release IRQ */ free_irq(ssp->irq, drv_data); - - /* Release SSP */ - pxa_ssp_free(ssp); } static int pxa2xx_spi_suspend(struct device *dev) From patchwork Thu May 30 15:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680543 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23CB1183069; Thu, 30 May 2024 15:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081886; cv=none; b=L0Eq7JrRjvJewebE2hEaC0lcaibtbOAMz8dvrYY5lPix7AE2MUrBiQDu8XpFfxcC9uNd1Yym1w+qhKCRloSONWTOS6uzTPeJc0yxWEdMzeko1HxCwCSO5hu7fHy0a8dzTJDvnM088QbyMpyvw50uPJKPg41FISHtYq8oySz3JrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081886; c=relaxed/simple; bh=xuQ6DZkTEDRxFoGQhloOJPIufIaUVMudZOmQbEL7V4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lm/tP6lVYWg+yrKUPzBk2fbfGr9wkyLgfaG8gdjp4ignsFwwIAuf6Bh84I9We+u3kdlSkrnr/rDh9VElusEsX92TuFj0xo2bu1EWCplOXfkRhYIFl+p/cAxVETsKh+jBC616D5izq/GASyl+7aWHmBcJs+84ujZP8n01Rn34OUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QMnHOawy; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QMnHOawy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081885; x=1748617885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xuQ6DZkTEDRxFoGQhloOJPIufIaUVMudZOmQbEL7V4Q=; b=QMnHOawylzn5BpobWuukWsrntADyQKpMT//9lujXVWwgSSv+ozPvoXh/ WVdt6zd+f62f4+vc595dCuSpcW6puTe0dkLzpIYqMaItnw/T1U7HOzBjB sdKt04hQo/idrHa3RpkhmIP7smXbxfMkNAZVTcM3Hm4cV1/AbpcfdxDSl Z+88XSm3/2s39Cx0wyTJAJN2FuEajeOqmz+h76jHbYgg8h5XZ1/4c8OZj tn3y0/0RxgLNtcJK+mx2PcsuXA6BVRF7gDr9m4ShzhGkH9VSKfOFQAwRr rPs+KwnA4BEtMH6BDSgQ4c3wU07qxmM8yyX6e/izVfO/30SgOhI8k4jn2 w==; X-CSE-ConnectionGUID: igPybMNDQHGXLEI0PLk+wg== X-CSE-MsgGUID: 6j5A4VV8TyaimG7B+w1d6w== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067931" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067931" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: RHkbdXUlRvKwVAoxgpxB+g== X-CSE-MsgGUID: wsKMsGyIQ363d/2wS2JSeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329421" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2C1252DC; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 02/11] spi: pxa2xx: Reorganize the SSP type retrieval Date: Thu, 30 May 2024 18:09:58 +0300 Message-ID: <20240530151117.1130792-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The old Intel platforms, such as Intel Braswell, also provide the property of SSP type. Reorganize the pxa2xx_spi_init_pdata() to take that into account. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 820a3702447a..f4dc113768cd 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1331,19 +1331,21 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) struct pxa2xx_spi_controller *pdata; struct device *dev = &pdev->dev; struct device *parent = dev->parent; + const void *match = device_get_match_data(dev); enum pxa_ssp_type type = SSP_UNDEFINED; - struct ssp_device *ssp = NULL; - const void *match; + struct ssp_device *ssp; bool is_lpss_priv; u32 num_cs = 1; int status; - is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); - - match = device_get_match_data(dev); - if (match) - type = (uintptr_t)match; - else if (is_lpss_priv) { + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) { + type = ssp->type; + } else if (match) { + type = (enum pxa_ssp_type)(uintptr_t)match; + } else { u32 value; status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); @@ -1351,12 +1353,6 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) return ERR_PTR(status); type = (enum pxa_ssp_type)value; - } else { - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return ERR_CAST(ssp); - if (ssp) - type = ssp->type; } /* Validate the SSP type correctness */ @@ -1368,6 +1364,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) return ERR_PTR(-ENOMEM); /* Platforms with iDMA 64-bit */ + is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); if (is_lpss_priv) { pdata->tx_param = parent; pdata->rx_param = parent; From patchwork Thu May 30 15:09:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680540 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1292F186E38; Thu, 30 May 2024 15:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081884; cv=none; b=LqNU0Cnrt1Dd/q9jXIfbRYEi8qR13uYZn4qrGLE2EyqR0biT9u5SOPY+fmT/VrNUYdKtQRnto/P8dj5RsIddgRFGhT3fK/f9w5D2fzuwlsrYMlhAVircTcE7yMp862GmVBwpELd1Ylvqa5FzBMS1k+RCbZUtNxU+EpQ61VmSPZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081884; c=relaxed/simple; bh=TQxj52QzB21T4oND+oGj5zj9iueR9JjcCvK8NiCC4XM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CzRAWMn07wZmKdHiJZIve5OyWm/NVleZTDt1hDof4rJxkX4oOQieib1sePRDs6jFbbKiZarT84QJfwlCM+AixsUjFyRne51sD73mU23rFDSLZ+QVkgBy96eSmG4ryTxgEJlwQOfyChdCD/0I9Z0Vwlm2bJ9uh4skq7dFCDz8zd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=d5O0iuE4; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="d5O0iuE4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081883; x=1748617883; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TQxj52QzB21T4oND+oGj5zj9iueR9JjcCvK8NiCC4XM=; b=d5O0iuE4HOdEdVLfK7uYrohyvYml5731JHTwX70KjtnMlrJTmp20u53x 6vqcGd+JMGRjdmyDmUt7u6y5EHwpu1VhEogHNWZqt/BBhG6+FuE7btdwp Vr651/wU9CTrGsWbBDLaVzIIgYHmZC98W71JzLts11ZBigyc1rmA+CUp+ FYqZ1lRWfSzbCWY8G3EUMWF4Sdrb6TZzX+nHIscbDMxyeFwUgcrNgJ3Bo NBdGfE+jO70Xkos7w7fujoEu7Jv4GG/sy91DxTp5LcoriS9lrhREDRUY9 QURNilHH+Ng/6NwGoZb6KWbtyNx6IH1sLD2B7uvb86uZiSYEcHzXuVks4 Q==; X-CSE-ConnectionGUID: 9ObHPrdaS8KW6hufCLRqBw== X-CSE-MsgGUID: U9FPRV6MS3GcPsidT5PYzA== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093031" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093031" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: /FZZb/pJSWy8TGVnqxXSMA== X-CSE-MsgGUID: XT/+hSA9QyKUq3odAWBusg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288501" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3D9C44DE; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 03/11] spi: pxa2xx: Remove no more needed driver data Date: Thu, 30 May 2024 18:09:59 +0300 Message-ID: <20240530151117.1130792-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since the ACPI enumerated devices provide a property with SSP type, there is no more necessity to bear the copy of them in the ID table. Drop the driver data in ACPI ID table. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index f4dc113768cd..b62a613378e0 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1718,12 +1718,12 @@ static const struct dev_pm_ops pxa2xx_spi_pm_ops = { }; static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { - { "80860F0E", LPSS_BYT_SSP }, - { "8086228E", LPSS_BSW_SSP }, - { "INT33C0", LPSS_LPT_SSP }, - { "INT33C1", LPSS_LPT_SSP }, - { "INT3430", LPSS_LPT_SSP }, - { "INT3431", LPSS_LPT_SSP }, + { "80860F0E" }, + { "8086228E" }, + { "INT33C0" }, + { "INT33C1" }, + { "INT3430" }, + { "INT3431" }, {} }; MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); From patchwork Thu May 30 15:10:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680542 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C5617F51A; Thu, 30 May 2024 15:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081886; cv=none; b=pDTxdPE5IiCbzOvjYY3dQoCSIpA69Q8aQhL0BdLCfvt3ndlJjJT6k0CSt57vbetXo91OEvOIGuet1eWijceIByrZ417/u9/MfNtqXZgTbv8MSU2GhjPgQh//7Yg45GJHWNi3k0HObyRmEWO1MKj29UvEkLmJ43apWNJ8xAGJ/rY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081886; c=relaxed/simple; bh=Iq9RkCVt6cK9FjvsEVBSiepSsecDquk00YCQe7trEiE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rgA0Tsz6AmcLV7MkBq/Rk5gPKma2rBLO5qg52Vg4Wcumik6NwUJ3cyIuP38vBwDnEgQvLVvXdOh7nikqa67oAwcTQOLAG06R8okcSe7YxkY4pZDbKmdDDK5RO1isEatRuwh2j7Umwj1r3eYpIFX2u+uz5VNxOLUM/BLz16jg/do= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Yc01nAOy; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Yc01nAOy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081885; x=1748617885; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iq9RkCVt6cK9FjvsEVBSiepSsecDquk00YCQe7trEiE=; b=Yc01nAOyIL4YHSCkTUI2NORVogqajT1LmMnQAhmIRoeYA2Kfe15IOjIX haQswrBt5DW9/dApS1Ps4PZN5VETL9udDKASummTWWMiEq5ZLN/0Eez5W rNAbtwR6DC7Es7sYBHvGqZY4kobccChWRM4CBtHjA3h3dRreAaVjcoovc 4K99M8EV670Apap2pQ8G/8TZsINV+Jo7Yg0uGJTp8pv1hq6N6yNLwEvku akL+GkD/wC7XLLboLIcA7bZNO1gQvM60hxZ+sGLYL7bNDDb6spGuoQbao LHU920cZyg4EmMpNXGYUNYaKIbh0RGmsMQTqrvlBihzoDT+9SxiAERWR2 g==; X-CSE-ConnectionGUID: SHa4VpxOSDK0jhih79Jh5g== X-CSE-MsgGUID: VWUWFameSkGAO3zRYH+CXw== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093039" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093039" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: G8o5fUUqTo2Es22qCMzxKg== X-CSE-MsgGUID: /TE0xF6cRluJM0rR4Vu7wg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288500" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4322937D; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 04/11] spi: pxa2xx: Remove hard coded number of chip select pins Date: Thu, 30 May 2024 18:10:00 +0300 Message-ID: <20240530151117.1130792-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove hard coded number of chip select pins for Intel Braswell. This comes via property. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index b62a613378e0..53815aab41aa 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -99,7 +99,6 @@ struct lpss_config { /* Chip select control */ unsigned cs_sel_shift; unsigned cs_sel_mask; - unsigned cs_num; /* Quirks */ unsigned cs_clk_stays_gated : 1; }; @@ -137,7 +136,6 @@ static const struct lpss_config lpss_platforms[] = { .tx_threshold_hi = 224, .cs_sel_shift = 2, .cs_sel_mask = 1 << 2, - .cs_num = 2, }, { /* LPSS_SPT_SSP */ .offset = 0x200, @@ -1594,8 +1592,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) tmp &= LPSS_CAPS_CS_EN_MASK; tmp >>= LPSS_CAPS_CS_EN_SHIFT; platform_info->num_chipselect = ffz(tmp); - } else if (config->cs_num) { - platform_info->num_chipselect = config->cs_num; } } controller->num_chipselect = platform_info->num_chipselect; From patchwork Thu May 30 15:10:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680544 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E479183092; Thu, 30 May 2024 15:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081887; cv=none; b=V1IFi6Y9dEWRgKamt5x6uc057e/nrHACsAb7bRO5NwZ0wEGRnkxEztn3QMNu5NArcqgDtgXvlRaf5Us8qZ4c2htuh2ptHDNOQM9824QapIxMdFTi1JpzYBiLGWqqWECWYyxWCpHOo9jGATvRYbo8xgtIQ5CJh5uPD883UuhOjwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081887; c=relaxed/simple; bh=M+NbhDPEqKAfXCCJumrA9VHagNYen39iF9Q6cbbh/Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J+R/ltuLp9CVC0qiVtXOEZGcD4r08kFFnShRShxu+Zw22JAEe/qjGbkFiUrqDauiZ2Cy3Obx0hs2vmmUBOCLGdLkMpHLHcC37xgENMj1A7sQ20UV5mdu9lKTSM6hOfTZzi4lc4E+4WyHpK2W7nUoakkN10y6HjH4bxhnHrdLS30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dVqKUWX2; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dVqKUWX2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M+NbhDPEqKAfXCCJumrA9VHagNYen39iF9Q6cbbh/Yc=; b=dVqKUWX2xg8zg9bUpbFtGs5szUbFxp1CjO4CU8QNjIymmM+UVw9bG+tc xAVCB21KKhdChaiOWN8KYbcmYKbANh3UJrfNC10PVCBsqRBUPk+ql7qsw n5K/eLFnTm0TJ8P/wCTeDdp/h4TlSKLK3WFK838Ji6ncGpPnVgUaj/oMS 8kE6pgFu4gObBw9yLnFwEEObs6REb0OkT8s8KSriwkTMaWi7aF36NJczD wMipWgK7nYlpBdrlpYJ2sGdG/iqeq2QI0VinvWqsxbfQ7NUFu68ArAHGl kdu9c7yYxvSEIXuuBNJq6i0Wo5zxIRNoFk3JfD0026c4q5FrHOLwEiACF A==; X-CSE-ConnectionGUID: RVvFNXKdSAKoKYSPSHFGow== X-CSE-MsgGUID: kxOZJfLTTOSTRar7dxAGXw== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093050" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093050" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: qt//DRy9Sc+BayjLWr0qfw== X-CSE-MsgGUID: 55oDytf2S8+9oqMNTbMdmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288502" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 57AEF6AB; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 05/11] spi: pxa2xx: Utilise temporary variable for struct device Date: Thu, 30 May 2024 18:10:01 +0300 Message-ID: <20240530151117.1130792-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have a temporary variable to keep a pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 53815aab41aa..19ee7739f4bd 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1606,13 +1606,13 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } } - pm_runtime_set_autosuspend_delay(&pdev->dev, 50); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_set_autosuspend_delay(dev, 50); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); /* Register with the SPI framework */ - platform_set_drvdata(pdev, drv_data); + dev_set_drvdata(dev, drv_data); status = spi_register_controller(controller); if (status) { dev_err_probe(dev, status, "problem registering SPI controller\n"); @@ -1622,7 +1622,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) return status; out_error_pm_runtime_enabled: - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(dev); out_error_clock_enabled: clk_disable_unprepare(ssp->clk); @@ -1636,10 +1636,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) static void pxa2xx_spi_remove(struct platform_device *pdev) { - struct driver_data *drv_data = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; - pm_runtime_get_sync(&pdev->dev); + pm_runtime_get_sync(dev); spi_unregister_controller(drv_data->controller); @@ -1651,8 +1652,8 @@ static void pxa2xx_spi_remove(struct platform_device *pdev) if (drv_data->controller_info->enable_dma) pxa2xx_spi_dma_release(drv_data); - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(dev); + pm_runtime_disable(dev); /* Release IRQ */ free_irq(ssp->irq, drv_data); From patchwork Thu May 30 15:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680546 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86C8D18397C; Thu, 30 May 2024 15:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081888; cv=none; b=AieFGisc8nTtV55F2rAIhI1zyuyVaRuwasLtmBbY/WDub3QU/qTU93kXq2tZ+xKkPNAe4iN4mRE2o5Z+vz7unQbUjfa+SpysGNRdaLonOAaPJ0cJZF53xYOXl5mjojA1ESdtGoaN6aI9XtquFFg3tnpE35Crryjt8ywcLtWWG24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081888; c=relaxed/simple; bh=VtuiMejnZILT/hyIjcNOY30dlVGcZI/pZvafnR2kTW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qtq4Mtafgk/F+vHFer6EwRDgQva1Rdnwo8hxcbV+j7f79GyovlDgSUai155vs1VGal+RWUH8/nqGwuLT5SoIo4vJhtTq1rha5+9vBnqEFcRrdaCx1RBQ8QjwUMsmqZbgUH2St+at7hH3WertgKG6okDcG5KXWU8IAi1docDsLKU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kP8XQVQK; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kP8XQVQK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081887; x=1748617887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VtuiMejnZILT/hyIjcNOY30dlVGcZI/pZvafnR2kTW0=; b=kP8XQVQKKytQswSd5X1lf78c910hKf33lY6j8pJTw92/gAAdNDNv/lIv fhnQc6aOqzGEPsXxk2+in3oJr9QfzCtzIlDMQLCFtoweEsgsC72MVFbpr Roetf1EK+aWtmBLz2HRutOKKIU1/tuWnZ+UE4LkF70yb2/1/7gmM99/n5 UBFk2S017b08Kzcmuk3xae7vNryUsfPYYFe27AM9/3ScQhGX7cem9hjj6 JFnGG7UvfbG5cCJpLytSMsFIcbxcmluKZxyKHUotvOM6rxTyNIBCRpcPd CADT/1FfS2nuGhZllWZrN6YDb39ynb7QoKx1jUpn7x7p/yDFP3H5t2m9a A==; X-CSE-ConnectionGUID: jqnYpsmUQnWTr0EfaRQFPg== X-CSE-MsgGUID: YSkyMrx/RcyBAXhigPW7qA== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093063" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093063" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: UfNqA/KvRC27iVrFMnKkuA== X-CSE-MsgGUID: rivNWmNoRDSgY/osG8FgRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288503" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 62AE46CB; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 06/11] spi: pxa2xx: Print DMA burst size only when DMA is enabled Date: Thu, 30 May 2024 18:10:02 +0300 Message-ID: <20240530151117.1130792-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Print DMA burst size only when DMA is enabled to avoid making a false impression that DMA is enabled when it may be not. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 19ee7739f4bd..30a829b74a22 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1434,7 +1434,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) if (IS_ERR(platform_info)) return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); } - dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); ssp = pxa2xx_spi_ssp_request(pdev); if (IS_ERR(ssp)) @@ -1516,6 +1515,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) controller->max_dma_len = MAX_DMA_LEN; controller->max_transfer_size = pxa2xx_spi_max_dma_transfer_size; + + dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); } } From patchwork Thu May 30 15:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680548 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F28F81862A7; Thu, 30 May 2024 15:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081889; cv=none; b=WfgMoCGyaMcf7oDYuoxeOv3F4cfu7+OSo5xuYPcIbrFrWrFg2YU98OQbwfqjRCgWgXabjLGuWtTkj/9gArcVzXnJoLdDS8cSY9bJJOt+5xIyg6y3h5z4RvEwc3X6V9j6ltZtfJsoFi+Ywaeu73ihEwF/RaKEEIkKeUh2yhRBYHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081889; c=relaxed/simple; bh=KHmkxGTrimggz5XiV2P+I49lCexUOiH4Nb0XpNE5VMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pqp/y65JC0yksGr5KZdbckd9BhViB294BBYXLprrV9xEOnhgA1+v0BS81bQlZ9iypkPilzDwpJqtM2jcYKPjpD/Ki9fkJwLoESkJ6/xg1t/08QwB15BVAagtQPPw73cXt+iYL3hs0EOIH/dPvCuMsmmW75/iNoIeLM4o9z9xp0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AgfWg0T4; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AgfWg0T4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KHmkxGTrimggz5XiV2P+I49lCexUOiH4Nb0XpNE5VMs=; b=AgfWg0T4w7Wsz4TmEAbYFE7+y+mquoIsHbML8lWRVTaxzyjUda/x61+F J1BAPthBS1rVZYLTaxP/BAiec5ID5oDggbKKhCpa0Pto9y0TrcnBKPH54 HcNOWRRL2AfUcXqnx5wq4Cztw2UQG2Te0S+omgPKGFDDXFM6dtWaAmx+y W1zkdrzwAAOjv4rYzflnV2mQE1yIF7PpMMx0EEkv7l88OD7rxLiU/h3Pm OAZTrTFSwTYK/ttCfupGeWlnytL4roko1fyShQKq51Gi4VrQ9F4sK2VKi TYYa61tgXOZjiQSBIhlnX2DG1RgNoIYAMMEZuwK0Vyivsv8wBfSoogPNe A==; X-CSE-ConnectionGUID: vej+lL29TjOOlfY02kNEHg== X-CSE-MsgGUID: kwD5rdU9SgCTa2CVpD8Z2A== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067968" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067968" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: ZmLvxdsRRH2XteUsnIoQpw== X-CSE-MsgGUID: t+vO54S1RdSW0kg0YoLNBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329439" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 68409679; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 07/11] spi: pxa2xx: Remove duplicate check Date: Thu, 30 May 2024 18:10:03 +0300 Message-ID: <20240530151117.1130792-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The mmio_base can't be NULL at this point. It's either checked in both pxa_ssp_probe() and pxa2xx_spi_init_ssp() or correctly provided by PCI core. Hence, remove duplicate check which is a dead code. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 30a829b74a22..9724d9455837 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1441,9 +1441,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) if (!ssp) ssp = &platform_info->ssp; - if (!ssp->mmio_base) - return dev_err_probe(dev, -ENODEV, "failed to get SSP\n"); - if (platform_info->is_target) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else From patchwork Thu May 30 15:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680545 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87D4E183980; Thu, 30 May 2024 15:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081887; cv=none; b=ICxELE5ndVayJMLc92gqfxXy6RlemN2JjvvS0wy9y8NdswdYsnY3SoUIBJiZstCiuuI9XRmET/dlUp00MeX4k/479Xd5RQg54qy3sy71GbvnovJdnD84mWyxAO+xqIC+BXuA1u4ugsLrGxi4ke8y2giHAYb9Qn2vFmaXmIkzuBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081887; c=relaxed/simple; bh=YN44JYZqoEKQIIQ+HPXBPHzx9SDRMV97fZqyIcUXYdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oorUHBUy1jR+vG3kTTB17MHOo8dasK/b+36yJQrolUg51jPhZWTqbOtiLwWVsa5KTm4HuUjb8XJ+gIWD7/Dzg1un11tgT/sLOpTOOz6qHhU0f8uGan9wuwotdWzqStbHzAg42vSh6sFDuOXOhbKFhQfts7z0qNsulJZI/tdAQR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=EA7ZgozL; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="EA7ZgozL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YN44JYZqoEKQIIQ+HPXBPHzx9SDRMV97fZqyIcUXYdE=; b=EA7ZgozLJMcJKCzKyI4/NpdG+wfYwgAz6n/FEXXi3ikB46RJfrFmCul8 53P1XDHV/Ymn1NUDLx98EFatBUVA8i9e3hGKuXPn2xcynC8pQHVgiTfY7 JPkQWMoGojjGGyG+KT5rS0gUH5PCRpeSk0ZasDJRpzRa41mTNvNYEeTn4 kSqJCVqOov+2pq/7nyJ6VM0JRTnPvKAiZuU8s1hhx8VBdp9ZZqZJF9hEs 93NlObs/RGeR3uhu8XYgWT4w4bMckrmUgQeKhf1vpfGMGJrHfv3uhlN77 Hk+O7a4h/ud4pdfTFLcKuJyWILkI3/6lSe0o2DrpQjtFiWuJZJ8YJ3FTq A==; X-CSE-ConnectionGUID: tDhQ02EAT3uRY4b1VUgk4w== X-CSE-MsgGUID: knrqNqEBT+SeyLYKr6ab4w== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067948" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067948" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: s1k/pvsFTLmW63bqcbIURg== X-CSE-MsgGUID: ZULTayxvTv6OSYz0zy9cQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329437" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7677D700; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 08/11] spi: pxa2xx: Remove superflous check for Intel Atom SoCs Date: Thu, 30 May 2024 18:10:04 +0300 Message-ID: <20240530151117.1130792-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pxa2xx_spi_fw_translate_cs() checks for the ACPI companion device presence along with the SSP type. But the SSP type is uniquely determines the case. Hence remove the superflous check. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 9724d9455837..3c03a8cd9ee6 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1393,23 +1393,19 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller, { struct driver_data *drv_data = spi_controller_get_devdata(controller); - if (has_acpi_companion(drv_data->ssp->dev)) { - switch (drv_data->ssp_type) { - /* - * For Atoms the ACPI DeviceSelection used by the Windows - * driver starts from 1 instead of 0 so translate it here - * to match what Linux expects. - */ - case LPSS_BYT_SSP: - case LPSS_BSW_SSP: - return cs - 1; + switch (drv_data->ssp_type) { + /* + * For some of Intel Atoms the ACPI DeviceSelection used by the Windows + * driver starts from 1 instead of 0 so translate it here to match what + * Linux expects. + */ + case LPSS_BYT_SSP: + case LPSS_BSW_SSP: + return cs - 1; - default: - break; - } + default: + return cs; } - - return cs; } static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) From patchwork Thu May 30 15:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680547 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E76718398D; Thu, 30 May 2024 15:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081888; cv=none; b=BmEL/GNZQD2p29FswTXneQy+7r3R8pvgkZUBDvd84aGQwAUOuMnPmw/RdXRd3Dwz5RnzKPCzU/YrpEgla9pidG4GbswZ8C35glJLJvk1VS7mPD5R6KO6CfLz2Sp3NMJBWoP23qv1oxQTCKut3ckVmP1/X+9bDkWWCnPDy/d6lxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081888; c=relaxed/simple; bh=cyTnsqcupVXst0FyS+yA1egD0GK0RbG+Gy/mnXGgt3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EHXMaqzSf1Pi0Uip7ur0wcjze/3PB1+RKQapGpTCym5tJEUlAUrLKRE3TahnlQ1SQPcALFbmJsXDPy1Fl2zyP2LxSj7lw3bT2aq1DiOLqzRfcIXC+ji7Dlbup6TlEa5dXhFRwa2KzFXlE8BemiVpDXCbTU3dup6Upfvk6/cCGfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=I45hPJ27; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="I45hPJ27" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cyTnsqcupVXst0FyS+yA1egD0GK0RbG+Gy/mnXGgt3g=; b=I45hPJ2713fkO4tvlkToMiOVMjhUGF/1lO+9VheENaK0KtgG8V/5g6Yf xnLmfBfQT0Kvci8nEWxgh22ZJNbP5iqdFA1AZ1RuyM0/QxYuAi5jb1LbQ lnU/tR/mGMHl7238SFQUS3a29ntLfc+WalN5lbnS+9swp4oPKX/dnkxie 4E8xIg7Bvd+osjXjG08giMSwc3jk6e64mpa8XL3PAHjccU04rO5Fkwiet lfKnvG4kuUNLmmdgeeG6CM5DuwDnNAjC7P21v6yfr3Y4x+h7ctLutXMjn U4WM4aZdQ3PYp1RAt9Y1IPGbT7KmeEr4uMJFvR7qkPOET75safko43nqw g==; X-CSE-ConnectionGUID: 0pZUovU6Rk+fk5N5TUQjWw== X-CSE-MsgGUID: +IQiDldbTYKztilk0KxyTQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067960" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067960" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: TJQT913DSqmlAiaG5MJS2Q== X-CSE-MsgGUID: OvvpV2LGRful5O8h0mDMvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329441" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 793CA6F1; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 09/11] spi: pxa2xx: Extract pxa2xx_spi_platform_*() callbacks Date: Thu, 30 May 2024 18:10:05 +0300 Message-ID: <20240530151117.1130792-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation of the extracting platform driver from spi-pxa2xx.c split the probe and remove functions so we have bus independent and platform device ones. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 52 +++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 3c03a8cd9ee6..74f242e652df 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1413,30 +1413,16 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) return MAX_DMA_LEN; } -static int pxa2xx_spi_probe(struct platform_device *pdev) +static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) { - struct device *dev = &pdev->dev; struct pxa2xx_spi_controller *platform_info; struct spi_controller *controller; struct driver_data *drv_data; - struct ssp_device *ssp; const struct lpss_config *config; int status; u32 tmp; platform_info = dev_get_platdata(dev); - if (!platform_info) { - platform_info = pxa2xx_spi_init_pdata(pdev); - if (IS_ERR(platform_info)) - return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); - } - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return PTR_ERR(ssp); - if (!ssp) - ssp = &platform_info->ssp; - if (platform_info->is_target) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else @@ -1628,9 +1614,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) return status; } -static void pxa2xx_spi_remove(struct platform_device *pdev) +static void pxa2xx_spi_remove(struct device *dev) { - struct device *dev = &pdev->dev; struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; @@ -1708,6 +1693,35 @@ static const struct dev_pm_ops pxa2xx_spi_pm_ops = { RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL) }; +static int pxa2xx_spi_platform_probe(struct platform_device *pdev) +{ + struct pxa2xx_spi_controller *platform_info; + struct device *dev = &pdev->dev; + struct ssp_device *ssp; + + platform_info = dev_get_platdata(dev); + if (!platform_info) { + platform_info = pxa2xx_spi_init_pdata(pdev); + if (IS_ERR(platform_info)) + return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); + + dev->platform_data = platform_info; + } + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); + if (!ssp) + ssp = &platform_info->ssp; + + return pxa2xx_spi_probe(dev, ssp); +} + +static void pxa2xx_spi_platform_remove(struct platform_device *pdev) +{ + pxa2xx_spi_remove(&pdev->dev); +} + static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { { "80860F0E" }, { "8086228E" }, @@ -1732,8 +1746,8 @@ static struct platform_driver driver = { .acpi_match_table = pxa2xx_spi_acpi_match, .of_match_table = pxa2xx_spi_of_match, }, - .probe = pxa2xx_spi_probe, - .remove_new = pxa2xx_spi_remove, + .probe = pxa2xx_spi_platform_probe, + .remove_new = pxa2xx_spi_platform_remove, }; static int __init pxa2xx_spi_init(void) From patchwork Thu May 30 15:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680551 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C6F1CB306; Thu, 30 May 2024 15:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081890; cv=none; b=gT9e6X6tmuvBZJv9qoJE35dMSAd+VNOOhaSdkoSd65mB5be/6yXcNMTEhDbL4nhBV8dLaNVJd8+bas4N9beyphf4eScqJknXwOW5pS8EpvwI+3O7mYizTl2ZbbINEw9drJW/gMZ50Y3PeRiUsIV1+oirKynpCkPisuZ1nI883nM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081890; c=relaxed/simple; bh=HYlrU3UBrVhjvXqz3+lbjc1NAwS2xeDgiIYUu3mQpXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ga7cXBg2lxFFOgypDKHW8P12KNqg86CwHRyX4IaDDucpz73FjkDDM2qUUGtSq06GCtUr6p5K476QjEKcRnmKQW0vrK8GbaVIIo4UEUcMMjE8BLrYtYpuc1Oaw1wuDtGOUvpUfZWoIV3moGDeg8S9kBfFGbGWMFJqAxhFSDgu9Sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Knbwssup; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Knbwssup" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HYlrU3UBrVhjvXqz3+lbjc1NAwS2xeDgiIYUu3mQpXA=; b=KnbwssupSB+Ia7j6j6qhzCoCQg94Z3i0XZjLa7kUs7iWawvBL6M4PIvH w0XGOzs+UB+dvoeF4wo7j6QBFAkfRvU2wwZrtQdK3roxlSxJgeWW/Lw9k lSrq1+2ULzBaoYrejbekJ7ktImDv2cJI/uS6wmNGiq4YldMe4E7+Szm6O HCi/mAsc7W04fGaWeYqdAk5t2YgKe9Yx3angYQLDDkbd1jzqi22PYjy/I Js1TQV6yQ63svold9O/1vMLqEafsoQaGAPBflFRUfKqaH/oNsnOZv1Zh/ putGL+Bk8FnHCLH/1tqWgf1VtnPp05dsOrGt0RrQeEeC43Ndk6e2Yn5XT A==; X-CSE-ConnectionGUID: x49ng7RJSoi905XDkAAEvg== X-CSE-MsgGUID: hxLyUNShQ+2LpbDiSiR6ew== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067974" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067974" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: GLCTZRnDTYmRXgBP/9I+5A== X-CSE-MsgGUID: VOD612wUSKSb/EIN8wlzzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329440" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 82AB072B; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 10/11] spi: pxa2xx: Move platform driver to a separate file Date: Thu, 30 May 2024 18:10:06 +0300 Message-ID: <20240530151117.1130792-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The spi-pxa2xx.c is bloated with a platform driver code while pretending to provide a core functionality. Make it real core library by splitting out the platform driver to a separate file. Signed-off-by: Andy Shevchenko --- drivers/spi/Makefile | 3 +- drivers/spi/spi-pxa2xx-platform.c | 214 +++++++++++++++++++++++++++++ drivers/spi/spi-pxa2xx.c | 215 ++---------------------------- drivers/spi/spi-pxa2xx.h | 6 + 4 files changed, 230 insertions(+), 208 deletions(-) create mode 100644 drivers/spi/spi-pxa2xx-platform.c diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index e694254dec04..bcfb6efd88e0 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -107,7 +107,8 @@ obj-$(CONFIG_SPI_PIC32) += spi-pic32.o obj-$(CONFIG_SPI_PIC32_SQI) += spi-pic32-sqi.o obj-$(CONFIG_SPI_PL022) += spi-pl022.o obj-$(CONFIG_SPI_PPC4xx) += spi-ppc4xx.o -spi-pxa2xx-platform-objs := spi-pxa2xx.o spi-pxa2xx-dma.o +obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-core.o +spi-pxa2xx-core-y := spi-pxa2xx.o spi-pxa2xx-dma.o obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-platform.o obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o obj-$(CONFIG_SPI_QCOM_GENI) += spi-geni-qcom.o diff --git a/drivers/spi/spi-pxa2xx-platform.c b/drivers/spi/spi-pxa2xx-platform.c new file mode 100644 index 000000000000..98a8ceb7db6f --- /dev/null +++ b/drivers/spi/spi-pxa2xx-platform.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "spi-pxa2xx.h" + +static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) +{ + return param == chan->device->dev; +} + +static int +pxa2xx_spi_init_ssp(struct platform_device *pdev, struct ssp_device *ssp, enum pxa_ssp_type type) +{ + struct device *dev = &pdev->dev; + struct resource *res; + int status; + u64 uid; + + ssp->mmio_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(ssp->mmio_base)) + return PTR_ERR(ssp->mmio_base); + + ssp->phys_base = res->start; + + ssp->clk = devm_clk_get(dev, NULL); + if (IS_ERR(ssp->clk)) + return PTR_ERR(ssp->clk); + + ssp->irq = platform_get_irq(pdev, 0); + if (ssp->irq < 0) + return ssp->irq; + + ssp->type = type; + ssp->dev = dev; + + status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); + if (status) + ssp->port_id = -1; + else + ssp->port_id = uid; + + return 0; +} + +static void pxa2xx_spi_ssp_release(void *ssp) +{ + pxa_ssp_free(ssp); +} + +static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) +{ + struct ssp_device *ssp; + int status; + + ssp = pxa_ssp_request(pdev->id, pdev->name); + if (!ssp) + return ssp; + + status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); + if (status) + return ERR_PTR(status); + + return ssp; +} + +static struct pxa2xx_spi_controller * +pxa2xx_spi_init_pdata(struct platform_device *pdev) +{ + struct pxa2xx_spi_controller *pdata; + struct device *dev = &pdev->dev; + struct device *parent = dev->parent; + const void *match = device_get_match_data(dev); + enum pxa_ssp_type type = SSP_UNDEFINED; + struct ssp_device *ssp; + bool is_lpss_priv; + u32 num_cs = 1; + int status; + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) { + type = ssp->type; + } else if (match) { + type = (enum pxa_ssp_type)(uintptr_t)match; + } else { + u32 value; + + status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); + if (status) + return ERR_PTR(status); + + type = (enum pxa_ssp_type)value; + } + + /* Validate the SSP type correctness */ + if (!(type > SSP_UNDEFINED && type < SSP_MAX)) + return ERR_PTR(-EINVAL); + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + /* Platforms with iDMA 64-bit */ + is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); + if (is_lpss_priv) { + pdata->tx_param = parent; + pdata->rx_param = parent; + pdata->dma_filter = pxa2xx_spi_idma_filter; + } + + /* Read number of chip select pins, if provided */ + device_property_read_u32(dev, "num-cs", &num_cs); + + pdata->num_chipselect = num_cs; + pdata->is_target = device_property_read_bool(dev, "spi-slave"); + pdata->enable_dma = true; + pdata->dma_burst_size = 1; + + /* If SSP has been already enumerated, use it */ + if (ssp) + return pdata; + + status = pxa2xx_spi_init_ssp(pdev, &pdata->ssp, type); + if (status) + return ERR_PTR(status); + + return pdata; +} + +static int pxa2xx_spi_platform_probe(struct platform_device *pdev) +{ + struct pxa2xx_spi_controller *platform_info; + struct device *dev = &pdev->dev; + struct ssp_device *ssp; + + platform_info = dev_get_platdata(dev); + if (!platform_info) { + platform_info = pxa2xx_spi_init_pdata(pdev); + if (IS_ERR(platform_info)) + return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); + + dev->platform_data = platform_info; + } + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); + if (!ssp) + ssp = &platform_info->ssp; + + return pxa2xx_spi_probe(dev, ssp); +} + +static void pxa2xx_spi_platform_remove(struct platform_device *pdev) +{ + pxa2xx_spi_remove(&pdev->dev); +} + +static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { + { "80860F0E" }, + { "8086228E" }, + { "INT33C0" }, + { "INT33C1" }, + { "INT3430" }, + { "INT3431" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); + +static const struct of_device_id pxa2xx_spi_of_match[] = { + { .compatible = "marvell,mmp2-ssp", .data = (void *)MMP2_SSP }, + {} +}; +MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match); + +static struct platform_driver driver = { + .driver = { + .name = "pxa2xx-spi", + .pm = pm_ptr(&pxa2xx_spi_pm_ops), + .acpi_match_table = pxa2xx_spi_acpi_match, + .of_match_table = pxa2xx_spi_of_match, + }, + .probe = pxa2xx_spi_platform_probe, + .remove_new = pxa2xx_spi_platform_remove, +}; + +static int __init pxa2xx_spi_init(void) +{ + return platform_driver_register(&driver); +} +subsys_initcall(pxa2xx_spi_init); + +static void __exit pxa2xx_spi_exit(void) +{ + platform_driver_unregister(&driver); +} +module_exit(pxa2xx_spi_exit); + +MODULE_AUTHOR("Stephen Street"); +MODULE_DESCRIPTION("PXA2xx SSP SPI Controller platform driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(SPI_PXA2xx); +MODULE_ALIAS("platform:pxa2xx-spi"); +MODULE_SOFTDEP("pre: dw_dmac"); diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 74f242e652df..1fb30201459f 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -4,7 +4,6 @@ * Copyright (C) 2013, 2021 Intel Corporation */ -#include #include #include #include @@ -14,15 +13,12 @@ #include #include #include -#include #include #include #include #include #include -#include #include -#include #include #include #include @@ -32,11 +28,6 @@ #include "spi-pxa2xx.h" -MODULE_AUTHOR("Stephen Street"); -MODULE_DESCRIPTION("PXA2xx SSP SPI Controller"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:pxa2xx-spi"); - #define TIMOUT_DFLT 1000 /* @@ -1263,131 +1254,6 @@ static void cleanup(struct spi_device *spi) kfree(chip); } -static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) -{ - return param == chan->device->dev; -} - -static int -pxa2xx_spi_init_ssp(struct platform_device *pdev, struct ssp_device *ssp, enum pxa_ssp_type type) -{ - struct device *dev = &pdev->dev; - struct resource *res; - int status; - u64 uid; - - ssp->mmio_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(ssp->mmio_base)) - return PTR_ERR(ssp->mmio_base); - - ssp->phys_base = res->start; - - ssp->clk = devm_clk_get(dev, NULL); - if (IS_ERR(ssp->clk)) - return PTR_ERR(ssp->clk); - - ssp->irq = platform_get_irq(pdev, 0); - if (ssp->irq < 0) - return ssp->irq; - - ssp->type = type; - ssp->dev = dev; - - status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); - if (status) - ssp->port_id = -1; - else - ssp->port_id = uid; - - return 0; -} - -static void pxa2xx_spi_ssp_release(void *ssp) -{ - pxa_ssp_free(ssp); -} - -static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) -{ - struct ssp_device *ssp; - int status; - - ssp = pxa_ssp_request(pdev->id, pdev->name); - if (!ssp) - return ssp; - - status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); - if (status) - return ERR_PTR(status); - - return ssp; -} - -static struct pxa2xx_spi_controller * -pxa2xx_spi_init_pdata(struct platform_device *pdev) -{ - struct pxa2xx_spi_controller *pdata; - struct device *dev = &pdev->dev; - struct device *parent = dev->parent; - const void *match = device_get_match_data(dev); - enum pxa_ssp_type type = SSP_UNDEFINED; - struct ssp_device *ssp; - bool is_lpss_priv; - u32 num_cs = 1; - int status; - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return ERR_CAST(ssp); - if (ssp) { - type = ssp->type; - } else if (match) { - type = (enum pxa_ssp_type)(uintptr_t)match; - } else { - u32 value; - - status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); - if (status) - return ERR_PTR(status); - - type = (enum pxa_ssp_type)value; - } - - /* Validate the SSP type correctness */ - if (!(type > SSP_UNDEFINED && type < SSP_MAX)) - return ERR_PTR(-EINVAL); - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - /* Platforms with iDMA 64-bit */ - is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); - if (is_lpss_priv) { - pdata->tx_param = parent; - pdata->rx_param = parent; - pdata->dma_filter = pxa2xx_spi_idma_filter; - } - - /* Read number of chip select pins, if provided */ - device_property_read_u32(dev, "num-cs", &num_cs); - - pdata->num_chipselect = num_cs; - pdata->is_target = device_property_read_bool(dev, "spi-slave"); - pdata->enable_dma = true; - pdata->dma_burst_size = 1; - - /* If SSP has been already enumerated, use it */ - if (ssp) - return pdata; - - status = pxa2xx_spi_init_ssp(pdev, &pdata->ssp, type); - if (status) - return ERR_PTR(status); - - return pdata; -} - static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller, unsigned int cs) { @@ -1413,7 +1279,7 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) return MAX_DMA_LEN; } -static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) { struct pxa2xx_spi_controller *platform_info; struct spi_controller *controller; @@ -1613,8 +1479,9 @@ static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) return status; } +EXPORT_SYMBOL_NS_GPL(pxa2xx_spi_probe, SPI_PXA2xx); -static void pxa2xx_spi_remove(struct device *dev) +void pxa2xx_spi_remove(struct device *dev) { struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; @@ -1637,6 +1504,7 @@ static void pxa2xx_spi_remove(struct device *dev) /* Release IRQ */ free_irq(ssp->irq, drv_data); } +EXPORT_SYMBOL_NS_GPL(pxa2xx_spi_remove, SPI_PXA2xx); static int pxa2xx_spi_suspend(struct device *dev) { @@ -1688,78 +1556,11 @@ static int pxa2xx_spi_runtime_resume(struct device *dev) return clk_prepare_enable(drv_data->ssp->clk); } -static const struct dev_pm_ops pxa2xx_spi_pm_ops = { +EXPORT_NS_GPL_DEV_PM_OPS(pxa2xx_spi_pm_ops, SPI_PXA2xx) = { SYSTEM_SLEEP_PM_OPS(pxa2xx_spi_suspend, pxa2xx_spi_resume) RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL) }; -static int pxa2xx_spi_platform_probe(struct platform_device *pdev) -{ - struct pxa2xx_spi_controller *platform_info; - struct device *dev = &pdev->dev; - struct ssp_device *ssp; - - platform_info = dev_get_platdata(dev); - if (!platform_info) { - platform_info = pxa2xx_spi_init_pdata(pdev); - if (IS_ERR(platform_info)) - return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); - - dev->platform_data = platform_info; - } - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return PTR_ERR(ssp); - if (!ssp) - ssp = &platform_info->ssp; - - return pxa2xx_spi_probe(dev, ssp); -} - -static void pxa2xx_spi_platform_remove(struct platform_device *pdev) -{ - pxa2xx_spi_remove(&pdev->dev); -} - -static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { - { "80860F0E" }, - { "8086228E" }, - { "INT33C0" }, - { "INT33C1" }, - { "INT3430" }, - { "INT3431" }, - {} -}; -MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); - -static const struct of_device_id pxa2xx_spi_of_match[] = { - { .compatible = "marvell,mmp2-ssp", .data = (void *)MMP2_SSP }, - {} -}; -MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match); - -static struct platform_driver driver = { - .driver = { - .name = "pxa2xx-spi", - .pm = pm_ptr(&pxa2xx_spi_pm_ops), - .acpi_match_table = pxa2xx_spi_acpi_match, - .of_match_table = pxa2xx_spi_of_match, - }, - .probe = pxa2xx_spi_platform_probe, - .remove_new = pxa2xx_spi_platform_remove, -}; - -static int __init pxa2xx_spi_init(void) -{ - return platform_driver_register(&driver); -} -subsys_initcall(pxa2xx_spi_init); - -static void __exit pxa2xx_spi_exit(void) -{ - platform_driver_unregister(&driver); -} -module_exit(pxa2xx_spi_exit); - -MODULE_SOFTDEP("pre: dw_dmac"); +MODULE_AUTHOR("Stephen Street"); +MODULE_DESCRIPTION("PXA2xx SSP SPI Controller core driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 93e1e471e1c6..a470d3d634d3 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -14,6 +14,7 @@ #include +struct device; struct gpio_desc; /* @@ -131,4 +132,9 @@ extern void pxa2xx_spi_dma_stop(struct driver_data *drv_data); extern int pxa2xx_spi_dma_setup(struct driver_data *drv_data); extern void pxa2xx_spi_dma_release(struct driver_data *drv_data); +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp); +void pxa2xx_spi_remove(struct device *dev); + +extern const struct dev_pm_ops pxa2xx_spi_pm_ops; + #endif /* SPI_PXA2XX_H */ From patchwork Thu May 30 15:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680549 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B975D18629A; Thu, 30 May 2024 15:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081889; cv=none; b=UB9U6jh6wZkIMoW12YrUj1WdzHwwqNxoufIopzBSeC3/7MG9+cH9gWyc5o7lJKea0OcU+F/Ny/Eh0za7MshZFcjaoiv3RF/kYjeOh0WCyOEhFWVp2oNS7gp1GC/gRZMzpTe8rKLuT42lowi/GXQW2fz+G44v3Vx9a4EfGhedCgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081889; c=relaxed/simple; bh=7g0FrtRJTKHe6RD7B4mm9xOD9+Ic1TmeKGG546OwPqo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nLAY0cTt4g1EfvdLa24VA23XEj6GMEdRO0mlMwpzwppEUMuvneLFJmEjiNulR5gbvRnnvlEzFAjM3nQJiNfX/ymxImFnwwvxBaXzsv+WGPuUywYccu3N2csdes43/uWnLWtK/QdeZJYx5l6Lb48OFaOWdoROeLERbj30OBn2FAs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=M1/c2tLJ; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="M1/c2tLJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7g0FrtRJTKHe6RD7B4mm9xOD9+Ic1TmeKGG546OwPqo=; b=M1/c2tLJGgUyPOMOzPvKptWOnKEHzcZUJPOsab9Qv40a4ZT3ee2tnIeJ lLK4PIv0X9aAzsw2g41YzoUUKqYb3V0TxNltPdcQDvHFvLZw3wHTtuj6C CD+ZqVGlO4KoWuEFxPIXBvfao3eNRtfnY58hRBbdg2duBrXnjH8ujcXVY oxyhpczhN5Yz2UZ6j9yMW3ONECgWytXqIFme0iz7bnUrpQG8aozriG9wJ Wr6fXGAU7jRBF6TaIHcwmtOHvxvxCqwKMHmd0a1tm/EluofXx9z5lcZes qELeD9yHF58VlkXpHHC6fteT5sCLrpVkG0dYidiWTfhDZuRB5L2EQOHTT w==; X-CSE-ConnectionGUID: RyQuOvnbSsi7pe6myj0UCA== X-CSE-MsgGUID: /cqcRdJ0RVerC6cI+bbWCQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093065" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093065" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: k9Eha/fGTpeqrsW1X+0gig== X-CSE-MsgGUID: G+4ZTQb/TfC1x49tTGutPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288504" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8E19774F; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 11/11] spi: pxa2xx: Convert PCI driver to use spi-pxa2xx code directly Date: Thu, 30 May 2024 18:10:07 +0300 Message-ID: <20240530151117.1130792-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 PCI driver has an additional device layer for enumeration. Remove that layer and use spi-pxa2xx code directly. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx-pci.c | 39 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 6d2efdb0e95f..616d032f1a89 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -10,8 +10,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -265,10 +264,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { const struct pxa_spi_info *info; - struct platform_device_info pi; int ret; - struct platform_device *pdev; - struct pxa2xx_spi_controller spi_pdata; + struct pxa2xx_spi_controller *pdata; struct ssp_device *ssp; ret = pcim_enable_device(dev); @@ -279,15 +276,17 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, if (ret) return ret; - memset(&spi_pdata, 0, sizeof(spi_pdata)); + pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; - ssp = &spi_pdata.ssp; + ssp = &pdata->ssp; ssp->dev = &dev->dev; ssp->phys_base = pci_resource_start(dev, 0); ssp->mmio_base = pcim_iomap_table(dev)[0]; info = (struct pxa_spi_info *)ent->driver_data; - ret = info->setup(dev, &spi_pdata); + ret = info->setup(dev, pdata); if (ret) return ret; @@ -298,28 +297,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, return ret; ssp->irq = pci_irq_vector(dev, 0); - memset(&pi, 0, sizeof(pi)); - pi.fwnode = dev_fwnode(&dev->dev); - pi.parent = &dev->dev; - pi.name = "pxa2xx-spi"; - pi.id = ssp->port_id; - pi.data = &spi_pdata; - pi.size_data = sizeof(spi_pdata); - - pdev = platform_device_register_full(&pi); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - - pci_set_drvdata(dev, pdev); - - return 0; + return pxa2xx_spi_probe(&dev->dev, ssp); } static void pxa2xx_spi_pci_remove(struct pci_dev *dev) { - struct platform_device *pdev = pci_get_drvdata(dev); - - platform_device_unregister(pdev); + pxa2xx_spi_remove(&dev->dev); } static const struct pci_device_id pxa2xx_spi_pci_devices[] = { @@ -341,6 +324,9 @@ MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices); static struct pci_driver pxa2xx_spi_pci_driver = { .name = "pxa2xx_spi_pci", .id_table = pxa2xx_spi_pci_devices, + .driver = { + .pm = pm_ptr(&pxa2xx_spi_pm_ops), + }, .probe = pxa2xx_spi_pci_probe, .remove = pxa2xx_spi_pci_remove, }; @@ -349,4 +335,5 @@ module_pci_driver(pxa2xx_spi_pci_driver); MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(SPI_PXA2xx); MODULE_AUTHOR("Sebastian Andrzej Siewior ");