From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Kavyasree Kotagiri <kavyasree.kotagiri@microchip.com>,
krzysztof.kozlowski+dt@linaro.org, nicolas.ferre@microchip.com,
alexandre.belloni@bootlin.com, claudiu.beznea@microchip.com,
peda@axentia.se
Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, lee.jones@linaro.org,
linux@armlinux.org.uk, Manohar.Puri@microchip.com,
UNGLinuxDriver@microchip.com
Subject: Re: [PATCH 4/4] mux: lan966: Add support for flexcom mux controller
Date: Tue, 3 May 2022 14:45:19 +0200 [thread overview]
Message-ID: <e00ff3b2-d5d1-706d-49cc-e70fe2cc9cab@linaro.org> (raw)
In-Reply-To: <20220503105528.12824-5-kavyasree.kotagiri@microchip.com>
On 03/05/2022 12:55, Kavyasree Kotagiri wrote:
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/mux/driver.h>
> +#include <linux/io.h>
> +
> +#define FLEX_SHRD_MASK 0x1FFFFF
> +#define LAN966_MAX_CS 21
> +
> +static void __iomem *flx_shared_base;
Why do you have file-scope shared variable? Cannot it be passed via
private data?
> +struct mux_lan966x {
> + u32 offset;
> + u32 ss_pin;
> +};
> +
> +static int mux_lan966x_set(struct mux_control *mux, int state)
> +{
> + struct mux_lan966x *mux_lan966x = mux_chip_priv(mux->chip);
> + u32 val;
> +
> + val = ~(1 << mux_lan966x[state].ss_pin) & FLEX_SHRD_MASK;
> + writel(val, flx_shared_base + mux_lan966x[state].offset);
> +
> + return 0;
> +}
> +
> +static const struct mux_control_ops mux_lan966x_ops = {
> + .set = mux_lan966x_set,
> +};
> +
> +static const struct of_device_id mux_lan966x_dt_ids[] = {
> + { .compatible = "microchip,lan966-flx-mux", },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mux_lan966x_dt_ids);
> +
> +static int mux_lan966x_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> + struct mux_lan966x *mux_lan966x;
> + struct mux_chip *mux_chip;
> + int ret, num_fields, i;
> +
> + ret = of_property_count_u32_elems(np, "mux-offset-pin");
> + if (ret == 0 || ret % 2)
> + ret = -EINVAL;
> + if (ret < 0)
> + return dev_err_probe(dev, ret,
> + "mux-offset-pin property missing or invalid");
> + num_fields = ret / 2;
> +
> + mux_chip = devm_mux_chip_alloc(dev, num_fields, sizeof(*mux_lan966x));
> + if (IS_ERR(mux_chip))
> + return dev_err_probe(dev, PTR_ERR(mux_chip),
> + "failed to allocate mux_chips\n");
> +
> + mux_lan966x = mux_chip_priv(mux_chip);
> +
> + flx_shared_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
> + if (IS_ERR(flx_shared_base))
> + return dev_err_probe(dev, PTR_ERR(flx_shared_base),
> + "failed to get flexcom shared base address\n");
> +
> + for (i = 0; i < num_fields; i++) {
> + struct mux_control *mux = &mux_chip->mux[i];
> + u32 offset, shared_pin;
> +
> + ret = of_property_read_u32_index(np, "mux-offset-pin",
> + 2 * i, &offset);
> + if (ret == 0)
> + ret = of_property_read_u32_index(np, "mux-offset-pin",
> + 2 * i + 1,
> + &shared_pin);
> + if (ret < 0)
> + return dev_err_probe(dev, ret,
> + "failed to read mux-offset-pin property: %d", i);
> +
> + if (shared_pin >= LAN966_MAX_CS)
> + return -EINVAL;
> +
> + mux_lan966x[i].offset = offset;
> + mux_lan966x[i].ss_pin = shared_pin;
> +
> + mux->states = LAN966_MAX_CS;
> + }
> +
> + mux_chip->ops = &mux_lan966x_ops;
> +
> + ret = devm_mux_chip_register(dev, mux_chip);
> + if (ret < 0)
> + return ret;
> +
> + return 0;
> +}
> +
> +static struct platform_driver mux_lan966x_driver = {
> + .driver = {
> + .name = "lan966-mux",
> + .of_match_table = of_match_ptr(mux_lan966x_dt_ids),
of_match_ptr comes with maybe_unused on data structure. Are you sure it
does not have W=1 warnings during compile tests? Just drop the of_match_ptr.
> + },
> + .probe = mux_lan966x_probe,
> +};
> +
> +module_platform_driver(mux_lan966x_driver);
Missing MODULE() stuff.
Best regards,
Krzysztof
next prev parent reply other threads:[~2022-05-03 12:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 10:55 [PATCH 0/4] Add support for lan966 flexcom multiplexer Kavyasree Kotagiri
2022-05-03 10:55 ` [PATCH 1/4] dt-bindings: mfd: atmel,flexcom: Convert to json-schema Kavyasree Kotagiri
2022-05-03 12:34 ` Krzysztof Kozlowski
2022-05-03 22:21 ` Rob Herring
2022-05-03 10:55 ` [PATCH 2/4] dt-bindings: mfd: atmel,flexcom: Add lan966 compatible string and mux properties Kavyasree Kotagiri
2022-05-03 12:37 ` Krzysztof Kozlowski
2022-05-03 10:55 ` [PATCH 3/4] dt-bindings: mux: Add lan966 flexcom mux controller Kavyasree Kotagiri
2022-05-03 12:42 ` Krzysztof Kozlowski
2022-05-03 10:55 ` [PATCH 4/4] mux: lan966: Add support for " Kavyasree Kotagiri
2022-05-03 12:45 ` Krzysztof Kozlowski [this message]
2022-05-09 8:25 ` Kavyasree.Kotagiri
2022-05-03 19:57 ` kernel test robot
2022-05-05 20:26 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e00ff3b2-d5d1-706d-49cc-e70fe2cc9cab@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=Manohar.Puri@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=devicetree@vger.kernel.org \
--cc=kavyasree.kotagiri@microchip.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nicolas.ferre@microchip.com \
--cc=peda@axentia.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).