From patchwork Fri Feb 16 07:05:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13559616 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 36919C48BF0 for ; Fri, 16 Feb 2024 07:06:38 +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=OznT4aLYdmLummSFEp/r/1OnRFZQYnZA2Y4fBIgitaY=; b=YZaheTBabaPmJI 9OEnhfD1V+S7H5UTyy0HwdAO82ORuEvLc19cssdhJAbNQOR/WqEODkr+mXrVQMrY0o0wtXOiaVyxj fIl8S5kIG0IAjwo7QwRakGHfZH0gcM2fp5mUCiU5ue40myUL4QyPJHqSSqnPaMk8bm9SDxIj5h+r9 8+5njNs544ZKMih5yn71ozfVR25Wn/kD70VC3bMw356GyARJH23B352cs3qtI8xi4C0MsGh+YoXPy CQ7IZ78LJ9f4O0Vfz1hsvHjP2IqpjmJMM7EJxobNQPLL2Yim+rt/dvVTsGHbmAANH0jfD/upzoQje tEsYbZWzktoIe2It8gkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rasIk-00000001JM7-2iYq; Fri, 16 Feb 2024 07:06:26 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rasIU-00000001JB4-23hL for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 07:06:11 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-33d18931a94so320913f8f.1 for ; Thu, 15 Feb 2024 23:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708067168; x=1708671968; 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=D6DI6oxyBGAOnmgH57nVgi2YtxfkZy7vqtRyT86aOak=; b=hgkfebsW0zY2SvNDHezscG9+G8wu2mxCsGBHtfdL3gIBD3y595bllanDJLnDMwRs1e pGlWZeYfPbPe+goFeZ1r6LAZnk3ym155gpc0k8bVk/yXAm1XrN59dYdIdEbPyRkc+p9o yji7c3M/ux26xiquW277t4A0VAO+eZ7dwSpRM31eVbxVZAEuvNX9Paq46AdhUhK0UE30 R1eGIcyvkkPiKXk8/J49M3tpKG3VEE1XwlBgAlaIEUgOPfbresrfW9c9ZNbeV8LaA2Jo LVzPRC/MheLnVmhKszGKaZXFdKs2iaDF/GtI4ta1PgXIpv38v7vSTLTykrzp8W6VDouv F5kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708067168; x=1708671968; 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=D6DI6oxyBGAOnmgH57nVgi2YtxfkZy7vqtRyT86aOak=; b=H5yZGFpkGW5iN4jS9Jcwm6QwNp/O7wxcld8uEdUWJKowPqBaQDSL1AhwnXQWC77HEH +BM1AfjXPnBchQbXhSTj6jqO6KUJ+fhlqYXrvoLFAbCJ5JG4PyQoSVb4/jpbXHo7geZf uXuieojd4SdHotVxxo+6TV/teZB7Pn7DV9i41vH5g4hDayq8RitbEtzURCGdnJIRFDdN r2kZ1yEitwcm8gY9TiB2nfNqbwhlT1acOEA/kUwbu8qzqGSc3Yi8cGQ/csGLi7tThZ42 pZgvP5FEldEsBQxAMoZf4KRSQbJH8oBxpk5QGnVA82YjurQlSh02lfnPASJmBQcq44fY JPOQ== X-Forwarded-Encrypted: i=1; AJvYcCXQw7qF3YecqVEsyZ44Hq+4e3TwgnNkLZvfj8NKUyr/5kD6jRauPaoxyb3EzJtkvNsMM0Z7wM8txB1RHzw8mwk0LKbY1BiFG4o7h9al3EqnbUyIjeg= X-Gm-Message-State: AOJu0YyOljVCA5wQDWiPob4C+HFgrsaRNaiV1mEHdZBwXiT4vT2e6rsN Ut+8NfS1OgRljWVM3RGenYF8DhG9+i8cEiBT8NJB8JHfBSzTYDZMjOgAPh5v2Gk= X-Google-Smtp-Source: AGHT+IElxq2xk6aiqP+v7vVmB9Rn+o8tE/AamjN56/HIJFwjBwNBu23xznmMSINpOQWx94t5lmSSfA== X-Received: by 2002:a5d:6190:0:b0:33c:f968:e243 with SMTP id j16-20020a5d6190000000b0033cf968e243mr2968421wru.43.1708067168666; Thu, 15 Feb 2024 23:06:08 -0800 (PST) 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 k18-20020a5d66d2000000b0033940016d6esm1298839wrw.93.2024.02.15.23.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 23:06:07 -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, Tudor Ambarus Subject: [PATCH v3 08/12] spi: s3c64xx: introduce s3c64xx_spi_set_port_id() Date: Fri, 16 Feb 2024 07:05:51 +0000 Message-ID: <20240216070555.2483977-9-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240216070555.2483977-1-tudor.ambarus@linaro.org> References: <20240216070555.2483977-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-20240215_230610_572209_CB428BBF X-CRM114-Status: GOOD ( 13.94 ) 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;