Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Aug 2017 07:43:14 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Alexander Motin <mav@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r323053 - head/sys/dev/ntb/ntb_hw
Message-ID:  <CAG6CVpUASypmZmg3F=4w-BkB04kSZF8ezCLDUF85Oh91%2BnoytQ@mail.gmail.com>
In-Reply-To: <201708311341.v7VDfirg037860@repo.freebsd.org>
References:  <201708311341.v7VDfirg037860@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Mav,

On Thu, Aug 31, 2017 at 6:41 AM, Alexander Motin <mav@freebsd.org> wrote:
> Author: mav
> Date: Thu Aug 31 13:41:44 2017
> New Revision: 323053
> URL: https://svnweb.freebsd.org/changeset/base/323053
>
> Log:
>   Fix port control for PEX 8749.
>
>   That chip has three Station Ports, so previous address math was incorrect.
>
>   MFC after:    13 days
>   Sponsored by: iXsystems, Inc.
>
> Modified:
>   head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
>
> Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
> ==============================================================================
> --- head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c        Thu Aug 31 13:32:01 2017        (r323052)
> +++ head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c        Thu Aug 31 13:41:44 2017        (r323053)
> @@ -473,7 +473,7 @@ ntb_plx_link_enable(device_t dev, enum ntb_speed speed
>                 return (0);
>         }
>
> -       reg = (sc->port < 8) ? 0x00208 : 0x08208;
> +       reg = ((sc->port & ~7) << 12) | 0x208;
>         val = bus_read_4(sc->conf_res, reg);
>         if ((val & (1 << (sc->port & 7))) == 0) {
>                 /* If already enabled, generate fake link event and exit. */
> @@ -495,7 +495,7 @@ ntb_plx_link_disable(device_t dev)
>         if (sc->link)
>                 return (0);
>
> -       reg = (sc->port < 8) ? 0x00208 : 0x08208;
> +       reg = ((sc->port & ~7) << 12) | 0x208;
>         val = bus_read_4(sc->conf_res, reg);
>         val |= (1 << (sc->port & 7));
>         bus_write_4(sc->conf_res, reg, val);
> @@ -512,7 +512,7 @@ ntb_plx_link_enabled(device_t dev)
>         if (sc->link)
>                 return (TRUE);
>
> -       reg = (sc->port < 8) ? 0x00208 : 0x08208;
> +       reg = ((sc->port & ~7) << 12) | 0x208;
>         val = bus_read_4(sc->conf_res, reg);
>         return ((val & (1 << (sc->port & 7))) == 0);
>  }
>

To me, the duplication strongly suggests that this should be a macro.

Best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpUASypmZmg3F=4w-BkB04kSZF8ezCLDUF85Oh91%2BnoytQ>