From: Dan Carpenter <dan.carpenter@oracle.com>
To: rtanwar@maxlinear.com
Cc: linux-clk@vger.kernel.org
Subject: [bug report] clk: mxl: Switch from direct readl/writel based IO to regmap based IO
Date: Mon, 24 Oct 2022 09:59:35 +0300 [thread overview]
Message-ID: <Y1Y31z6VqiuF/9Lp@kili> (raw)
Hello Rahul Tanwar,
The patch 036177310bac: "clk: mxl: Switch from direct readl/writel
based IO to regmap based IO" from Oct 13, 2022, leads to the
following Smatch static checker warning:
drivers/clk/x86/clk-lgm.c:441 lgm_cgu_probe()
warn: passing zero to 'PTR_ERR'
drivers/clk/x86/clk-lgm.c
424 static int lgm_cgu_probe(struct platform_device *pdev)
425 {
426 struct lgm_clk_provider *ctx;
427 struct device *dev = &pdev->dev;
428 struct device_node *np = dev->of_node;
429 int ret;
430
431 ctx = devm_kzalloc(dev, struct_size(ctx, clk_data.hws, CLK_NR_CLKS),
432 GFP_KERNEL);
433 if (!ctx)
434 return -ENOMEM;
435
436 ctx->clk_data.num = CLK_NR_CLKS;
437
438 ctx->membase = syscon_node_to_regmap(np);
439 if (IS_ERR_OR_NULL(ctx->membase)) {
440 dev_err(dev, "Failed to get clk CGU iomem\n");
--> 441 return PTR_ERR(ctx->membase);
Generally when a function returns NULL that is a special kind of success
path where the feature has been deliberately disabled. If for example,
LEDs have been disabled then the ethernet driver or whatever should just
handle that and continue functioning. (If there is an error in the LEDs
then report the error and do not ignore it).
Can this driver not continue without ctx->membase? Is it useful to
have a no-op probe function that just sets ctx->clk_data.num and returns
success? If it's not useful then it's better to handle it in the
Kconfig instead of waiting for the user to find it the hard way.
If CONFIG_MFD_SYSCON is turned off then syscon_node_to_regmap() does
not return NULL, it returns ERR_PTR(-ENOTSUPP). So the IS_ERR_OR_NULL()
doesn't make sense.
442 }
443
444
445 ctx->np = np;
446 ctx->dev = dev;
447
448 ret = lgm_clk_register_plls(ctx, lgm_pll_clks,
449 ARRAY_SIZE(lgm_pll_clks));
450 if (ret)
451 return ret;
452
453 ret = lgm_clk_register_branches(ctx, lgm_branch_clks,
454 ARRAY_SIZE(lgm_branch_clks));
455 if (ret)
456 return ret;
457
458 ret = lgm_clk_register_ddiv(ctx, lgm_ddiv_clks,
459 ARRAY_SIZE(lgm_ddiv_clks));
460 if (ret)
461 return ret;
462
463 return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
464 &ctx->clk_data);
465 }
regards,
dan carpenter
next reply other threads:[~2022-10-24 7:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 6:59 Dan Carpenter [this message]
2022-10-25 7:09 ` [bug report] clk: mxl: Switch from direct readl/writel based IO to regmap based IO Rahul Tanwar
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=Y1Y31z6VqiuF/9Lp@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-clk@vger.kernel.org \
--cc=rtanwar@maxlinear.com \
/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