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

Commit 9d490b4e authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller
Browse files

net: dsa: rename switch operations structure



Now that the dsa_switch_driver structure contains only function pointers
as it is supposed to, rename it to the more appropriate dsa_switch_ops,
uniformly to any other operations structure in the kernel.

No functional changes here, basically just the result of something like:
s/dsa_switch_driver *drv/dsa_switch_ops *ops/g

However keep the {un,}register_switch_driver functions and their
dsa_switch_drivers list as is, since they represent the -- likely to be
deprecated soon -- legacy DSA registration framework.

In the meantime, also fix the following checks from checkpatch.pl to
make it happy with this patch:

    CHECK: Comparison to NULL could be written "!ops"
    #403: FILE: net/dsa/dsa.c:470:
    +	if (ops == NULL) {

    CHECK: Comparison to NULL could be written "ds->ops->get_strings"
    #773: FILE: net/dsa/slave.c:697:
    +		if (ds->ops->get_strings != NULL)

    CHECK: Comparison to NULL could be written "ds->ops->get_ethtool_stats"
    #824: FILE: net/dsa/slave.c:785:
    +	if (ds->ops->get_ethtool_stats != NULL)

    CHECK: Comparison to NULL could be written "ds->ops->get_sset_count"
    #835: FILE: net/dsa/slave.c:798:
    +		if (ds->ops->get_sset_count != NULL)

    total: 0 errors, 0 warnings, 4 checks, 784 lines checked

Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c7b7b483
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -227,9 +227,9 @@ to address individual switches in the tree.

dsa_switch: structure describing a switch device in the tree, referencing a
dsa_switch_tree as a backpointer, slave network devices, master network device,
and a reference to the backing dsa_switch_driver
and a reference to the backing dsa_switch_ops

dsa_switch_driver: structure referencing function pointers, see below for a full
dsa_switch_ops: structure referencing function pointers, see below for a full
description.

Design limitations
@@ -357,10 +357,10 @@ regular HWMON devices in /sys/class/hwmon/.
Driver development
==================

DSA switch drivers need to implement a dsa_switch_driver structure which will
DSA switch drivers need to implement a dsa_switch_ops structure which will
contain the various members described below.

register_switch_driver() registers this dsa_switch_driver in its internal list
register_switch_driver() registers this dsa_switch_ops in its internal list
of drivers to probe for. unregister_switch_driver() does the exact opposite.

Unless requested differently by setting the priv_size member accordingly, DSA
@@ -379,7 +379,7 @@ Switch configuration
  buses, return a non-NULL string

- setup: setup function for the switch, this function is responsible for setting
  up the dsa_switch_driver private structure with all it needs: register maps,
  up the dsa_switch_ops private structure with all it needs: register maps,
  interrupts, mutexes, locks etc.. This function is also expected to properly
  configure the switch to separate all network interfaces from each other, that
  is, they should be isolated by the switch hardware itself, typically by creating
+2 −2
Original line number Diff line number Diff line
@@ -1378,7 +1378,7 @@ static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
	return DSA_TAG_PROTO_NONE;
}

static struct dsa_switch_driver b53_switch_ops = {
static struct dsa_switch_ops b53_switch_ops = {
	.get_tag_protocol	= b53_get_tag_protocol,
	.setup			= b53_setup,
	.set_addr		= b53_set_addr,
@@ -1618,7 +1618,7 @@ static int b53_switch_init(struct b53_device *dev)
			dev->vta_regs[1] = chip->vta_regs[1];
			dev->vta_regs[2] = chip->vta_regs[2];
			dev->jumbo_pm_reg = chip->jumbo_pm_reg;
			ds->drv = &b53_switch_ops;
			ds->ops = &b53_switch_ops;
			dev->cpu_port = chip->cpu_port;
			dev->num_vlans = chip->vlans;
			dev->num_arl_entries = chip->arl_entries;
+2 −2
Original line number Diff line number Diff line
@@ -1581,7 +1581,7 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
	return 0;
}

static struct dsa_switch_driver bcm_sf2_switch_driver = {
static struct dsa_switch_ops bcm_sf2_switch_ops = {
	.setup			= bcm_sf2_sw_setup,
	.get_tag_protocol	= bcm_sf2_sw_get_tag_protocol,
	.set_addr		= bcm_sf2_sw_set_addr,
@@ -1632,7 +1632,7 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
	priv = (struct bcm_sf2_priv *)(ds + 1);
	ds->priv = priv;
	ds->dev = &pdev->dev;
	ds->drv = &bcm_sf2_switch_driver;
	ds->ops = &bcm_sf2_switch_ops;

	dev_set_drvdata(&pdev->dev, ds);

+3 −3
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@ mv88e6060_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
	return reg_write(ds, addr, regnum, val);
}

static struct dsa_switch_driver mv88e6060_switch_driver = {
static struct dsa_switch_ops mv88e6060_switch_ops = {
	.get_tag_protocol = mv88e6060_get_tag_protocol,
	.probe		= mv88e6060_drv_probe,
	.setup		= mv88e6060_setup,
@@ -263,14 +263,14 @@ static struct dsa_switch_driver mv88e6060_switch_driver = {

static int __init mv88e6060_init(void)
{
	register_switch_driver(&mv88e6060_switch_driver);
	register_switch_driver(&mv88e6060_switch_ops);
	return 0;
}
module_init(mv88e6060_init);

static void __exit mv88e6060_cleanup(void)
{
	unregister_switch_driver(&mv88e6060_switch_driver);
	unregister_switch_driver(&mv88e6060_switch_ops);
}
module_exit(mv88e6060_cleanup);

+4 −4
Original line number Diff line number Diff line
@@ -3976,7 +3976,7 @@ static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
	return NULL;
}

static struct dsa_switch_driver mv88e6xxx_switch_driver = {
static struct dsa_switch_ops mv88e6xxx_switch_ops = {
	.probe			= mv88e6xxx_drv_probe,
	.get_tag_protocol	= mv88e6xxx_get_tag_protocol,
	.setup			= mv88e6xxx_setup,
@@ -4025,7 +4025,7 @@ static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip,

	ds->dev = dev;
	ds->priv = chip;
	ds->drv = &mv88e6xxx_switch_driver;
	ds->ops = &mv88e6xxx_switch_ops;

	dev_set_drvdata(dev, ds);

@@ -4118,7 +4118,7 @@ static struct mdio_driver mv88e6xxx_driver = {

static int __init mv88e6xxx_init(void)
{
	register_switch_driver(&mv88e6xxx_switch_driver);
	register_switch_driver(&mv88e6xxx_switch_ops);
	return mdio_driver_register(&mv88e6xxx_driver);
}
module_init(mv88e6xxx_init);
@@ -4126,7 +4126,7 @@ module_init(mv88e6xxx_init);
static void __exit mv88e6xxx_cleanup(void)
{
	mdio_driver_unregister(&mv88e6xxx_driver);
	unregister_switch_driver(&mv88e6xxx_switch_driver);
	unregister_switch_driver(&mv88e6xxx_switch_ops);
}
module_exit(mv88e6xxx_cleanup);

Loading