From: Bjorn Helgaas <helgaas@kernel.org>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
Kelvin.Cao@microchip.com, Eric Pilmore <epilmore@gigaio.com>,
Doug Meyer <dmeyer@gigaio.com>
Subject: Re: [PATCH 08/12] PCI/switchtec: Add gen4 support in struct sys_info_regs
Date: Wed, 8 Jan 2020 15:21:44 -0600 [thread overview]
Message-ID: <20200108212144.GA209154@google.com> (raw)
In-Reply-To: <20200106190337.2428-9-logang@deltatee.com>
On Mon, Jan 06, 2020 at 12:03:33PM -0700, Logan Gunthorpe wrote:
> Add a union with gen3 and gen4 sys_info structs. Ensure any use of the
> gen3 struct is gaurded by an if statement on stdev->gen.
s/gaurded/guarded/
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> ---
> drivers/pci/switch/switchtec.c | 41 +++++++++++++++++++++++++++---
> include/linux/switchtec.h | 46 +++++++++++++++++++++++++++++++++-
> 2 files changed, 82 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index 21d3dd6e74f9..90d9c00984a7 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -317,8 +317,14 @@ static ssize_t field ## _show(struct device *dev, \
> struct device_attribute *attr, char *buf) \
> { \
> struct switchtec_dev *stdev = to_stdev(dev); \
> - return io_string_show(buf, &stdev->mmio_sys_info->gen3.field, \
> - sizeof(stdev->mmio_sys_info->gen3.field)); \
> + struct sys_info_regs __iomem *si = stdev->mmio_sys_info; \
> + \
> + if (stdev->gen == SWITCHTEC_GEN4) \
> + return io_string_show(buf, &si->gen4.field, \
> + sizeof(si->gen4.field)); \
> + else \
> + return io_string_show(buf, &si->gen3.field, \
> + sizeof(si->gen3.field)); \
> } \
> \
> static DEVICE_ATTR_RO(field)
> @@ -326,7 +332,21 @@ static DEVICE_ATTR_RO(field)
> DEVICE_ATTR_SYS_INFO_STR(vendor_id);
> DEVICE_ATTR_SYS_INFO_STR(product_id);
> DEVICE_ATTR_SYS_INFO_STR(product_revision);
> -DEVICE_ATTR_SYS_INFO_STR(component_vendor);
> +
> +static ssize_t component_vendor_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct switchtec_dev *stdev = to_stdev(dev);
> + struct sys_info_regs __iomem *si = stdev->mmio_sys_info;
> +
> + /* component_vendor field not supported after gen4 */
> + if (stdev->gen != SWITCHTEC_GEN3)
I assume the comment should say "after gen3"? More occurrences below.
> + return sprintf(buf, "none\n");
> +
> + return io_string_show(buf, &si->gen3.component_vendor,
> + sizeof(si->gen3.component_vendor));
> +}
> +static DEVICE_ATTR_RO(component_vendor);
>
> static ssize_t component_id_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> @@ -334,6 +354,10 @@ static ssize_t component_id_show(struct device *dev,
> struct switchtec_dev *stdev = to_stdev(dev);
> int id = ioread16(&stdev->mmio_sys_info->gen3.component_id);
>
> + /* component_id field not supported after gen4 */
> + if (stdev->gen != SWITCHTEC_GEN3)
> + return sprintf(buf, "none\n");
> +
> return sprintf(buf, "PM%04X\n", id);
> }
> static DEVICE_ATTR_RO(component_id);
> @@ -344,6 +368,10 @@ static ssize_t component_revision_show(struct device *dev,
> struct switchtec_dev *stdev = to_stdev(dev);
> int rev = ioread8(&stdev->mmio_sys_info->gen3.component_revision);
>
> + /* component_revision field not supported after gen4 */
> + if (stdev->gen != SWITCHTEC_GEN3)
> + return sprintf(buf, "255\n");
> +
next prev parent reply other threads:[~2020-01-08 21:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-06 19:03 [PATCH 00/12] Switchtec Fixes and Gen4 Support Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 01/12] PCI/switchtec: Use dma_set_mask_and_coherent() Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 02/12] PCI/switchtec: Fix vep_vector_number ioread width Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 03/12] PCI/switchtec: Add support for new events Logan Gunthorpe
2020-01-08 21:33 ` Bjorn Helgaas
2020-01-08 21:47 ` Logan Gunthorpe
2020-01-14 2:07 ` Kelvin.Cao
2020-01-14 18:21 ` Logan Gunthorpe
2020-01-14 19:07 ` Bjorn Helgaas
2020-01-06 19:03 ` [PATCH 04/12] PCI/switchtec: Remove redundant valid PFF number count Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 05/12] PCI/switchtec: Move check event id from mask_event() to switchtec_event_isr() Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 06/12] PCI/switchtec: Introduce Generation Variable Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 07/12] PCI/switchtec: Separate out gen3 specific fields in the sys_info_regs structure Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 08/12] PCI/switchtec: Add gen4 support in struct sys_info_regs Logan Gunthorpe
2020-01-08 21:21 ` Bjorn Helgaas [this message]
2020-01-06 19:03 ` [PATCH 09/12] PCI/switchtec: Add gen4 support in struct flash_info_regs Logan Gunthorpe
2020-01-08 21:23 ` Bjorn Helgaas
2020-01-08 21:34 ` Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 10/12] PCI/switchtec: Add permission check for the GAS access MRPC commands Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 11/12] PCI/switchtec: Introduce gen4 variant IDS in the device ID table Logan Gunthorpe
2020-01-06 19:03 ` [PATCH 12/12] PCI: Apply switchtec DMA aliasing quirk to GEN4 devices Logan Gunthorpe
2020-01-08 21:47 ` [PATCH 00/12] Switchtec Fixes and Gen4 Support Bjorn Helgaas
2020-01-08 21:53 ` Logan Gunthorpe
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=20200108212144.GA209154@google.com \
--to=helgaas@kernel.org \
--cc=Kelvin.Cao@microchip.com \
--cc=dmeyer@gigaio.com \
--cc=epilmore@gigaio.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=logang@deltatee.com \
/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.