From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Kartik <kkartik@nvidia.com>
Cc: thierry.reding@gmail.com, jonathanh@nvidia.com,
sumitg@nvidia.com, arnd@arndb.de, pshete@nvidia.co,
digetx@gmail.com, petlozup@nvidia.com, windhl@126.com,
frank.li@vivo.com, robh@kernel.org, stefank@nvidia.com,
pdeschrijver@nvidia.com, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] soc/tegra: fuse: Add tegra_acpi_init_apbmisc()
Date: Fri, 18 Aug 2023 16:21:57 +0300 [thread overview]
Message-ID: <ZN9wdTLK1rwnVK/e@smile.fi.intel.com> (raw)
In-Reply-To: <20230818093028.7807-2-kkartik@nvidia.com>
On Fri, Aug 18, 2023 at 03:00:23PM +0530, Kartik wrote:
> In preparation to ACPI support in Tegra fuse driver add function
> tegra_acpi_init_apbmisc() and move common code used for both ACPI and
> device-tree into a new helper function tegra_init_apbmisc_base().
>
> Note that function tegra_acpi_init_apbmisc() is not placed in the __init
> section, because it will be called during probe.
...
> void tegra_init_revision(void);
> void tegra_init_apbmisc(void);
> +void tegra_acpi_init_apbmisc(void);
Why do you need a separate function?
...
> +static const struct acpi_device_id apbmisc_acpi_match[] = {
> + { .id = "NVDA2010", 0 },
We rarely use C99 initializers for ACPI ID table.
Also 0 is not needed.
> + { /* sentinel */ }
> +};
...
> + if (!apbmisc_base)
> + pr_err("failed to map APBMISC registers\n");
> + else
> + chipid = readl_relaxed(apbmisc_base + 4);
Why not positive conditional as you have two branches anyway?
...
> + if (!strapping_base) {
> + pr_err("failed to map strapping options registers\n");
> + } else {
> + strapping = readl_relaxed(strapping_base);
> + iounmap(strapping_base);
> + }
Ditto.
...
> - apbmisc_base = ioremap(apbmisc.start, resource_size(&apbmisc));
> - if (!apbmisc_base) {
> - pr_err("failed to map APBMISC registers\n");
> - } else {
> - chipid = readl_relaxed(apbmisc_base + 4);
> - }
> -
> - strapping_base = ioremap(straps.start, resource_size(&straps));
> - if (!strapping_base) {
> - pr_err("failed to map strapping options registers\n");
> - } else {
> - strapping = readl_relaxed(strapping_base);
> - iounmap(strapping_base);
> - }
> -
> + tegra_init_apbmisc_base(&apbmisc, &straps);
This split can be done in a separate precursor patch.
...
> +void tegra_acpi_init_apbmisc(void)
> +{
> + struct acpi_device *adev = NULL;
> + struct resource *apbmisc, *straps;
> + struct list_head resource_list;
> + struct resource_entry *rentry;
> + int rcount;
> +
> + adev = acpi_dev_get_first_match_dev(apbmisc_acpi_match[0].id, NULL, -1);
> + if (!adev)
> + return;
> +
> + INIT_LIST_HEAD(&resource_list);
> +
> + rcount = acpi_dev_get_memory_resources(adev, &resource_list);
> + if (rcount != 2) {
> + pr_err("failed to get APBMISC memory resources");
(1)
> + return;
> + }
> + rentry = list_first_entry(&resource_list, struct resource_entry, node);
> + apbmisc = rentry->res;
> + rentry = list_next_entry(rentry, node);
> + straps = rentry->res;
We don't do like this, we walk through them and depending on the type and index
do something. The above if error prone and not scalable code.
> + tegra_init_apbmisc_base(apbmisc, straps);
> + acpi_dev_free_resource_list(&resource_list);
Not okay in (1).
> + acpi_dev_put(adev);
Not okay in (1).
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-08-18 13:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-18 9:30 [PATCH 0/6] soc/tegra: fuse: Add ACPI support Kartik
2023-08-18 9:30 ` [PATCH 1/6] soc/tegra: fuse: Add tegra_acpi_init_apbmisc() Kartik
2023-08-18 13:21 ` Andy Shevchenko [this message]
2023-08-21 11:32 ` Kartik
2023-08-21 12:32 ` Andy Shevchenko
2023-08-22 7:52 ` Thierry Reding
2023-08-22 3:12 ` kernel test robot
2023-08-22 4:01 ` kernel test robot
2023-08-18 9:30 ` [PATCH 2/6] soc/tegra: fuse: Add function to register nvmem Kartik
2023-08-18 13:50 ` Andy Shevchenko
2023-08-21 11:34 ` Kartik
2023-08-18 9:30 ` [PATCH 3/6] soc/tegra: fuse: Add function to add lookups Kartik
2023-08-18 14:06 ` Andy Shevchenko
2023-08-21 11:36 ` Kartik
2023-08-18 9:30 ` [PATCH 4/6] soc/tegra: fuse: Add function to print SKU info Kartik
2023-08-22 7:55 ` Thierry Reding
2023-08-18 9:30 ` [PATCH 5/6] soc/tegra: fuse: Add ACPI support for Tegra194 and Tegra234 Kartik
2023-08-18 15:07 ` Andy Shevchenko
2023-08-21 11:38 ` Kartik
2023-08-21 12:45 ` Andy Shevchenko
2023-08-18 9:30 ` [PATCH 6/6] soc/tegra: fuse: Add support for Tegra241 Kartik
2023-08-18 15:10 ` Andy Shevchenko
2023-08-21 11:40 ` Kartik
2023-08-21 12:47 ` Andy Shevchenko
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=ZN9wdTLK1rwnVK/e@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=digetx@gmail.com \
--cc=frank.li@vivo.com \
--cc=jonathanh@nvidia.com \
--cc=kkartik@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pdeschrijver@nvidia.com \
--cc=petlozup@nvidia.com \
--cc=pshete@nvidia.co \
--cc=robh@kernel.org \
--cc=stefank@nvidia.com \
--cc=sumitg@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=windhl@126.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
all inboxes | Powered by JetHome®