From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@savoirfairelinux.com,
"David S. Miller" <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next v3 11/12] net: dsa: mv88e6xxx: add G1 helper for ageing time
Date: Tue, 19 Jul 2016 16:45:18 +0200 [thread overview]
Message-ID: <20160719144518.GC31103@lunn.ch> (raw)
In-Reply-To: <20160719004540.1066-12-vivien.didelot@savoirfairelinux.com>
> +static int mv88e6xxx_g1_set_age_time(struct mv88e6xxx_chip *chip,
> + unsigned int msecs)
> +{
> + const unsigned int coeff = chip->info->age_time_coeff;
> + const unsigned int min = 0x01 * coeff;
> + const unsigned int max = 0xff * coeff;
> + u8 age_time;
> + u16 val;
> + int err;
> +
> + if (msecs < min || msecs > max)
> + return -ERANGE;
> +
> + /* Round to nearest multiple of coeff */
> + age_time = (msecs + coeff / 2) / coeff;
> +
> + err = mv88e6xxx_read(chip, REG_GLOBAL, GLOBAL_ATU_CONTROL, &val);
> + if (err)
> + return err;
> +
> + /* AgeTime is 11:4 bits */
> + val &= ~0xff0;
> + val |= age_time << 4;
> +
> + return mv88e6xxx_write(chip, REG_GLOBAL, GLOBAL_ATU_CONTROL, val);
> +}
Hi Vivien
This is doing a read/modify/write, so should really hold the mutex.
> + err = mv88e6xxx_g1_set_age_time(chip, 300000);
Maybe use (5 * 60 * 1000) to make it more readable?
Andrew
next prev parent reply other threads:[~2016-07-19 14:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 0:45 [PATCH net-next v3 00/12] net: dsa: mv88e6xxx: Global2 cleanup and STP Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 01/12] net: dsa: mv88e6xxx: remove basic function flags Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 02/12] net: dsa: mv88e6xxx: split setup of Global 1 and 2 Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 03/12] net: dsa: mv88e6xxx: extract device mapping Vivien Didelot
2016-07-19 2:48 ` Andrew Lunn
2016-07-19 0:45 ` [PATCH net-next v3 04/12] net: dsa: mv88e6xxx: extract trunk mapping Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 05/12] net: dsa: mv88e6xxx: add cap for MGMT Enables bits Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 06/12] net: dsa: mv88e6xxx: rework Switch MAC setter Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 07/12] net: dsa: mv88e6xxx: add cap for PVT Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 08/12] net: dsa: mv88e6xxx: add cap for Priority Override Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 09/12] net: dsa: mv88e6xxx: add cap for IRL Vivien Didelot
2016-07-19 0:45 ` [PATCH net-next v3 10/12] net: dsa: support switchdev ageing time attr Vivien Didelot
2016-07-19 3:24 ` Andrew Lunn
2016-07-19 4:26 ` Florian Fainelli
2016-07-19 14:20 ` Andrew Lunn
2016-07-19 17:24 ` Florian Fainelli
2016-07-19 18:50 ` Andrew Lunn
2016-07-19 0:45 ` [PATCH net-next v3 11/12] net: dsa: mv88e6xxx: add G1 helper for ageing time Vivien Didelot
2016-07-19 14:45 ` Andrew Lunn [this message]
2016-07-19 14:47 ` Andrew Lunn
2016-07-19 18:58 ` Andrew Lunn
2016-07-19 0:45 ` [PATCH net-next v3 12/12] net: dsa: mv88e6xxx: add support for DSA " Vivien Didelot
2016-07-19 18:50 ` Andrew Lunn
2016-07-20 2:42 ` [PATCH net-next v3 00/12] net: dsa: mv88e6xxx: Global2 cleanup and STP David Miller
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=20160719144518.GC31103@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.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.