Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp239400rwb; Mon, 26 Sep 2022 11:39:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XOUokd1D1B/NFGyiITL86eg8PvLvsoGUfnn2kTDGCEV2tZB424GuOzE2NRGyWlO7RSI+I X-Received: by 2002:a05:6402:27d0:b0:451:b381:e0a1 with SMTP id c16-20020a05640227d000b00451b381e0a1mr23505824ede.4.1664217581546; Mon, 26 Sep 2022 11:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664217581; cv=none; d=google.com; s=arc-20160816; b=tDaM8QXmYpyH2a1XRBKygglEPwTMsF3+fhjJJqzg3y9K1i6y0Gae/0Z34bD+/ypOXF D5VxVK4nNhaSB64UeF4B4gCw9rlFr7F0ez9xUA40qsayhCTf/cpdqaDaeO/eujo+3G3B Mq0xe0tfFWfrh+T4zVZuZ3oZV8C2oKIyhELNz0XkCBvB7QAVo+tLP/4G5r7SuofIVqw/ Fkg/FDyOsnCts9k44+4VrWKCV37CPPkRvRAdNjt2W/+t67TSk3LCAuHzRmZo/9nideBU hg/BgIS1EuDicuksrdM1xmMXGUPlwuHKaSmf9hUl6SiPCzciABfK5lDsmBJBI9LYmbNn liRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=ov5nWY71OfRJWDWCmEbalkIRmSd0mYAHuF9hJfhrdXk=; b=NT6kfwrt0hdS3CJE9ptTJgAIG2NUqmZfJbraWEaqP5c0iONx4a7iUoAr3s0yGY+ytG QeQZzV0OhHz2bMR0+wY3DFe7vI2xwobS79fZ1diz4JpOmLcNogRE7asT3gu1rTSgSxxW Xg4ZWxFtCUvYWHHZA0fpd2bLgoDwX6gJCl6iVFel64/B83Zo7VlYtbVv96VgzG+AfxgO tcdn7vonZLEoI1Rh5YLzZkmS7NMqB9QUPYSR8nPHvqVuvViY9HYmIbRoUAOT4tBzy4Il VGnvR5sNFNLjsGmIBVFDFvghtEOaJSxRYujg+tECeDP8xjtazzzxT1acY3Gj8a/vF+yX wc7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EFwaq5e6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa13-20020a170907868d00b0077c5ec87ec2si675293ejc.297.2022.09.26.11.39.03; Mon, 26 Sep 2022 11:39:41 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=EFwaq5e6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbiIZS2M (ORCPT + 99 others); Mon, 26 Sep 2022 14:28:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiIZS1l (ORCPT ); Mon, 26 Sep 2022 14:27:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2982E2E; Mon, 26 Sep 2022 11:27:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 632CDB80ACC; Mon, 26 Sep 2022 18:27:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D89EEC433C1; Mon, 26 Sep 2022 18:27:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664216832; bh=h2Ceidh4tSheNB/iFG8vH+y4KkoBbzZ0Sz2+DSuNFes=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=EFwaq5e6kyYxw7NdRVhdeAoIoeUBhIC8dEO5QjM7ma9xwZglgTLAZVyBdrRMIDB4O i66g3Bl2DYYQROl4eU3RFKFT/rruZhTod5VQCTpAD2XUjTtq9HJfXHg+dMO8VJhenw nfXNGTjx1zNGrWOzFyZ5DZsosA/8VzL88H22+TFC/ZHncEyVAthohiOfppCJnk178h qwqFXwjf54siBevVXAcqpPXMXL13C5YPBjE5SB2GawA4HvikZz+vx5TBk7APtnSC8+ 887G58bOCXC8YGTV4CjhvmvmrRT5jVla3m4P6GBg2OrxLcPlI93rLvVG6PLHOKJyC/ n5mjXoI+7wNPA== Date: Mon, 26 Sep 2022 13:27:10 -0500 From: Bjorn Helgaas To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Sergio Paracuellos , Matthias Brugger , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH 1/3] PCI: Add standard PCI Config Address macros Message-ID: <20220926182710.GA1613197@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220924092404.31776-2-pali@kernel.org> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Sat, Sep 24, 2022 at 11:24:02AM +0200, Pali Roh?r wrote: > Lot of PCI and PCIe controllers are using standard Config Address for PCI > Configuration Mechanism #1 (as defined in PCI Local Bus Specification) or > its extended version. > > So introduce new macros PCI_CONF1_ADDRESS() and PCI_CONF1_EXT_ADDRESS() in > include file drivers/pci/pci.h which can be suitable for PCI and PCIe > controllers which uses this type of access to PCI config space. > > Signed-off-by: Pali Roh?r Acked-by: Bjorn Helgaas > +#define PCI_CONF1_BUS_SHIFT 16 /* Bus number */ > +#define PCI_CONF1_DEV_SHIFT 11 /* Device number */ > +#define PCI_CONF1_FUNC_SHIFT 8 /* Function number */ > + > +#define PCI_CONF1_BUS_MASK 0xff > +#define PCI_CONF1_DEV_MASK 0x1f > +#define PCI_CONF1_FUNC_MASK 0x7 > +#define PCI_CONF1_REG_MASK 0xfc /* Limit aligned offset to a maximum of 256B */ Since all the above are used only in the macros below, I personally don't think they're really necessary and I would find it easier to read if they were just open-coded, e.g., +#define PCI_CONF1_BUS(x) (((x) & 0xff) << 16) +#define PCI_CONF1_DEV(x) (((x) & 0x1f) << 11) +#define PCI_CONF1_FUNC(x) (((x) & 0x07) << 8) +#define PCI_CONF1_REG(x) ( (x) & 0xfc) > +#define PCI_CONF1_ENABLE BIT(31) > +#define PCI_CONF1_BUS(x) (((x) & PCI_CONF1_BUS_MASK) << PCI_CONF1_BUS_SHIFT) > +#define PCI_CONF1_DEV(x) (((x) & PCI_CONF1_DEV_MASK) << PCI_CONF1_DEV_SHIFT) > +#define PCI_CONF1_FUNC(x) (((x) & PCI_CONF1_FUNC_MASK) << PCI_CONF1_FUNC_SHIFT) > +#define PCI_CONF1_REG(x) ((x) & PCI_CONF1_REG_MASK)