public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Csókás Bence" <csokas.bence@prolan.hu>
Cc: Vladimir Oltean <olteanv@gmail.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	trivial@kernel.org, Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Subject: Re: [RFC PATCH 2/2] net: include: mii: Refactor: Use BIT() for ADVERTISE_* bits
Date: Wed, 5 Jun 2024 18:48:10 +0200	[thread overview]
Message-ID: <1c4d8c46-3124-4a90-bc50-788cc3883d93@lunn.ch> (raw)
In-Reply-To: <52b9e3f4-8dd4-4696-9a47-0dc4eb59c013@prolan.hu>

On Wed, Jun 05, 2024 at 04:47:27PM +0200, Csókás Bence wrote:
> Hi!
> 
> On 6/5/24 16:13, Vladimir Oltean wrote:
> > On Wed, Jun 05, 2024 at 02:16:49PM +0200, Csókás, Bence wrote:
> > > Replace hex values with BIT() and GENMASK() for readability
> > > 
> > > Cc: trivial@kernel.org
> > > 
> > > Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>
> > > ---
> > 
> > You can't use BIT() and GENMASK() in headers exported to user space.
> > 
> > I mean you can, but the BIT() and GENMASK() macros themselves aren't
> > exported to user space, and you would break any application which used
> > values dependent on them.
> > 
> 
> I thought the vDSO headers (which currently hold the definition for `BIT()`)
> *are* exported. Though `GENMASK()`, and the headers which would normally
> include vdso/bits.h, might not be... But then again, is uapi/linux/mii.h
> itself even exported?

uapi .... I would expect everything below that is considered exported.

Take a look at the sources for mii-tool.c:

    if (bmcr & BMCR_ANENABLE) {
        if (bmsr & BMSR_ANEGCOMPLETE) {
            if (advert & lkpar) {
                strcat(buf, (lkpar & LPA_LPACK) ?
                       "negotiated" : "no autonegotiation,");
                strcat(buf, media_list(advert & lkpar, bmcr2 & lpa2>>2, 1));
                strcat(buf, ", ");
            } else {
                strcat(buf, "autonegotiation failed, ");
            }
        } else if (bmcr & BMCR_ANRESTART) {
            strcat(buf, "autonegotiation restarted, ");
        }
    } else {
        sprintf(buf+strlen(buf), "%s Mbit, %s duplex, ",
                ((bmcr2 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL)) & lpa2 >> 2)
                ? "1000"
                : (bmcr & BMCR_SPEED100) ? "100" : "10",
                (bmcr & BMCR_FULLDPLX) ? "full" : "half");
    }
    strcat(buf, (bmsr & BMSR_LSTATUS) ? "link ok" : "no link");

So they are actually used as well. Try compiling this with your
changes made.

	Andrew

  parent reply	other threads:[~2024-06-05 16:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 12:16 [RFC PATCH 1/2] net: include: mii: Refactor: Define LPA_* in terms of ADVERTISE_* Csókás, Bence
2024-06-05 12:16 ` [RFC PATCH 2/2] net: include: mii: Refactor: Use BIT() for ADVERTISE_* bits Csókás, Bence
2024-06-05 14:13   ` Vladimir Oltean
2024-06-05 14:47     ` Csókás Bence
2024-06-05 15:31       ` Vladimir Oltean
2024-06-05 16:48       ` Andrew Lunn [this message]
2024-06-05 12:51 ` [RFC PATCH 1/2] net: include: mii: Refactor: Define LPA_* in terms of ADVERTISE_* Andrew Lunn
2024-06-05 13:37   ` Csókás Bence

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=1c4d8c46-3124-4a90-bc50-788cc3883d93@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=csokas.bence@prolan.hu \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=trivial@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox