Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1740740pxb; Wed, 9 Feb 2022 03:34:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxg929f5fkx90Hd7N4Twpg6aQfI0rzrf7QoMtgvtr+FuYk4yIC7gF4drJQZNgTDRs7kdxuT X-Received: by 2002:a17:902:ea10:: with SMTP id s16mr1975443plg.111.1644406494140; Wed, 09 Feb 2022 03:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644406494; cv=none; d=google.com; s=arc-20160816; b=ffXJrKDlgjvDxqEFaXUCXW/BAaRUldvxAWEv3nzxzno2CZI5vcYoCYzU2mlADoflH7 uLmekEkhiFO909gwaSBXzNkSbPcetsCXxRrqoo/38iVZ7/H5QWAO0l58uizyjJjO1O3Y c7C+uwAqxUz5mwy/7yF3QV7YZNAXCgeniuvLgBSKuO3/w0yZ8m1qwdefzyKDC9AY4nkl OaSD/S443kaM+0nzF259Cq62xTRVnooy/WJNRBSm8f5Y3kiSb6qjepNtGG6ga3aT3FlW +88KWBY7Caaa/SmGmkv/ppD1WQjBkfc0k6uQEZc+gvPrX0iBi09k1RKbnuEuNgGd1El5 wBlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:dkim-signature; bh=F8fCX7jpBJSdTGWVH6OOOBQBhn3uvoR/Uftrbxcu2D0=; b=m/oFHd3wQs4HhObvHHbhWxnPPMzzYbbyXy8de8UJf/6fZLwuS44R3heOO6DvGHVcl2 SWpGG86zxHOgkCZ7X26G437zic6qNS3e2FASyaxMs7C/gjgaqfpNBgH5zwz48Bz3qNWu Kk/LOv6v6Z/kC7t/VKllkzRnRym7Gz8X7vCLIFym9zfmdw+8oSOVJKSqADnlYAm1FeFY v8gJO3cLmtlRecqjCbau7i/p3n9A1hQsl8hSLCtl4NnB/H+dD8AKUHNSaMAghB7jibJQ fmKotRtBrFE0qee4HgiLoPCgYwAabPpZ948BJvJqkUpixqGyXrVdBHR5EohCj8Cj+iCE oXHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gZUkN49I; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u2si14288628plm.167.2022.02.09.03.34.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gZUkN49I; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08117E076B4E; Wed, 9 Feb 2022 01:53:45 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351626AbiBHOpb (ORCPT + 99 others); Tue, 8 Feb 2022 09:45:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351484AbiBHOp2 (ORCPT ); Tue, 8 Feb 2022 09:45:28 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8BCC03FED4; Tue, 8 Feb 2022 06:45:27 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6EEFD1F387; Tue, 8 Feb 2022 14:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1644331526; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F8fCX7jpBJSdTGWVH6OOOBQBhn3uvoR/Uftrbxcu2D0=; b=gZUkN49ITaU744saGHPoaBrHxebr7OVW0K3A02xnMR0qLfJHWISh2ExbOqTgBd+pm7+txn TpHyxG9CeReB6H1Rq68OUBo+JGURds0H56Cnc9mfJ7JP5NtHwSNSsY5ZmZy7l+fMgxNzVy BrG5Pw30Bbd1nXt7jBrKLZZcCGdnkYk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1644331526; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F8fCX7jpBJSdTGWVH6OOOBQBhn3uvoR/Uftrbxcu2D0=; b=zF1lHTovq6sClWtl35NOT8VHMi1709bKDEzHdRe3pUQMftZY1A99N/+9uU95qZQpK6CO1F 1xK69EzqDluIeSAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D9CE413C79; Tue, 8 Feb 2022 14:45:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0a1rMwWCAmI3DgAAMHmgww (envelope-from ); Tue, 08 Feb 2022 14:45:25 +0000 Date: Tue, 8 Feb 2022 15:45:24 +0100 From: Jean Delvare To: Terry Bowman Cc: , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 3/9] i2c: piix4: Move port I/O region request/release code into functions Message-ID: <20220208154524.283609ad@endymion.delvare> In-Reply-To: <20220130184130.176646-4-terry.bowman@amd.com> References: <20220130184130.176646-1-terry.bowman@amd.com> <20220130184130.176646-4-terry.bowman@amd.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Terry, On Sun, 30 Jan 2022 12:41:24 -0600, Terry Bowman wrote: > Move duplicated region request and release code into a function. Move is > in preparation for following MMIO changes. > > Signed-off-by: Terry Bowman > --- > drivers/i2c/busses/i2c-piix4.c | 39 +++++++++++++++++++++++----------- > 1 file changed, 27 insertions(+), 12 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c > index 3ff68967034e..5a98970ac60a 100644 > --- a/drivers/i2c/busses/i2c-piix4.c > +++ b/drivers/i2c/busses/i2c-piix4.c > @@ -165,6 +165,24 @@ struct i2c_piix4_adapdata { > u8 port; /* Port number, shifted */ > }; > > +static int piix4_sb800_region_request(struct device *dev) > +{ > + if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, > + "sb800_piix4_smb")) { > + dev_err(dev, > + "SMBus base address index region 0x%x already in use.\n", > + SB800_PIIX4_SMB_IDX); > + return -EBUSY; > + } > + > + return 0; > +} > + > +static void piix4_sb800_region_release(struct device *dev) > +{ > + release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); > +} > + > static int piix4_setup(struct pci_dev *PIIX4_dev, > const struct pci_device_id *id) > { > @@ -270,6 +288,7 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, > unsigned short piix4_smba; > u8 smba_en_lo, smba_en_hi, smb_en, smb_en_status, port_sel; > u8 i2ccfg, i2ccfg_offset = 0x10; > + int retval; > > /* SB800 and later SMBus does not support forcing address */ > if (force || force_addr) { > @@ -291,20 +310,16 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, > else > smb_en = (aux) ? 0x28 : 0x2c; > > - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, > - "sb800_piix4_smb")) { > - dev_err(&PIIX4_dev->dev, > - "SMB base address index region 0x%x already in use.\n", > - SB800_PIIX4_SMB_IDX); > - return -EBUSY; > - } > + retval = piix4_sb800_region_request(&PIIX4_dev->dev); > + if (retval) > + return retval; > > outb_p(smb_en, SB800_PIIX4_SMB_IDX); > smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1); > outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX); > smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1); > > - release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); > + piix4_sb800_region_release(&PIIX4_dev->dev); > > if (!smb_en) { > smb_en_status = smba_en_lo & 0x10; > @@ -685,9 +700,9 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, > u8 port; > int retval; > > - if (!request_muxed_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE, > - "sb800_piix4_smb")) > - return -EBUSY; > + retval = piix4_sb800_region_request(&adap->dev); > + if (retval) > + return retval; > > /* Request the SMBUS semaphore, avoid conflicts with the IMC */ > smbslvcnt = inb_p(SMBSLVCNT); > @@ -762,7 +777,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, > piix4_imc_wakeup(); > > release: > - release_region(SB800_PIIX4_SMB_IDX, SB800_PIIX4_SMB_MAP_SIZE); > + piix4_sb800_region_release(&adap->dev); > return retval; > } > There's a third occurrence of request_muxed_region(SB800_PIIX4_SMB_IDX, ...) / release_region(SB800_PIIX4_SMB_IDX, ...) in function piix4_setup_sb800. Any reason why you don't make use of the new helper functions there as well? OK, I see that this part of the code is specific to the original (ATI) SB800, so it can't use MMIO, therefore you don't *have* to call the helper functions. But for consistency, wouldn't it still make sense to use them? -- Jean Delvare SUSE L3 Support