// spatch -D report --very-quiet --sp-file phylink-link.cocci \
//    drivers/net/ethernet net/dsa

virtual report

@ ops @
identifier I, func;
@@
(
  struct phylink_mac_ops I = { 
  	.mac_config = func,
  };
|
  struct dsa_switch_ops I = {
  	.phylink_mac_config = func,
  };
)

@ mac_config_link @
identifier ops.func, S;
position p;
@@
  func(..., const struct phylink_link_state *S)
  {
  ... when exists
    S->link @p
  ... when exists
  }

@ mac_config_spd_dpx @
identifier ops.func, S;
identifier member =~ "^(speed|duplex)$";
position p;
@@
  func(..., const struct phylink_link_state *S)
  {
  ... when exists
    S->member @p
  ... when exists
  }

@ mac_config_pause @
identifier ops.func, S;
identifier mask =~ "^MLO_PAUSE_(TX|RX|TXRX_MASK)$";
position p;
@@
  func(..., const struct phylink_link_state *S)
  {
  ... when exists
    S->pause & mask @p
  ... when exists
  }


@ script:python depends on report @
func << ops.func;
pos << mac_config_spd_dpx.p;
var << mac_config_spd_dpx.S;
memb << mac_config_spd_dpx.member;
@@
coccilib.report.print_report(pos[0],
	"WARNING: use of %s->%s in %s is deprecated" % (var, memb, func))

@ script:python depends on report @
func << ops.func;
pos << mac_config_pause.p;
var << mac_config_pause.S;
mask << mac_config_pause.mask;
@@
coccilib.report.print_report(pos[0],
	"WARNING: use of %s->pause %s flag in %s is deprecated" % (var, mask, func))

@ script:python depends on report @
func << ops.func;
pos << mac_config_link.p;
var << mac_config_link.S;
@@
coccilib.report.print_report(pos[0],
	"ERROR: use of %s->link in %s is unreliable and should never be used" % (var, func))