From patchwork Mon Apr 17 07:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1956681vqo; Mon, 17 Apr 2023 01:10:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZE0YdC/C1EZWjspFTtMsh5wDsaDbgo7qSS+x4PRTtOdHejATwwtyrEBr//6NWvebXJlGI3 X-Received: by 2002:a05:6a00:1a43:b0:634:657e:546e with SMTP id h3-20020a056a001a4300b00634657e546emr19245635pfv.5.1681719014929; Mon, 17 Apr 2023 01:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719014; cv=none; d=google.com; s=arc-20160816; b=MCvsC/cYGTlOqpNRHAcukaHeBFakx5bH3U6IYDDHNxAjwZAaBb77x2cB+G+WAPiAkj LJbKBEu718sfAZIVL/D2CWQQDeg0ncqxtR3Mae4YNL6QAcCQJIJbpXkyJxvil4fRSJqI kFMXbFaHpJX1UfLkRafS5WvMIncWLvVfVwswdyqw2BqIHBxprO1asj0vtLec0SajxelQ unRO2PmLnLWlLMK9qUZFIoquFfbHZDIkvozA1QETFh2aC1Y6WAwq+onwUKaJizgyl7WI Y8yWVG2ejoM5uLvC5sW0Dv+YyHOb6cZTSaFKh9dI+V0kISejJ8Idc6JoU+TzULP6UnJm H6mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=O1PEWaqImmBnb3WBB6FH/NmE400DGerlhv0wB+spE59hB4OPwAl7XWJ/D0RfZUZDk1 JFsGQDvb1hTlMr/oeEj/lZPPp24ZCEAXJj5Y8gDjrKxS5dU+UD197VSdd4BN/YNwdMuD UImWuaX6iEkXKINrYyKOJuQx9vtg720yDZcfNxnCJzMtG2q8fj/F3IRdlbXi28gZ4j/E cUlAvJGjQ0G9AikA2FjxoBfH0wcl7K7AZnN+tdc/QAolr5TUNMeFwVTHlFZFz9e3bDA6 G4XHaogmNJ6EKluRs5mLu1aeOKCVTClOyyoBIqVBi6yxnw8HkN4LrE4iDx76dIfIPSii 2U9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKmXKwxI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x189-20020a6263c6000000b0063b86de9d22si4703593pfb.177.2023.04.17.01.10.02; Mon, 17 Apr 2023 01:10:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKmXKwxI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbjDQH4h (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbjDQH4D (ORCPT ); Mon, 17 Apr 2023 03:56:03 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E2B40F5 for ; Mon, 17 Apr 2023 00:56:01 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4edbd6cc46bso1040574e87.2 for ; Mon, 17 Apr 2023 00:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718159; x=1684310159; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=bKmXKwxI1i5GaBTDoiN8WGb3G7UxJGUxg2INzSxaVMCoaFLx48refXd4Nz5bpaTidd +aJVPhMYK3cl1wy7wA5gA2ITlD3XkS104O9DZZlUQkF/2sYeRwZdKIDF9YkwMDLsEHUa fMknMhAwfXB7I6Abw/8FZI2/Fc6hGYMjSWeHlTqNKpRCbf/nCmmlBfc4HHeSS+DKo7Il Usoh5H71wzm1HaCo6ZsGh01TzozH0JBMsxXAxp8OBvFE1iOe8WNQHfmBGmxmUhPK2InJ InJDp5EKEQvh6O5GYiMLKHqqQqQlbPHOxLZUBQN+wvDF8krGuzw/A27tH1xHHfnQZyT3 0BCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718159; x=1684310159; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=MCrW5gKpsVXzpnOde6JL5bGgL1YiWNOO6FbTcVBLqaU7JTLX7K6KOpzrIqcLYoMVGo bVrS8soYmTk3Ay2Q1f5XpicoSNr9HIA+IjEWyVXXHZIc/fia4Ua+fTniFVihUl089Ota licdt2oKjNhrcYHKlFI5s6XJqwcrkVauZElf2qrHWwLH/dEqWv7BcWVwN1M7akJakqtF noUkVj4U1UecBnU9Xjam1QWEO1czr7v7ztJtjLCultXfrixIf2lWLegXMSuRyHiKmlL9 Q1Ws+Yd9V2xVjJm0A5D/a/t9VBq8ZdCkd8LiuNDtNfM1R3rVU1lf3f32eaZIccBOPAoI t7rg== X-Gm-Message-State: AAQBX9eECt9qvhv+lzyrSJ15Y8zYjvkNQzXpNI13auSrNwavYpQRKPYC JyUFHs5508+qaH5N0y/1zgD1lg== X-Received: by 2002:a19:f80a:0:b0:4ec:9e01:71e with SMTP id a10-20020a19f80a000000b004ec9e01071emr1697300lff.4.1681718159455; Mon, 17 Apr 2023 00:55:59 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:59 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:52 +0200 Subject: [PATCH 7/7] dmaengine: ste_dma40: Return error codes properly MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-7-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763410197959289350?= X-GMAIL-MSGID: =?utf-8?q?1763410197959289350?= This makes the probe() and its subfunction d40_hw_detect_init() return proper error codes. One effect of this is that deferred probe, e.g from the clock, will start to work, would it happen. Also it is better design. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index c5991009d3e4..2911017265cf 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -3132,7 +3132,8 @@ static void d40_drop_kmem_cache_action(void *d) kmem_cache_destroy(desc_slab); } -static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) +static int __init d40_hw_detect_init(struct platform_device *pdev, + struct d40_base **retbase) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device *dev = &pdev->dev; @@ -3150,14 +3151,12 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(clk)) - return NULL; + return PTR_ERR(clk); /* Get IO for DMAC base address */ virtbase = devm_platform_ioremap_resource_byname(pdev, "base"); - if (IS_ERR(virtbase)) { - dev_err(dev, "No IO base defined\n"); - return NULL; - } + if (IS_ERR(virtbase)) + return PTR_ERR(virtbase); /* This is just a regular AMBA PrimeCell ID actually */ for (pid = 0, i = 0; i < 4; i++) @@ -3169,13 +3168,13 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) if (cid != AMBA_CID) { d40_err(dev, "Unknown hardware! No PrimeCell ID\n"); - return NULL; + return -EINVAL; } if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) { d40_err(dev, "Unknown designer! Got %x wanted %x\n", AMBA_MANF_BITS(pid), AMBA_VENDOR_ST); - return NULL; + return -EINVAL; } /* * HW revision: @@ -3189,7 +3188,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) rev = AMBA_REV_BITS(pid); if (rev < 2) { d40_err(dev, "hardware revision: %d is not supported", rev); - return NULL; + return -EINVAL; } /* The number of physical channels on this HW */ @@ -3216,7 +3215,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) sizeof(struct d40_chan), GFP_KERNEL); if (!base) - return NULL; + return -ENOMEM; base->rev = rev; base->clk = clk; @@ -3263,51 +3262,53 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) sizeof(*base->phy_res), GFP_KERNEL); if (!base->phy_res) - return NULL; + return -ENOMEM; base->lookup_phy_chans = devm_kcalloc(dev, num_phy_chans, sizeof(*base->lookup_phy_chans), GFP_KERNEL); if (!base->lookup_phy_chans) - return NULL; + return -ENOMEM; base->lookup_log_chans = devm_kcalloc(dev, num_log_chans, sizeof(*base->lookup_log_chans), GFP_KERNEL); if (!base->lookup_log_chans) - return NULL; + return -ENOMEM; base->reg_val_backup_chan = devm_kmalloc_array(dev, base->num_phy_chans, sizeof(d40_backup_regs_chan), GFP_KERNEL); if (!base->reg_val_backup_chan) - return NULL; + return -ENOMEM; base->lcla_pool.alloc_map = devm_kcalloc(dev, num_phy_chans * D40_LCLA_LINK_PER_EVENT_GRP, sizeof(*base->lcla_pool.alloc_map), GFP_KERNEL); if (!base->lcla_pool.alloc_map) - return NULL; + return -ENOMEM; base->regs_interrupt = devm_kmalloc_array(dev, base->gen_dmac.il_size, sizeof(*base->regs_interrupt), GFP_KERNEL); if (!base->regs_interrupt) - return NULL; + return -ENOMEM; base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc), 0, SLAB_HWCACHE_ALIGN, NULL); if (!base->desc_slab) - return NULL; + return -ENOMEM; ret = devm_add_action_or_reset(dev, d40_drop_kmem_cache_action, base->desc_slab); if (ret) - return NULL; + return ret; + + *retbase = base; - return base; + return 0; } static void __init d40_hw_init(struct d40_base *base) @@ -3503,20 +3504,20 @@ static int __init d40_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; struct device_node *np_lcpa; - int ret = -ENOENT; struct d40_base *base; struct resource *res; struct resource res_lcpa; int num_reserved_chans; u32 val; + int ret; if (d40_of_probe(dev, np)) { ret = -ENOMEM; goto report_failure; } - base = d40_hw_detect_init(pdev); - if (!base) + ret = d40_hw_detect_init(pdev, &base); + if (ret) goto report_failure; num_reserved_chans = d40_phy_res_init(base); @@ -3530,6 +3531,7 @@ static int __init d40_probe(struct platform_device *pdev) np_lcpa = of_parse_phandle(np, "sram", 0); if (!np_lcpa) { dev_err(dev, "no LCPA SRAM node\n"); + ret = -EINVAL; goto report_failure; } /* This is no device so read the address directly from the node */