Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp217025imn; Fri, 1 Jul 2022 13:30:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHPmKKoRpX3AJAe2bqcca2bGP3EMOm+sXeFlvMFlvHgnHNLSH87vCLu4OD7LnDWcf2EWWH X-Received: by 2002:a05:6402:3304:b0:437:74dc:b6ea with SMTP id e4-20020a056402330400b0043774dcb6eamr21929798eda.141.1656707440268; Fri, 01 Jul 2022 13:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656707440; cv=none; d=google.com; s=arc-20160816; b=tzs8HQPGqqOlVhDoZ2k2RBXkITlumLTHekfe7lx3dXwJpe0UrvCNVmbQ82OU9OD0+8 LeNL1lURvU1zxXddbM8qbVPIfH67zGNwQO9k1Cl9bf4bYzgBYhlhl9Iz9kbDmKvfr1bi 7vLi3dleOWmVY5Pe4dLYUV/NWVsTKRvRXH3hWYM6/oOgv8FzS3zTBs/DmYkS6QjC3AXF HEZjwyvq9I/zCVU1cMoPmDLe6mEUNIi7+rI4ozT8VdoJVSdY8k2Ht7FITOgw+Ls81n81 ZmCCQJwMUj+I4Rj0lQPUhrEXVzVHtGf0Wl7MC4ULtjG6w9eAFiFEik3GHlaBI00HNUge fMwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/MRsD2vJA8bDPtwGkMOr5/5qFkYCaN1HrNYJP8Aooaw=; b=Bh9PgmA+1rBnkdVj0OP+WU6LVHFOzt8Br4Pe9dwKP4zfSDovbm4x4H1K9exsbisQse pyrvJ+nLJ3JgxTbujZ84CGr8GfIQdOHOk0jFUWoDYvJ+Qu+sfgxIYlAAb+J13c1uDQMG gN74LmSItkuWte5B8Qn+u7jNstAz7w7Pu11jRAag1MYN5BWgL4y6Zwnb8CM1UePNW0fb HWtkriO0aijusRsdOsbDpoY57dWLp6tqvxLkO5LCDDoTVsHoAMMRk7R8i8GFJMyztRbo ZwkAjVc+VijyTlex2NZWgop/IpI+lkMN37cE/L/iNKGe0yIPGHOFuLZzbuvMYTb7eHKE WBtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MRMpkkkX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a1709061d4c00b006fef5188c39si14080644ejh.307.2022.07.01.13.30.15; Fri, 01 Jul 2022 13:30:40 -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=@gmail.com header.s=20210112 header.b=MRMpkkkX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232216AbiGAUYR (ORCPT + 99 others); Fri, 1 Jul 2022 16:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbiGAUYQ (ORCPT ); Fri, 1 Jul 2022 16:24:16 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CAB32ED5B; Fri, 1 Jul 2022 13:24:13 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id 205so3467617ybe.3; Fri, 01 Jul 2022 13:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/MRsD2vJA8bDPtwGkMOr5/5qFkYCaN1HrNYJP8Aooaw=; b=MRMpkkkXd/AxaYKSqzVZ+JHGaNVydSScCwxeeTHy7nH9KnkQVHPCiFczxXqDZ++Eou oVPL5T2xx4TJ6WrEVruW23jgn5i0TbeLnhYhbNHWvJ/WJyf7ev8SxZF2YbGAfdUj2bqR BNRaRznaCwOa3BaYlKZi1g5WgSO4/Zg0olrORzny6nh9qIbQkP1FZTOltjqjit/0/vUF sbk8BerO6Qd9qJj9xpU62MQ5wpEivT03M+gjvTjP0AdvLDgncvTpscUSJsa7ULEq+aKc glVbZ9ngxZixwRW1/pJd4TNQON1BiMrb4owcn1YR3jIn8IJFW+EUDYQmgPdBlky6fwIs 93/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/MRsD2vJA8bDPtwGkMOr5/5qFkYCaN1HrNYJP8Aooaw=; b=FfyIZFlG3h28qdvwFuWaM1KzACweZp8PyTE7063p9+3F9Fy+txjx3YH2QCxzAeHyrD Bir+V+HbHb2DCzVe03/BJ7uNxpQQHn8W8OZtazrL1Ob6MGwmZvk4aojZynUJgBBkiUyH AD4DWsGG1CQKR0lMhLMqb/85PChuCq/6VvUovbA4hb5GCxCTHxn8gSqRKjVKhA5MFz2p ZsljI1KABvIzKGdTOYVkR11oR78x5R2lAfSKcpNK8T5cIIiRL2gsLsso3zCCEGP5Cam1 BdMpjRqG+O1HuTa1GZ+2gPTYBnBt+UG6R8U8K70y6lzhyqJX5TflZz4VEyec3UcvrnP7 qXmg== X-Gm-Message-State: AJIora8P72FZszn/0raMeO5JMO68YLVzTYq/lwE7+PiWNfidsaVSl1VK 1M2iMzlqxj12vg4sd6PzquXCpDTKYWSriI2rP2c= X-Received: by 2002:a05:6902:c4:b0:64b:4677:331b with SMTP id i4-20020a05690200c400b0064b4677331bmr17139233ybs.93.1656707052779; Fri, 01 Jul 2022 13:24:12 -0700 (PDT) MIME-Version: 1.0 References: <20220701192609.3970317-1-colin.foster@in-advantage.com> <20220701192609.3970317-2-colin.foster@in-advantage.com> In-Reply-To: <20220701192609.3970317-2-colin.foster@in-advantage.com> From: Andy Shevchenko Date: Fri, 1 Jul 2022 22:23:36 +0200 Message-ID: Subject: Re: [PATCH v12 net-next 1/9] mfd: ocelot: add helper to get regmap from a resource To: Colin Foster Cc: devicetree , Linux Kernel Mailing List , netdev , linux-arm Mailing List , "open list:GPIO SUBSYSTEM" , Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , Microchip Linux Driver Support , Linus Walleij , Wolfram Sang , Terry Bowman , katie.morris@in-advantage.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 On Fri, Jul 1, 2022 at 9:26 PM Colin Foster wrote: > > Several ocelot-related modules are designed for MMIO / regmaps. As such, > they often use a combination of devm_platform_get_and_ioremap_resource and > devm_regmap_init_mmio. > > Operating in an MFD might be different, in that it could be memory mapped, > or it could be SPI, I2C... In these cases a fallback to use IORESOURCE_REG > instead of IORESOURCE_MEM becomes necessary. > > When this happens, there's redundant logic that needs to be implemented in > every driver. In order to avoid this redundancy, utilize a single function > that, if the MFD scenario is enabled, will perform this fallback logic. ... > + res = platform_get_resource(pdev, IORESOURCE_MEM, index); > + if (res) { > + regs = devm_ioremap_resource(dev, res); > + if (IS_ERR(regs)) > + return ERR_CAST(regs); Why can't it be devm_platform_get_and_ioremap_resource() here? regs = devm_platform_get_and_ioremap_resource(); if (res) { if (IS_ERR(regs)) return ERR_CAST(); return ... } > + return devm_regmap_init_mmio(dev, regs, config); > + } ... > + return (map) ? map : ERR_PTR(-ENOENT); Too many parentheses. Also you may use short form of ternary operator: return map ?: ERR_PTR(-ENOENT); -- With Best Regards, Andy Shevchenko