Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2386683rwn; Fri, 9 Sep 2022 12:54:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7gND/8hpVg3OmCX3ylabu6tFA+cPG/uIuWMSxjifZ6UWbRlMLs1n41Xl7pZ7Va2Os0d8nN X-Received: by 2002:aa7:d315:0:b0:44e:6647:9dae with SMTP id p21-20020aa7d315000000b0044e66479daemr12489438edq.280.1662753289578; Fri, 09 Sep 2022 12:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662753289; cv=none; d=google.com; s=arc-20160816; b=wqtBNVo7lr2YyMcWARKRu+bXr0L1HynZcBqBJZgjHUNtsJfDKHkIjZmhcATp2dI5ve H5cEU08SaIGTXEsSOtRlqMFHnpTJ1aqLiFu6V6IH4Fuvze4u2gzhGNdSZOTUhhQVF0Ks vMUbbsQZX+CTijAyqKxmPQDsLIIP394hiF+n5s/JPUZTEVKsKfXfXggHYr/mohNYa615 DuvfPx2ZhPBKxGYRSm34VfHv6udgVu4b1fCylfPkQ1TbFYKcZ3wqtMkUFZBh9XuyAebH vGzdv1Q5rhCp6cz3+KZMlOIRNcfkKgVMc1BzRA1goCXvX3oHsJotHfGALbeZlzBeV7Ik zkgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=4UEvOJBnrhYbJMOH5dIhZYkkbJ2g80CrYqwa/ZKcSYU=; b=eiC6c6dgWuNegsqNqDaPW/EBByIQnxiHHYfefgW9LqYe624dhGQUUlPtMTJJz4c44U qm1f4YkT/Fbuywj9bV5KK4ptgVmmIhlbVRLvFATsk/47CVatLDZGCLXtXMPW+phL2u6/ UZnz/SqUBm1zYbGctJZVZuTfiPWduCNiU/Z5ClZEJjRe6JuUeYUh3ro47H5UU1FghyvG Fy82aOD3pbt6pVE2y9Z9qEy9lWpRnsuAo9nnt4i/jKPKeqQurEl7MRfCAhIwfyA5QPC+ t+42Dkfplo4b34cOUYycPuSzzllipbZTJ1LPHtHbSfzdiY2lgmRbbqMKy9Dp9fiIvZaU srXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=PuI+Re6L; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a170906c01700b0074156b2af5fsi901481ejz.829.2022.09.09.12.54.23; Fri, 09 Sep 2022 12:54:49 -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=@baikalelectronics.ru header.s=mail header.b=PuI+Re6L; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbiIIThX (ORCPT + 99 others); Fri, 9 Sep 2022 15:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbiIITgu (ORCPT ); Fri, 9 Sep 2022 15:36:50 -0400 Received: from mail.baikalelectronics.com (mail.baikalelectronics.com [87.245.175.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D789D115CE3; Fri, 9 Sep 2022 12:36:37 -0700 (PDT) Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id 27E3FDBF; Fri, 9 Sep 2022 22:40:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com 27E3FDBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1662752422; bh=4UEvOJBnrhYbJMOH5dIhZYkkbJ2g80CrYqwa/ZKcSYU=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=PuI+Re6LN1febwr8DWRC0N7Vh/Z6Olj+NKDllbtqHnTPgdUnqdjDaIBA608in6QIS +6lx0LYqvn+sdfBUgmoYj2NSYvq9x0w4g6bTXl6ogVkgNqenHF4WdHU0ftgjvlrxCM p0yOA7DYXbv+cA4gEgl1urShyqqMTVUjK3JcpcK8= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Sep 2022 22:36:33 +0300 From: Serge Semin To: Damien Le Moal , Hans de Goede , Jens Axboe , Hannes Reinecke CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Rob Herring , Krzysztof Kozlowski , , , Subject: [PATCH v8 06/23] ata: libahci_platform: Convert to using platform devm-ioremap methods Date: Fri, 9 Sep 2022 22:36:04 +0300 Message-ID: <20220909193621.17380-7-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220909193621.17380-1-Sergey.Semin@baikalelectronics.ru> References: <20220909193621.17380-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 Currently the IOMEM AHCI registers space is mapped by means of the two functions invocation: platform_get_resource() is used to get the very first memory resource and devm_ioremap_resource() is called to remap that resource. Device-managed kernel API provides a handy wrapper to perform the same in single function call: devm_platform_ioremap_resource(). While at it seeing many AHCI platform drivers rely on having the AHCI CSR space marked with "ahci" name let's first try to find and remap the CSR IO-mem with that name and only if it fails fallback to getting the very first registers space platform resource. Signed-off-by: Serge Semin Reviewed-by: Hannes Reinecke --- Changelog v2: - Check whether there is "ahci" reg resource before using the devm_platform_ioremap_resource_byname() method in order to prevent a false error message printed in the log (@Damien) - Slightly update the patch title due to the change above and to be more specific about what the platform device managed methods are utilized for. --- drivers/ata/libahci_platform.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 32495ae96567..1e9e825d6cc5 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -402,8 +402,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, devres_add(dev, hpriv); - hpriv->mmio = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); + /* + * If the DT provided an "ahci" named resource, use it. Otherwise, + * fallback to using the default first resource for the device node. + */ + if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci")) + hpriv->mmio = devm_platform_ioremap_resource_byname(pdev, "ahci"); + else + hpriv->mmio = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(hpriv->mmio)) { rc = PTR_ERR(hpriv->mmio); goto err_out; -- 2.37.2