From patchwork Wed Apr 3 17:06:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13616520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBD0BCD1296 for ; Wed, 3 Apr 2024 17:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WtaaPpHAsQOkkJcALSMBZLfap+hQC5v5JlvRIOp6ass=; b=RyOPcj2t2q2j/8 tlLTvYLYlBS7tCgSuHThMuo6TRSt4DxV0JMILG66WhNdXOSmHINcWd7BsH1ZpHX8uB3Bg49uM1a5h 0rMnwEjMqjW0/6rbTn2Mx/laeRaZ6FobQE7j3Xy4+Nb73snu9yOGeaitZ2Mn+etIKLhdB6r2K5Ylq 1k8Hkw70HSeQ/X5oJA6xTMhrbVAZiEDLEkkAbiNsBBXK+e5fUVW8dYxJEXUMlFqXn1TwGPhRFqaOk b4YCYVNVYtBPaWIdlde/KxtOmLwnsHLHeW/Q41M4eJ6aBV+zzt3Q3bf5j0nbR7Qdrw9I01EmwcDFO veMORkvC7MSWC41khLNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4DT-0000000H86q-3zmD; Wed, 03 Apr 2024 17:16:03 +0000 Received: from mgamail.intel.com ([198.175.65.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4DP-0000000H840-3x7P for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2024 17:16:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712164560; x=1743700560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GwuZHVBOSboMBOsVLsZWRQAybgsz5rDWta39aVm4WuQ=; b=khqrFg/DH7BGeWFCZRbrDle1smy1AogqMKL5V4kiQAP1WUmFb+NP6H3T UWFfjRkvrslghYJ5B/UgT1wtNpKpuYnIErWCB7S40muNkgn7k9WYb83ih aPWpRluafupgbIIG6vAYFm/Gj49eMXtqSuDSZmCvIjDkhhDFsTfpLI4hf zG3eUVHMUtH6CLQIegfjEeWNxYmtRjBmKSQcDK8KcWYxW4baHzZabdtV6 YetUKlGm4/UJ7e91RM7XUDHBuSQof9douGogwyofOAja8n0mptRs0SnsU tCnZlsaNrSxbGUXxjfjhVd23DCJqI7LcZ8g2NdbdNv0pVcOFdR1bEJQn0 w==; X-CSE-ConnectionGUID: /c/rU/XDTTyje8AF4Gtkwg== X-CSE-MsgGUID: GbAIV6OCRXq/2nE4kyODIw== X-IronPort-AV: E=McAfee;i="6600,9927,11033"; a="18863546" X-IronPort-AV: E=Sophos;i="6.07,177,1708416000"; d="scan'208";a="18863546" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2024 10:15:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11033"; a="937085339" X-IronPort-AV: E=Sophos;i="6.07,177,1708416000"; d="scan'208";a="937085339" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 03 Apr 2024 10:15:54 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9931FF4; Wed, 3 Apr 2024 20:15:53 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Mark Brown Subject: [PATCH v1 1/5] spi: pxa2xx: Move number of CS pins validation out of condition Date: Wed, 3 Apr 2024 20:06:35 +0300 Message-ID: <20240403171550.1074644-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240403171550.1074644-1-andriy.shevchenko@linux.intel.com> References: <20240403171550.1074644-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_101600_060088_0B014923 X-CRM114-Status: GOOD ( 14.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is no need to allocate chip_data and then validate number of CS pins as it will have the same effect. Hence move number of CS pins validation out of condition in setup(). Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 1348249f8178..cc0e54f8d2c3 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1200,6 +1200,13 @@ static int setup(struct spi_device *spi) break; } + if (drv_data->ssp_type == CE4100_SSP) { + if (spi_get_chipselect(spi, 0) > 4) { + dev_err(&spi->dev, "failed setup: cs number must not be > 4.\n"); + return -EINVAL; + } + } + /* Only allocate on the first setup */ chip = spi_get_ctldata(spi); if (!chip) { @@ -1207,14 +1214,6 @@ static int setup(struct spi_device *spi) if (!chip) return -ENOMEM; - if (drv_data->ssp_type == CE4100_SSP) { - if (spi_get_chipselect(spi, 0) > 4) { - dev_err(&spi->dev, - "failed setup: cs number must not be > 4.\n"); - kfree(chip); - return -EINVAL; - } - } chip->enable_dma = drv_data->controller_info->enable_dma; chip->timeout = TIMOUT_DFLT; }