Thread (36 messages) 36 messages, 4 authors, 2023-04-03

Re: [PATCH 6/7] dsa: marvell: Correct value of max_frame_size variable after validation

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2023-03-10 15:38:55
Also in: lkml

On Fri, Mar 10, 2023 at 12:06:15PM +0000, Russell King (Oracle) wrote:
It may be worth doing:

static int mv88e6xxx_g1_modify(struct mv88e6xxx_chip *chip, int reg,
			       u16 mask, u16 val)
{
	int addr = chip->info->global1_addr;
	int err;
	u16 v;

	err = mv88e6xxx_read(chip, addr, reg, &v);
	if (err < 0)
		return err;

	v = (v & ~mask) | val;

	return mv88e6xxx_write(chip, addr, reg, v);
}

Then, mv88e6185_g1_set_max_frame_size() becomes:

int mv88e6185_g1_set_max_frame_size(struct mv88e6xxx_chip *chip, int mtu)
{
	u16 val = 0;

	if (mtu + ETH_HLEN + ETH_FCS_LEN > 1518)
		val = MV88E6185_G1_CTL1_MAX_FRAME_1632;

	return mv88e6xxx_g1_modify(chip, MV88E6XXX_G1_CTL1,
				   MV88E6185_G1_CTL1_MAX_FRAME_1632, val);
}

The 6250 variant becomes similar.
+1, sounds good to have separate mv88e6185_g1_set_max_frame_size() and
mv88e6250_g1_set_max_frame_size() with a common implementation. It is a
lot less confusing than the two driving a bit named in the same way but
meaning different things.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help