From patchwork Mon Feb 12 14:03:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13553315 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 1ACE4C4829B for ; Mon, 12 Feb 2024 14:04:29 +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=Mufy2oILR9xi5VIcYpeZ5dp5NCgW4IEeFLN9nz++7wU=; b=xJ7BoDnAwfBXCF +snlZODMktcVS7sumh9VYCjOgmDVo9NNlqJ5hnQ/cyvpLPSNju8UHvosNcWLalo8+uCnLZW1DPNKq lvdgXAK9FpOQQXJEsPTdxZ4QtfPxoqXdNYSJ2LNDqoWztPlOetls470T44bWPKnAVrhvZ688evwTs Qm3Fw70TuKlmKY6WW0xbXb1sG0U+Tr4d+d3KoVfqFJ8tpZPxUkSflcGP9AEWQvEJUSSFJHa05G4yX KrxOuTlqBQqba7kd+2yS2JSBcKPdp+9fX4J2hCdnIRtxB8hHpC7XeNwEby4t0C+gdjTPuHo5UjI26 K5+w8ragdSyUMXRLo/JA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZWut-00000005h2V-3Hmu; Mon, 12 Feb 2024 14:04:15 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZWuf-00000005gqF-0njY for linux-arm-kernel@lists.infradead.org; Mon, 12 Feb 2024 14:04:03 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33b65b2e43eso2301052f8f.1 for ; Mon, 12 Feb 2024 06:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707746639; x=1708351439; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OTrzZqM2Ss1d3JLf/TDWyYpLJTs2h0kZukw/0ZYCnhU=; b=gRtkwRU+xxJquSLgqnsUssUoJ8CKHzbP6yVmkqzl5X+wzebtg1alED+l0WngNRQTlW oJgBmg6oCHDmEGO3YLF1flsgwbTjfwm45aGVAI7o7leZ4caTYvjovScjh9yVr7a7Av9y SwOdYjbGrNBo+Uzbp0LA71+SxeN9WjnoKd0fbZwAPHfPaZRAbgONqHeBGNLomxtG/qgx /pYZXKUC/ofQFGrR0AAknnCRqkd5ekuqic9MpCkhIloaayLmIqHaU38I15JdoGbhu0Gv t3Ww+OIUlymMHLp0s8qkP+JaD+O8dgEnyXigimB5s1/MtWkMQOGHdVvju0Gxh1tulZIM HfjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707746639; x=1708351439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OTrzZqM2Ss1d3JLf/TDWyYpLJTs2h0kZukw/0ZYCnhU=; b=c1dKmyotlYrQzVvg0PounJF2Sgy/QFmGMpypAPmmh1wEav2kXqGm20JAJ3gT0r/gB7 kCAP0b/NV8H8hxFrdIYMBPZp/cFS4TkXSnKpGFQ2oWjZ6fdBttQb9LBiUAmkUNwD61hV c5DxRfLwXD4kYLyihuBJjAM1bYF2iQojPcxPar6spGE7qJ0wiPzU7yob48Gvz5uhrxBx M7hV6IYJVG74xTZcjO1Hc/VJds9N+oJlfnjyk+uIhcQgWmgCcELYr5ZhDP3MvdzraoK2 YbTxvGyk9O1bW39H2kE68Af6kMptlfa2vFflzWqfgk+FZO8ghkkAOiUurtn1lOgilqCU jIDw== X-Forwarded-Encrypted: i=1; AJvYcCX5ge2CfQfGiycvDsuDkk2SgP7sZX0al+5v8caaEGJ8e5W1JSf5kR7UN+Ba0QZgVpo3fsGKQjAbw62yLgfUq5Acco80OWcmThHTehDsaHHdLJuv5aM= X-Gm-Message-State: AOJu0Yx7obR0eUUVOaB6BhBowb3Os4PwMLRYvlcqQ0cy2BwGPkFdgfch c/bejdrrDnJFBdECAFxtef8RmOjnUv4xfn6fr4W/Wumm+KRTtR2yFDYWmb/Yalc= X-Google-Smtp-Source: AGHT+IHe8AP9Dw8wolP7N78fXQjkB4Fn/h8j7Uc6WIIgess7pG3SedXldeeOTzKTSsK/F0AG9gZq9Q== X-Received: by 2002:a5d:65cf:0:b0:33b:1bcc:3be5 with SMTP id e15-20020a5d65cf000000b0033b1bcc3be5mr4450299wrw.71.1707746639324; Mon, 12 Feb 2024 06:03:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVlANfbZ8m+T1LP+cim+3GEYRHtlP15t/9gHZXViQTDofn14kjIknDINvOVYOR6vmxFlfUStZTWdOG6zC940DM9gEdcSYpAJat7dHZV1/GhpmuH2mkIFZeX/wzm256H3ItmSWgzRA5gXTwu09J9l9sECJz9CR1926Hrn2JUfE0uTHRJOcTAHOxgv6FxIYNQkujb9XEvvdGgF8ZT6lZ0XjYBjXbcdWooyZLKfQluQM8C3Eu4gnkkJmKAhZOmA+mmxxFqSl1YdQvWSFVDvN9p64Nfbp0V2rNMTsgDWac83u06lQNq5awYi0RPtLwaBE2tptRRDl0ZU1z3//WjnDK8IzkJewItN/RaANod2YfTjR8k1bza188Af6A6/ni+T4Fag2MouhZVapoYhCyDyH6sMOSs0hxNJWIbVKfDdojj3E9Rk+idLKFA+Ac4w41gIWPCYInt4i+o0ufV89VDDcCb+fggUhvaCsLIuBn4B/C+b4Xj2oM8FgzoEQ/NHC5Cgc1w17cgxld0qWhJbGMRutqJXlX2gTRHfgXkVlS002uP42NwWWea56Ocq9/zrvG3T3MW6P9aHSvF731DoqYzxFpCPF6j0CxIWVp9TcljJdlXquuBfwTEQh8= Received: from ta2.c.googlers.com.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id v9-20020a5d4b09000000b0033b843786e1sm2135356wrq.51.2024.02.12.06.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 06:03:58 -0800 (PST) From: Tudor Ambarus To: broonie@kernel.org, robh@kernel.org, andi.shyti@kernel.org, krzysztof.kozlowski@linaro.org, semen.protsenko@linaro.org, conor+dt@kernel.org Cc: alim.akhtar@samsung.com, linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, andre.draszik@linaro.org, peter.griffin@linaro.org, kernel-team@android.com, willmcvicker@google.com, devicetree@vger.kernel.org, arnd@arndb.de, Tudor Ambarus Subject: [PATCH v2 08/12] spi: s3c64xx: introduce s3c64xx_spi_set_port_id() Date: Mon, 12 Feb 2024 14:03:27 +0000 Message-ID: <20240212140331.915498-9-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240212140331.915498-1-tudor.ambarus@linaro.org> References: <20240212140331.915498-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_060401_405373_311517D4 X-CRM114-Status: GOOD ( 13.89 ) 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 Prepare driver to get rid of the of alias ID dependency. Split the port_id logic into a dedicated method. Signed-off-by: Tudor Ambarus --- drivers/spi/spi-s3c64xx.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index ac47755beb02..40de325bd094 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1200,6 +1200,27 @@ static inline const struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config( return (const struct s3c64xx_spi_port_config *)platform_get_device_id(pdev)->driver_data; } +static int s3c64xx_spi_set_port_id(struct platform_device *pdev, + struct s3c64xx_spi_driver_data *sdd) +{ + int ret; + + if (pdev->dev.of_node) { + ret = of_alias_get_id(pdev->dev.of_node, "spi"); + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, + "Failed to get alias id\n"); + sdd->port_id = ret; + } else { + if (pdev->id < 0) + return dev_err_probe(&pdev->dev, -EINVAL, + "Negative platform ID is not allowed\n"); + sdd->port_id = pdev->id; + } + + return 0; +} + static void s3c64xx_spi_set_fifomask(struct s3c64xx_spi_driver_data *sdd) { const struct s3c64xx_spi_port_config *port_conf = sdd->port_conf; @@ -1252,18 +1273,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) sdd->host = host; sdd->cntrlr_info = sci; sdd->pdev = pdev; - if (pdev->dev.of_node) { - ret = of_alias_get_id(pdev->dev.of_node, "spi"); - if (ret < 0) - return dev_err_probe(&pdev->dev, ret, - "Failed to get alias id\n"); - sdd->port_id = ret; - } else { - if (pdev->id < 0) - return dev_err_probe(&pdev->dev, -EINVAL, - "Negative platform ID is not allowed\n"); - sdd->port_id = pdev->id; - } + + ret = s3c64xx_spi_set_port_id(pdev, sdd); + if (ret) + return ret; if (sdd->port_conf->fifo_depth) sdd->fifo_depth = sdd->port_conf->fifo_depth;