[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c1d121f7-f482-7913-eced-4fbef962656d@amd.com>
Date: Tue, 1 Feb 2022 10:46:53 -0600
From: Terry Bowman <Terry.Bowman@....com>
To: Guenter Roeck <linux@...ck-us.net>, linux-watchdog@...r.kernel.org,
jdelvare@...e.com, linux-i2c@...r.kernel.org, wsa@...nel.org,
andy.shevchenko@...il.com, rafael.j.wysocki@...el.com
Cc: linux-kernel@...r.kernel.org, wim@...ux-watchdog.org,
rrichter@....com, thomas.lendacky@....com, sudheesh.mavila@....com,
Nehal-bakulchandra.Shah@....com, Basavaraj.Natikar@....com,
Shyam-sundar.S-k@....com, Mario.Limonciello@....com
Subject: Re: [PATCH v4 2/4] Watchdog: sp5100_tco: Refactor MMIO base address
initialization
On 2/1/22 09:31, Guenter Roeck wrote:
> 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@....com>
>> Signed-off-by: Robert Richter <rrichter@....com>
>> Signed-off-by: Terry Bowman <terry.bowman@....com>
>> Tested-by: Jean Delvare <jdelvare@...e.de>
>> Reviewed-by: Jean Delvare <jdelvare@...e.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
Hi Guenter,
I'll add the change to v5.
Regards,
Terry
Powered by blists - more mailing lists