Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1464689pxb; Wed, 2 Feb 2022 05:40:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOjaJB9CLloix7ml385Hr4SUIdY4K9nN8hNUb1h3W5gHinNF+IDWpBiKv7m3HzdOXAIzOR X-Received: by 2002:a63:6b43:: with SMTP id g64mr12176902pgc.396.1643809234503; Wed, 02 Feb 2022 05:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643809234; cv=none; d=google.com; s=arc-20160816; b=UGeXCPvCIZvl2nH4POqE8Ex6yvBC/qdZhWNrOkKhjWCgI5JWcOv8egQA+/beIsKJyp UWRz2QLmJp2Lxy9RN5HgMUXTv9deTbhNSWSEVULjTWjR3D/jqPstz8Xq5BIQfh0bPghP 9vNr2f7lXtD09rA2FlzQ6UNs3Qcoikm412e3PSQEG6/0SvnQWdrC5cIi3F34ugyL+GpN UxpZojJR/x3hXDvhw1wkUZGSs3cxj8YKNh6V2Zqgfu4JPlRn+5J7sDM+3cIAS+8sCi4f 28+4u8CqWxSoJhHrzl7wdZBks9w5uU5FqFXmmVfrv4tM8i3sk8L1uD4RD/kA/uhlfwO1 4lYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=UPBnfs9IIErMG9UWZegVg4Nd9cpkesaMUdLMx6iOWuY=; b=BeRQ8NM0ZhOijtFqlCjJyLS8jsTb3n6C8wxWrk3w7QoDArmnNl2Lh3hj7n+iD3780Q tDg6MdPh2CqUdVkEKXfcA6ZlAfX04Y0o9BoayJdRgq/fSKeXvV9LYvFvdxupr5bhLYrn lONrADgQo5vswbp+G6dxPLYiXTF3DlBCuEz7b74e3NVoZIQn2+KnwFROTT+b996DYnqC hC3/FTPJvaK2dm61Kdpth3PAAAaSj5goj88xDrC3Ec5NOAuTrC0fNFodoBrefUKgrJhu vsDDLsPYF3zIKiFvqeiWxnCfqhktn03ZNMK5xkYcuNZQgFKJmbacZSN0SJmIDRj2mw0H wRmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lr2bhrke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf4si5051610pjb.27.2022.02.02.05.40.21; Wed, 02 Feb 2022 05:40:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lr2bhrke; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240407AbiBAPbP (ORCPT + 99 others); Tue, 1 Feb 2022 10:31:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239751AbiBAPbO (ORCPT ); Tue, 1 Feb 2022 10:31:14 -0500 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBBEBC061714; Tue, 1 Feb 2022 07:31:13 -0800 (PST) Received: by mail-oi1-x235.google.com with SMTP id m9so33918734oia.12; Tue, 01 Feb 2022 07:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=UPBnfs9IIErMG9UWZegVg4Nd9cpkesaMUdLMx6iOWuY=; b=lr2bhrkeFJA1c5oGu5C1DnADC/V4XKTdW2A76wWKma9+WhHxU+DplKi3EoZ6xRVz9x k2k+eJbiDh0OOeJ26V/t6OEK091u5D/zvnfmXAygsN7WYLKhX5y9hcZWRmjUvW3IFwt/ CpFj4+ViqE9esBbCsTN9us39ea8QXNE+6v3OTqFSxv2u6Fni4q+XFFej4qhhrmPz9bbm CRXlmyBjWss06ncduG+YKH1FzD9G0XT9vTQwj6cazSlqSPJ6nIg3WyhBbA5Lpr9MxFkn b00nf7VWvBeTViHrmbZQx27EzmtAYbM8QDZ/Zzeyub14titelz514gaxmHXZgU8n0GbP Xt2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=UPBnfs9IIErMG9UWZegVg4Nd9cpkesaMUdLMx6iOWuY=; b=PM4EnaKeep/L/ES8J0qVh2fyOdSJNefqN1HPft6pSsR3GhgdA7TeDdw2KaOJNqtOjQ ODExP3jEHz6nQuhAonRz+DNJMkrwv5KzftvUb88otmF+p6vy1aGg7MSYiC82MOFZKbyv Rd9rUaCEsgbDWMsjStN9aCV8GWw8TIiL4Nyo/U/vp7dZisLhfhnhQZ0+9WtYgx6Ugot7 HM45BAVcoPBBUDmMPk5dj1mMLXn01oEKHYn02HnF4J0yFueEFZLhxe/2czhgngU7bVWw 5Q6TePXweXTRIkUfYVjRgV1FWIss02Aynh0XZQj3sJGJufnrtgXAtupgqjLi1KgTmv86 pMRg== X-Gm-Message-State: AOAM532Xqt+LMI4GdjIL+xVYOCb4WUinPceadxmSJYWxQfMwT7vLfI43 8uB1G6PYq7ZY/9By1XG3kh4= X-Received: by 2002:a05:6808:23ca:: with SMTP id bq10mr1486267oib.281.1643729473327; Tue, 01 Feb 2022 07:31:13 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y3sm17616850oix.41.2022.02.01.07.31.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Feb 2022 07:31:12 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Tue, 1 Feb 2022 07:31:10 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 2/4] Watchdog: sp5100_tco: Refactor MMIO base address initialization Content-Language: en-US To: Terry Bowman , 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 References: <20220130191225.303115-1-terry.bowman@amd.com> <20220130191225.303115-3-terry.bowman@amd.com> From: Guenter Roeck In-Reply-To: <20220130191225.303115-3-terry.bowman@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Robert Richter > Signed-off-by: Terry Bowman > Tested-by: Jean Delvare > Reviewed-by: Jean Delvare > --- > 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