From: Corey Minyard <minyard@acm.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Corey Minyard <cminyard@mvista.com>,
openipmi-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 01/10] ipmi_si: Switch to use platform_get_mem_or_io()
Date: Fri, 2 Apr 2021 08:57:56 -0500 [thread overview]
Message-ID: <20210402135756.GU507977@minyard.net> (raw)
In-Reply-To: <20210330181649.66496-1-andriy.shevchenko@linux.intel.com>
On Tue, Mar 30, 2021 at 09:16:40PM +0300, Andy Shevchenko wrote:
> Switch to use new platform_get_mem_or_io() instead of home grown analogue.
> Note, we also introduce ipmi_set_addr_data_and_space() helper here.
You didn't send a part 0 that I saw, so just using this. This is a nice
cleanup set, I just had a few very minor nits. Thanks for this.
-corey
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/char/ipmi/ipmi_si_platform.c | 40 +++++++++++-----------------
> 1 file changed, 16 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index 129b5713f187..d7bd093f80e9 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -100,35 +100,32 @@ static int acpi_gpe_irq_setup(struct si_sm_io *io)
> }
> #endif
>
> +static void ipmi_set_addr_data_and_space(struct resource *r, struct si_sm_io *io)
> +{
> + io->addr_data = r->start;
> + if (resource_type(r) == IORESOURCE_IO)
> + io->addr_space = IPMI_IO_ADDR_SPACE;
> + else
> + io->addr_space = IPMI_MEM_ADDR_SPACE;
> +}
> +
> static struct resource *
> ipmi_get_info_from_resources(struct platform_device *pdev,
> struct si_sm_io *io)
> {
> - struct resource *res, *res_second;
> + struct resource *res, *second;
>
> - res = platform_get_resource(pdev, IORESOURCE_IO, 0);
> - if (res) {
> - io->addr_space = IPMI_IO_ADDR_SPACE;
> - } else {
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (res)
> - io->addr_space = IPMI_MEM_ADDR_SPACE;
> - }
> + res = platform_get_mem_or_io(pdev, 0);
> if (!res) {
> dev_err(&pdev->dev, "no I/O or memory address\n");
> return NULL;
> }
> - io->addr_data = res->start;
> + ipmi_set_addr_data_and_space(res, io);
>
> io->regspacing = DEFAULT_REGSPACING;
> - res_second = platform_get_resource(pdev,
> - (io->addr_space == IPMI_IO_ADDR_SPACE) ?
> - IORESOURCE_IO : IORESOURCE_MEM,
> - 1);
> - if (res_second) {
> - if (res_second->start > io->addr_data)
> - io->regspacing = res_second->start - io->addr_data;
> - }
> + second = platform_get_mem_or_io(pdev, 1);
> + if (second && resource_type(second) == resource_type(res) && second->start > io->addr_data)
> + io->regspacing = second->start - io->addr_data;
>
> return res;
> }
> @@ -275,12 +272,7 @@ static int of_ipmi_probe(struct platform_device *pdev)
> io.addr_source = SI_DEVICETREE;
> io.irq_setup = ipmi_std_irq_setup;
>
> - if (resource.flags & IORESOURCE_IO)
> - io.addr_space = IPMI_IO_ADDR_SPACE;
> - else
> - io.addr_space = IPMI_MEM_ADDR_SPACE;
> -
> - io.addr_data = resource.start;
> + ipmi_set_addr_data_and_space(&resource, &io);
>
> io.regsize = regsize ? be32_to_cpup(regsize) : DEFAULT_REGSIZE;
> io.regspacing = regspacing ? be32_to_cpup(regspacing) : DEFAULT_REGSPACING;
> --
> 2.30.2
>
prev parent reply other threads:[~2021-04-02 13:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 18:16 [PATCH v1 01/10] ipmi_si: Switch to use platform_get_mem_or_io() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 02/10] ipmi_si: Remove bogus err_free label Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 03/10] ipmi_si: Utilize temporary variable to hold device pointer Andy Shevchenko
2021-04-02 13:45 ` Corey Minyard
2021-03-30 18:16 ` [PATCH v1 04/10] ipmi_si: Use proper ACPI macros to check error code for failures Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 05/10] ipmi_si: Introduce panic_event_str array Andy Shevchenko
2021-04-02 13:48 ` Corey Minyard
2021-03-30 18:16 ` [PATCH v1 06/10] ipmi_si: Reuse si_to_str array in ipmi_hardcode_init_one() Andy Shevchenko
2021-04-02 13:53 ` Corey Minyard
2021-03-30 18:16 ` [PATCH v1 07/10] ipmi_si: Get rid of ->addr_source_cleanup() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 08/10] ipmi_si: Use strstrip() to remove surrounding spaces Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 09/10] ipmi_si: Drop redundant check before calling put_device() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 10/10] ipmi_si: Join string literals back Andy Shevchenko
2021-04-02 13:57 ` Corey Minyard [this message]
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=20210402135756.GU507977@minyard.net \
--to=minyard@acm.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=cminyard@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openipmi-developer@lists.sourceforge.net \
/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).