Received: by 2002:a05:6512:e85:0:0:0:0 with SMTP id bi5csp3100893lfb; Tue, 28 Jun 2022 06:32:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsSjzsEnTB69nTRO4CF5iloDT70ywsCuHLBNpJ+LYTchG9nWz7Ysc+yj1QGiLjGKkjzS++ X-Received: by 2002:a17:907:3e86:b0:6f5:917:10cc with SMTP id hs6-20020a1709073e8600b006f5091710ccmr18013475ejc.53.1656423131443; Tue, 28 Jun 2022 06:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656423131; cv=none; d=google.com; s=arc-20160816; b=Jm8HdeYF4sdaGvQWpczmSGBuA5UB8cHRHSkv0uDXrZLiltrKXagboWWM9/1sRdEMPQ OFmytiiQH0MQubio0B+nNPazdZ5OXAKNTzTj57d9kyvgXb61W+b1oOV8aCCLGHPMKfai lqpNWVOVjNpsNyX+bwKaXsGjTsu/HH6FSJBULKR7lttAUFv1ZZmbSWA/bHeBRL8Ih1w/ vYSq1xrwGmiSQo8dKdUY7EuoJcrziBIVXwp9dhT1+VPkQhSo6+Bk7hqcu6Kp57JtBmre s5ClXeyxbUtc3dqeBKL6h8Sz8Rp2pdMIqjn9stqMu+hy5ovp19suH3YfGkIRYGoAwCQ7 T12w== 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=CH4Pyqj8qPmLBBURKSPKNXwIf78EfOj9Be5JNsbd8XM=; b=PL6Cdp2zAvkH9jo7Y8q2ph3ZKBCKded2Zd0gPRyykfm/F/y0VlCRSFYeaI0fac5HF6 mfsfuKhsJYWtcmg8WHkbT50od8x0EIFyIznLjRmSD07QsK5w3cjmwS9pElbIBB7rg+Yn /N2u5CLHg9kw9zR6dfg+IP064yjD+lz+dsP7Ggbb0SJIrdQ3lfolj70LXdiwxknVRy0O X+gtrQ8NdTYsZFvUWWcmALAUn2Z4yWwcpvtr8IxX28g6Co98nyABYQVxqaXdH/udM3Kd Eec1VVncZg85mfVSsijKLoWQv6hwA7W0G8jwcXjSDWcdpOoHoqGSXhqejgDjRjiCxqZc Z+fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=deAEahjw; 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 a20-20020a50f0d4000000b00435806b796asi17064089edm.433.2022.06.28.06.31.45; Tue, 28 Jun 2022 06:32:11 -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=deAEahjw; 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 S1345948AbiF1MvQ (ORCPT + 99 others); Tue, 28 Jun 2022 08:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240685AbiF1MvO (ORCPT ); Tue, 28 Jun 2022 08:51:14 -0400 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D50228E12; Tue, 28 Jun 2022 05:51:13 -0700 (PDT) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-3176b6ed923so115539847b3.11; Tue, 28 Jun 2022 05:51: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=CH4Pyqj8qPmLBBURKSPKNXwIf78EfOj9Be5JNsbd8XM=; b=deAEahjwrHbwfkQvJGhjE6repNNVh4eFNXQleZTBkNEFCYFe2wVgqh1M4cYNsVB3+T qw8/tmDv3eOW2gHe+FpDVnMYKHcybPPA2wuXoA0aW/13r7EOmfY0I/V3WgAVGZiMs5h8 Q/6Z78eUd49B2FWnfOlyxXLWaJSf7zcayPGwzab8lM8i44AR/7S8yDVxUzH/IXuCOw57 WWdfxd6yPc39eHwWlD1zMnXnPBLEW8ZwhrinOn/H4hAXHsw0iUDy2NhGDlcMmj9XNSe+ JxDlXTjbPKy0CrPhD4f462cdPEWyDnbXGnb33QLaBAXeYzshiGSBvXUjhjYupzBjgMoH nPcg== 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=CH4Pyqj8qPmLBBURKSPKNXwIf78EfOj9Be5JNsbd8XM=; b=U1yJRJiCcT+w8QAwBep8P6hLQkX4AzG4E3YoHaI0hnVlkvBGOF9YvgSSROjWAuNUEv DL2EtSbOvrAaYVxYkSwxcpJDOyg8de3K1XxdLBd69iQQUUj5xA0lu7MWU91PDvFOX/N2 QQHTDjSh/72HQ2uYutpFLr3SWexvDXrIUm7yuRsQj+s+D3azMqviYxI1x7z0fyWPeqgn /wtAYDPlH1MLJQWP1h9W5bH5IIr7VOMHGNO4U22Eo8MA8LE86VDvjrlPgKpOgNmUNO3v EmBnIAcGfvRj2uENTBmCDuR5GFwm5Tc/XPMPYfigwYkKJKT3l5DuiEhnex3c6vMo/tYS GJZQ== X-Gm-Message-State: AJIora9cxoCTeBJQc0pX0eiuCbJE18CHqU2rPmrpBE7lPxZssazLP9GT K1zcRZ53373top90iSYgXVrFEVSgNkLu3vtCg2k= X-Received: by 2002:a81:468b:0:b0:318:4cac:6576 with SMTP id t133-20020a81468b000000b003184cac6576mr20543609ywa.277.1656420672775; Tue, 28 Jun 2022 05:51:12 -0700 (PDT) MIME-Version: 1.0 References: <20220628081709.829811-1-colin.foster@in-advantage.com> <20220628081709.829811-2-colin.foster@in-advantage.com> In-Reply-To: <20220628081709.829811-2-colin.foster@in-advantage.com> From: Andy Shevchenko Date: Tue, 28 Jun 2022 14:50:36 +0200 Message-ID: Subject: Re: [PATCH v11 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 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 Tue, Jun 28, 2022 at 10:17 AM 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. > + regs = devm_platform_get_and_ioremap_resource(pdev, index, &res); > + > + if (!res) > + return ERR_PTR(-ENOENT); This needs a comment why the original error code from devm_ call above is not good here. > + else if (IS_ERR(regs)) > + return ERR_CAST(regs); > + else > + return devm_regmap_init_mmio(&pdev->dev, regs, config); > +} 'else' is redundant in all cases above. -- With Best Regards, Andy Shevchenko