Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7543a6d5 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

net: dsa: Have the switch driver allocate there own private memory



Now the switch devices have a dev pointer, make use of it for allocating
the drivers private data structures using a devm_kzalloc().

Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Tested-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bbb8d793
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -136,8 +136,15 @@ static int bcm_sf2_sw_get_sset_count(struct dsa_switch *ds)
}

static char *bcm_sf2_sw_probe(struct device *dsa_dev, struct device *host_dev,
			      int sw_addr)
			      int sw_addr, void **_priv)
{
	struct bcm_sf2_priv *priv;

	priv = devm_kzalloc(dsa_dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return NULL;
	*_priv = priv;

	return "Broadcom Starfighter 2";
}

@@ -1363,7 +1370,6 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,

static struct dsa_switch_driver bcm_sf2_switch_driver = {
	.tag_protocol		= DSA_TAG_PROTO_BRCM,
	.priv_size		= sizeof(struct bcm_sf2_priv),
	.probe			= bcm_sf2_sw_probe,
	.setup			= bcm_sf2_sw_setup,
	.set_addr		= bcm_sf2_sw_set_addr,
+2 −1
Original line number Diff line number Diff line
@@ -58,11 +58,12 @@ static int reg_write(struct dsa_switch *ds, int addr, int reg, u16 val)
	})

static char *mv88e6060_probe(struct device *dsa_dev, struct device *host_dev,
			     int sw_addr)
			     int sw_addr, void **priv)
{
	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
	int ret;

	*priv = NULL;
	if (bus == NULL)
		return NULL;

+14 −3
Original line number Diff line number Diff line
@@ -30,10 +30,20 @@ static const struct mv88e6xxx_switch_id mv88e6123_table[] = {
};

static char *mv88e6123_probe(struct device *dsa_dev, struct device *host_dev,
			     int sw_addr)
			     int sw_addr, void **priv)
{
	return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6123_table,
	struct mv88e6xxx_priv_state *ps;
	char *name;

	name = mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6123_table,
				     ARRAY_SIZE(mv88e6123_table));
	if (name) {
		ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
		if (!ps)
			return NULL;
		*priv = ps;
	}
	return name;
}

static int mv88e6123_setup_global(struct dsa_switch *ds)
@@ -74,6 +84,8 @@ static int mv88e6123_setup(struct dsa_switch *ds)
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;

	ps->ds = ds;

	ret = mv88e6xxx_setup_common(ds);
	if (ret < 0)
		return ret;
@@ -103,7 +115,6 @@ static int mv88e6123_setup(struct dsa_switch *ds)

struct dsa_switch_driver mv88e6123_switch_driver = {
	.tag_protocol		= DSA_TAG_PROTO_EDSA,
	.priv_size		= sizeof(struct mv88e6xxx_priv_state),
	.probe			= mv88e6123_probe,
	.setup			= mv88e6123_setup,
	.set_addr		= mv88e6xxx_set_addr_indirect,
+14 −3
Original line number Diff line number Diff line
@@ -26,10 +26,20 @@ static const struct mv88e6xxx_switch_id mv88e6131_table[] = {
};

static char *mv88e6131_probe(struct device *dsa_dev, struct device *host_dev,
			     int sw_addr)
			     int sw_addr, void **priv)
{
	return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6131_table,
	struct mv88e6xxx_priv_state *ps;
	char *name;

	name = mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6131_table,
				     ARRAY_SIZE(mv88e6131_table));
	if (name) {
		ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
		if (!ps)
			return NULL;
		*priv = ps;
	}
	return name;
}

static int mv88e6131_setup_global(struct dsa_switch *ds)
@@ -92,6 +102,8 @@ static int mv88e6131_setup(struct dsa_switch *ds)
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;

	ps->ds = ds;

	ret = mv88e6xxx_setup_common(ds);
	if (ret < 0)
		return ret;
@@ -160,7 +172,6 @@ mv88e6131_phy_write(struct dsa_switch *ds,

struct dsa_switch_driver mv88e6131_switch_driver = {
	.tag_protocol		= DSA_TAG_PROTO_DSA,
	.priv_size		= sizeof(struct mv88e6xxx_priv_state),
	.probe			= mv88e6131_probe,
	.setup			= mv88e6131_setup,
	.set_addr		= mv88e6xxx_set_addr_direct,
+14 −3
Original line number Diff line number Diff line
@@ -25,10 +25,20 @@ static const struct mv88e6xxx_switch_id mv88e6171_table[] = {
};

static char *mv88e6171_probe(struct device *dsa_dev, struct device *host_dev,
			     int sw_addr)
			     int sw_addr, void **priv)
{
	return mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table,
	struct mv88e6xxx_priv_state *ps;
	char *name;

	name = mv88e6xxx_lookup_name(host_dev, sw_addr, mv88e6171_table,
				     ARRAY_SIZE(mv88e6171_table));
		if (name) {
		ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
		if (!ps)
			return NULL;
		*priv = ps;
	}
	return name;
}

static int mv88e6171_setup_global(struct dsa_switch *ds)
@@ -70,6 +80,8 @@ static int mv88e6171_setup(struct dsa_switch *ds)
	struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
	int ret;

	ps->ds = ds;

	ret = mv88e6xxx_setup_common(ds);
	if (ret < 0)
		return ret;
@@ -89,7 +101,6 @@ static int mv88e6171_setup(struct dsa_switch *ds)

struct dsa_switch_driver mv88e6171_switch_driver = {
	.tag_protocol		= DSA_TAG_PROTO_EDSA,
	.priv_size		= sizeof(struct mv88e6xxx_priv_state),
	.probe			= mv88e6171_probe,
	.setup			= mv88e6171_setup,
	.set_addr		= mv88e6xxx_set_addr_indirect,
Loading