lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 25 Jul 2022 11:39:48 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Colin Foster <colin.foster@...advantage.com>
Cc:     linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        netdev <netdev@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Terry Bowman <terry.bowman@....com>,
        Vladimir Oltean <vladimir.oltean@....com>,
        Wolfram Sang <wsa@...nel.org>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Steen Hegelund <Steen.Hegelund@...rochip.com>,
        Lars Povlsen <lars.povlsen@...rochip.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        "David S. Miller" <davem@...emloft.net>,
        Russell King <linux@...linux.org.uk>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Lee Jones <lee.jones@...aro.org>, katie.morris@...advantage.com
Subject: Re: [PATCH v14 mfd 1/9] mfd: ocelot: add helper to get regmap from a resource

On Fri, Jul 22, 2022 at 6:06 AM Colin Foster
<colin.foster@...advantage.com> 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.

When we refer to functions we put it like func().

> 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.

...

> +#include <linux/err.h>

You also missed errno.h

> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/types.h>

...

> +static inline struct regmap *
> +ocelot_regmap_from_resource_optional(struct platform_device *pdev,
> +                                    unsigned int index,
> +                                    const struct regmap_config *config)
> +{
> +       struct device *dev = &pdev->dev;
> +       struct resource *res;
> +       void __iomem *regs;
> +
> +       /*
> +        * Don't use get_and_ioremap_resource here, since that will invoke

_get_and_ioremap_resource()

> +        * prints of "invalid resource" which simply add confusion
> +        */

will simply add

Missed period.

> +       res = platform_get_resource(pdev, IORESOURCE_MEM, index);

Where are the IORESOURCE_*  defined? Haven't you missed a header?

> +       if (res) {
> +               regs = devm_ioremap_resource(dev, res);
> +               if (IS_ERR(regs))
> +                       return ERR_CAST(regs);
> +               return devm_regmap_init_mmio(dev, regs, config);
> +       }
> +
> +       /*
> +        * Fall back to using REG and getting the resource from the parent
> +        * device, which is possible in an MFD configuration
> +        */
> +       if (dev->parent) {
> +               res = platform_get_resource(pdev, IORESOURCE_REG, index);
> +               if (!res)
> +                       return NULL;
> +
> +               return dev_get_regmap(dev->parent, res->name);
> +       }
> +
> +       return NULL;
> +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ