Thread (2 messages) 2 messages, 2 authors, 2017-12-06

Re: [PATCH v3 net-next] net: dsa: Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers

flat view

From: Andrew Lunn <andrew@lunn.ch>
Date: 2017-12-06 23:23:09

On Tue, Dec 05, 2017 at 05:47:14PM -0800, Tristram.Ha@microchip.com wrote:
quoted hunk ↗ jump to hunk
+static int ksz9477_get_tag(u8 *tag, int *port)
+{
+	*port = tag[0] & 7;
+	return KSZ_EGRESS_TAG_LEN;
+}
+
+static void ksz9477_set_tag(void *ptr, u8 *addr, int p)
+{
+	u16 *tag = (u16 *)ptr;
+
+	*tag = 1 << p;
+	*tag = cpu_to_be16(*tag);
+}
Hi Tristram

It would be more normal to create an ops structure

struct ksz_tag_ops {
       int (*get_tag)(u8 *tag, int *port);
       void (*set_tag)(void *ptr, u8 *addr, int p)
};

static const struct ksz_tag_ops ksz9477_tag_ops = {
       .get_tag = ksz9477_get_tag,
       .set_tag = ksz9477_set_tag,
}

and then pass this to the functions.

It might even be possible to make this more generic, use it for other
tag drivers.

    Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help