From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BFF93C4547 for ; Mon, 27 Jul 2026 20:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785183350; cv=none; b=A/QW8E/VgsktvNLF2nKagvlnjOyZ11hnhPgz28XlmlPkFMFSm4La1+OmlNZc60BivLA+4CHl9YpcqLFC1gBVPDlIc/Bs2cxrZFp8XGM98V+Zn90lTEVhh3OrdrHVa+CtXtmvhaFXzTbY638kRyydMGnt9eAXIvdaDF6ZcRVkkL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785183350; c=relaxed/simple; bh=1GoRFCat+ErrB3hAtE60uqnxLaB3juM+9KFO4jka8VA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZTeJkekQ8PEX6dHGO69lOhyVuYNcJUYDmMNOGi2SuxR8/3vNu7CtudS2v28Thgyf2cfa7dvPigSnHDPcLJOsMNgf5YGP3IaxIMdZeB8blpDwRPgIa2YsfHkE2iZpgiBLw7Ktfh8LJq4MflC2sBD5dHhBAt9EQ2D2vFRs7xq25hI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MWHAtIWO; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MWHAtIWO" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-92f03daaa97so197169585a.2 for ; Mon, 27 Jul 2026 13:15:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785183346; x=1785788146; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=tDME+g3Hpcs7tuajmBtOQU1/TxU8l89I/sLTGgXuXUg=; b=MWHAtIWOjr5mq2Qyz3MAvwpKWSj3xbqqY8c2TK8M1foQaleAGr8icAzHeELdsPz+D3 SH23JyJZJ47U/hjMm+qoa0fI6rQcuHk7ZAoYVrm/HAfDZFSVDA0zBSkQvGUY7rHszQxD n+KV1HACM/PYN3LiVNb2CkNXswpPVGxBU2fBodKbs+jcXCKQ7qW7eOMzjL2a9rzd3+b2 LXUQS0EA8nvkfscNzhjV8nEtI9DqT77nbSMEaoGxfOMI/ykkPcfX8BxcIu0xUVkB7DLI +CnAQ7jbNtU2dv4MD3LgfBuvCsCmJa4OMYJcqMPx8OmEJT8gdsdZBeoNCtfl0YeZK0y7 acrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785183346; x=1785788146; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tDME+g3Hpcs7tuajmBtOQU1/TxU8l89I/sLTGgXuXUg=; b=XQ1GtKdItYqH1Un5NGs4wajsuZDuSZmONHlCuz76F2xPtakoilu5m1F809VKUZsS6w EGzOV7llk9KJD1YBMOPmN2a7M8LbdpPYnKMPS9hlILluW5ylQUV73LU9ztA2qNeZKfb7 sJFQULmFtsD2MQ7ZJ6q9lNumR5yvTJDofdtrVCWEwoIL2ysZ2nmUP+7s3qRj5OkIVoNk 3/5g2NIOrViB8w5bhNFktDfBovBxFzXP7KX823/Gwq9dSSeYqeVx/4j9txIaCZx6lBzw UiIP6rBj2BHputMNWeU1K1XaTkY5vAPGSF0P6nCueuGrNfVqJ5dc25c5qUJY9wGAqWoq hLwQ== X-Forwarded-Encrypted: i=1; AHgh+RpfWV1m5Yi0rX0XsO7hRq1xcXbc+orUneA927erYRSWOkjGc8YsQ+oJUzlMf5kVqtRDGfVORznzeqoQwzI=@vger.kernel.org X-Gm-Message-State: AOJu0YwNHhPwZs31MNKIjKdtZ/n8N9SQGU29/oNN9+TAFXJaWiP/lxSm qS16ECeBbXdBMewj0KxWcMXjhAPv5fqnU7nknX13trlV3kRv7jju5+ubmDV0u37k X-Gm-Gg: AR+sD13hE0iyD1XSQZXhQi0gAvC3c1gg4b6lWtKU7pbtFa0wRR1bgZ6pSfkdx4lITs/ tQyQOfE6oPljoCeBLgM8ejTzKAouKrEAZIip8yElK3eVBiLFyyzGuvCuOVY6sli/L151LdC0dG9 cNxDe5Dn5iH5aefD7i1wYVr1h63Kum3+u9yIHTfqflzmJfczgOI49fCQPivlgz2m+80q6nkv9aG NI06pq0ZhJiUAakznmQ8iIzlN32U2MGNOfARi8Xq7GCsiKyl0VAAFXsFHNFZ/0oEGIj1DOZmomu ahFPbmHYrtaOuGaxG7h+Nd4WdWVQGb87WL2Nm7eiXWg/dXh8Yxxv5x+AilpIZ538I3RMVDYA9Um nW0Otyy5u61lf6GUTT7jYsOafsU2/xtZMduYc8K549Gh39ytYmXYBazvbL0VOCcEKBf56+eMne5 fjkCVhBH/LmZ8uF0yLxvLKi99EFGBjxg5XG56cb1Efqenhypjco95I3pzjLokYfJrVwiKfjWore jGJ4rtC0Wt2y5HeulMaocgMHJLIDylgHfcj/QOES7A62vm6B6cAd43xTvuH8vXdFg== X-Received: by 2002:a05:620a:2403:10b0:92e:c197:e9f5 with SMTP id af79cd13be357-932df75c07fmr788497585a.77.1785183345611; Mon, 27 Jul 2026 13:15:45 -0700 (PDT) Received: from ryzen.lan ([2601:644:8000:7a86::e34]) by smtp.gmail.com with ESMTPSA id af79cd13be357-932de569a84sm697800985a.21.2026.07.27.13.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2026 13:15:44 -0700 (PDT) From: Rosen Penev To: linux-spi@vger.kernel.org Cc: Mark Brown , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] spi: ath79: use devm everywhere in probe Date: Mon, 27 Jul 2026 13:15:43 -0700 Message-ID: <20260727201543.18857-1-rosenp@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use devm_spi_alloc_host() instead of spi_alloc_host() so that the spi controller is automatically freed on probe failure or device removal. This lets us eliminate the err_put_host label and goto error path in probe, as well as the spi_controller_put() call in remove. It's also a bit weird as everything in probe is using devm except the first allocating function. Might fix an ordering issue on teardown. Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev --- drivers/spi/spi-ath79.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 2f61e5b9943c..1f5d0fb03917 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -173,7 +173,7 @@ static int ath79_spi_probe(struct platform_device *pdev) unsigned long rate; int ret; - host = spi_alloc_host(&pdev->dev, sizeof(*sp)); + host = devm_spi_alloc_host(&pdev->dev, sizeof(*sp)); if (host == NULL) { dev_err(&pdev->dev, "failed to allocate spi host\n"); return -ENOMEM; @@ -194,22 +194,16 @@ static int ath79_spi_probe(struct platform_device *pdev) sp->bitbang.flags = SPI_CS_HIGH; sp->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(sp->base)) { - ret = PTR_ERR(sp->base); - goto err_put_host; - } + if (IS_ERR(sp->base)) + return PTR_ERR(sp->base); sp->clk = devm_clk_get_enabled(&pdev->dev, "ahb"); - if (IS_ERR(sp->clk)) { - ret = PTR_ERR(sp->clk); - goto err_put_host; - } + if (IS_ERR(sp->clk)) + return PTR_ERR(sp->clk); rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ); - if (!rate) { - ret = -EINVAL; - goto err_put_host; - } + if (!rate) + return -EINVAL; sp->rrw_delay = ATH79_SPI_RRW_DELAY_FACTOR / rate; dev_dbg(&pdev->dev, "register read/write delay is %u nsecs\n", @@ -224,9 +218,6 @@ static int ath79_spi_probe(struct platform_device *pdev) err_disable: ath79_spi_disable(sp); -err_put_host: - spi_controller_put(host); - return ret; } @@ -236,7 +227,6 @@ static void ath79_spi_remove(struct platform_device *pdev) spi_bitbang_stop(&sp->bitbang); ath79_spi_disable(sp); - spi_controller_put(sp->bitbang.ctlr); } static void ath79_spi_shutdown(struct platform_device *pdev) -- 2.55.0