All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Terry Bowman <terry.bowman@amd.com>,
	linux-watchdog@vger.kernel.org, jdelvare@suse.com,
	linux-i2c@vger.kernel.org, wsa@kernel.org,
	andy.shevchenko@gmail.com, rafael.j.wysocki@intel.com
Cc: linux-kernel@vger.kernel.org, wim@linux-watchdog.org,
	rrichter@amd.com, thomas.lendacky@amd.com,
	sudheesh.mavila@amd.com, Nehal-bakulchandra.Shah@amd.com,
	Basavaraj.Natikar@amd.com, Shyam-sundar.S-k@amd.com,
	Mario.Limonciello@amd.com
Subject: Re: [PATCH v4 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization
Date: Tue, 1 Feb 2022 07:31:10 -0800	[thread overview]
Message-ID: <ecf12beb-a03b-2aec-1dc4-8183a8b6daa6@roeck-us.net> (raw)
In-Reply-To: <20220130191225.303115-3-terry.bowman@amd.com>

On 1/30/22 11:12, Terry Bowman wrote:
> Combine MMIO base address and alternate base address detection. Combine
> based on layout type. This will simplify the function by eliminating
> a switch case.
> 
> Move existing request/release code into functions. This currently only
> supports port I/O request/release. The move into a separate function
> will make it ready for adding MMIO region support.
> 
> Co-developed-by: Robert Richter <rrichter@amd.com>
> Signed-off-by: Robert Richter <rrichter@amd.com>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
> Tested-by: Jean Delvare <jdelvare@suse.de>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
> ---
>   drivers/watchdog/sp5100_tco.c | 155 ++++++++++++++++++----------------
>   drivers/watchdog/sp5100_tco.h |   1 +
>   2 files changed, 82 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
> index b365bbc9ac36..16e122d5045e 100644
> --- a/drivers/watchdog/sp5100_tco.c
> +++ b/drivers/watchdog/sp5100_tco.c
> @@ -223,6 +223,55 @@ static u32 sp5100_tco_read_pm_reg32(u8 index)
>   	return val;
>   }
>   
> +static u32 sp5100_tco_request_region(struct device *dev,
> +				     u32 mmio_addr,
> +				     const char *dev_name)
> +{
> +	if (!devm_request_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE,
> +				     dev_name)) {
> +		dev_dbg(dev, "MMIO address 0x%08x already in use\n", mmio_addr);
> +		return 0;
> +	}
> +
> +	return mmio_addr;
> +}
> +
> +static u32 sp5100_tco_prepare_base(struct sp5100_tco *tco,
> +				   u32 mmio_addr,
> +				   u32 alt_mmio_addr,
> +				   const char *dev_name)
> +{
> +	struct device *dev = tco->wdd.parent;
> +
> +	dev_dbg(dev, "Got 0x%08x from SBResource_MMIO register\n", mmio_addr);
> +
> +	if (!mmio_addr && !alt_mmio_addr)
> +		return -ENODEV;
> +
> +	/* Check for MMIO address and alternate MMIO address conflicts */
> +	if (mmio_addr)
> +		mmio_addr = sp5100_tco_request_region(dev, mmio_addr, dev_name);
> +
> +	if (!mmio_addr && alt_mmio_addr)
> +		mmio_addr = sp5100_tco_request_region(dev, alt_mmio_addr, dev_name);
> +
> +	if (!mmio_addr) {
> +		dev_err(dev, "Failed to reserve MMIO or alternate MMIO region\n");
> +		return -EBUSY;
> +	}
> +
> +	tco->tcobase = devm_ioremap(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE);
> +	if (!tco->tcobase) {
> +		dev_err(dev, "MMIO address 0x%08x failed mapping\n", mmio_addr);
> +		devm_release_mem_region(dev, mmio_addr, SP5100_WDT_MEM_MAP_SIZE);
> +		return -ENOMEM;
> +	}
> +
> +	dev_info(dev, "Using 0x%08x for watchdog MMIO address\n", tco->tcobase);
> +

I know this is the same as the old code, but I think it would make sense to change
this as suggested by 0-day and use %px instead.

Thanks,
Guenter

  parent reply	other threads:[~2022-02-01 15:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-30 19:12 [PATCH v4 0/4] Watchdog: sp5100_tco: Replace cd6h/cd7h port I/O accesses with MMIO accesses Terry Bowman
2022-01-30 19:12 ` [PATCH v4 1/4] Watchdog: sp5100_tco: Move timer initialization into function Terry Bowman
2022-01-30 19:12 ` [PATCH v4 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization Terry Bowman
2022-01-31  2:52   ` kernel test robot
2022-01-31  2:52     ` kernel test robot
2022-01-31  3:13   ` kernel test robot
2022-01-31  3:13     ` kernel test robot
2022-02-01 15:31   ` Guenter Roeck [this message]
2022-02-01 16:46     ` Terry Bowman
2022-02-01 20:32       ` Terry Bowman
2022-02-01 22:36         ` Guenter Roeck
2022-01-30 19:12 ` [PATCH v4 3/4] Watchdog: sp5100_tco: Add initialization using EFCH MMIO Terry Bowman
2022-01-31  5:37   ` kernel test robot
2022-01-31  5:37     ` kernel test robot
2022-01-31  5:58   ` kernel test robot
2022-01-31  5:58     ` kernel test robot
2022-01-30 19:12 ` [PATCH v4 4/4] Watchdog: sp5100_tco: Enable Family 17h+ CPUs Terry Bowman
2022-02-07 12:44 ` [PATCH v4 0/4] Watchdog: sp5100_tco: Replace cd6h/cd7h port I/O accesses with MMIO accesses Jean Delvare
2022-02-07 13:03   ` Wolfram Sang
2022-02-08  9:45     ` Jean Delvare
2022-02-08 10:00       ` Wolfram Sang
2022-02-08 14:20         ` Jean Delvare

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=ecf12beb-a03b-2aec-1dc4-8183a8b6daa6@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rrichter@amd.com \
    --cc=sudheesh.mavila@amd.com \
    --cc=terry.bowman@amd.com \
    --cc=thomas.lendacky@amd.com \
    --cc=wim@linux-watchdog.org \
    --cc=wsa@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.