pnp: Add some default functions to enter/exit config state
commit1c81128dcd3a723f75d554b0a8d87101d7dd3663
authorNico Huber <nico.h@gmx.de>
Sat, 15 Jun 2013 18:33:44 +0000 (15 20:33 +0200)
committerNico Huber <nico.huber@secunet.com>
Wed, 3 Jul 2013 14:13:11 +0000 (3 16:13 +0200)
tree09a664dc1a18439e57480ef61adc6044a205c3e8
parentabe6847cd21b553dd66fcb0540de166f82ebaf00
pnp: Add some default functions to enter/exit config state

Implement some common default functions to enter and exit the
configuration state. Also provide default pnp_mode_ops for common
enter()/exit() function pairs.

The following cocci ensures their use:
    @ mode_match @
    identifier enter, exit, ops;
    @@
     struct pnp_mode_ops ops = {
             .enter_conf_mode  = enter,
             .exit_conf_mode   = exit,
     };

    @ enter_match_8787 @
    identifier mode_match.enter, dev;
    @@
     enter(...)
     {
             outb(0x87, dev->path.pnp.port);
             outb(0x87, dev->path.pnp.port);
     }

    @ depends on enter_match_8787 @
    identifier mode_match.enter, mode_match.ops;
    @@
     struct pnp_mode_ops ops = {
    -        .enter_conf_mode  = enter,
    +        .enter_conf_mode  = pnp_enter_conf_mode_8787,
     };

    @ enter_match_55 @
    identifier mode_match.enter, dev;
    @@
     enter(...)
     {
             outb(0x55, dev->path.pnp.port);
     }

    @ depends on enter_match_55 @
    identifier mode_match.enter, mode_match.ops;
    @@
     struct pnp_mode_ops ops = {
    -        .enter_conf_mode  = enter,
    +        .enter_conf_mode  = pnp_enter_conf_mode_55,
     };

    @ depends on enter_match_8787 || enter_match_55 @
    identifier mode_match.enter;
    @@
    -enter(...) {...}

    @ exit_match_aa @
    identifier mode_match.exit, dev;
    @@
     exit(...)
     {
             outb(0xaa, dev->path.pnp.port);
     }

    @ depends on exit_match_aa @
    identifier mode_match.exit, mode_match.ops;
    @@
     struct pnp_mode_ops ops = {
    -        .exit_conf_mode   = exit,
    +        .exit_conf_mode   = pnp_exit_conf_mode_aa,
     };

    @ depends on exit_match_aa @
    identifier mode_match.exit;
    @@
    -exit(...) {...}

    @ depends on enter_match_8787 || enter_match_55 || exit_match_aa @
    @@
     #include <device/pnp.h>
    +#include <superio/conf_mode.h>

    @ mode_match_55_aa @
    identifier ops;
    @@
     struct pnp_mode_ops ops = {
             .enter_conf_mode  = pnp_enter_conf_mode_55,
             .exit_conf_mode   = pnp_exit_conf_mode_aa,
     };

    @@
    identifier mode_match_55_aa.ops;
    @@
    -struct pnp_mode_ops ops = {...};

    @@
    identifier mode_match_55_aa.ops, devops;
    @@
     struct device_operations devops = {
    -        .ops_pnp_mode     = &ops,
    +        .ops_pnp_mode     = &pnp_conf_mode_55_aa,
     };

    @ mode_match_8787_aa @
    identifier ops;
    @@
     struct pnp_mode_ops ops = {
             .enter_conf_mode  = pnp_enter_conf_mode_8787,
             .exit_conf_mode   = pnp_exit_conf_mode_aa,
     };

    @@
    identifier mode_match_8787_aa.ops;
    @@
    -struct pnp_mode_ops ops = {...};

    @@
    identifier mode_match_8787_aa.ops, devops;
    @@
     struct device_operations devops = {
    -        .ops_pnp_mode     = &ops,
    +        .ops_pnp_mode     = &pnp_conf_mode_8787_aa,
     };

Change-Id: I1480336b54523cc95210d99cf31c1a0b3a14b464
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: http://review.coreboot.org/3484
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
28 files changed:
src/include/superio/conf_mode.h [new file with mode: 0644]
src/superio/Makefile.inc
src/superio/common/conf_mode.c [new file with mode: 0644]
src/superio/fintek/f71805f/superio.c
src/superio/fintek/f71859/superio.c
src/superio/fintek/f71863fg/superio.c
src/superio/fintek/f71872/superio.c
src/superio/fintek/f71889/superio.c
src/superio/fintek/f81865f/superio.c
src/superio/nuvoton/nct5104d/superio.c
src/superio/smsc/kbc1100/superio.c
src/superio/smsc/lpc47b272/superio.c
src/superio/smsc/lpc47b397/superio.c
src/superio/smsc/lpc47m10x/superio.c
src/superio/smsc/lpc47m15x/superio.c
src/superio/smsc/mec1308/superio.c
src/superio/smsc/sch4037/superio.c
src/superio/smsc/sio1036/superio.c
src/superio/smsc/smscsuperio/superio.c
src/superio/via/vt1211/vt1211.c
src/superio/winbond/w83627dhg/superio.c
src/superio/winbond/w83627ehg/superio.c
src/superio/winbond/w83627hf/superio.c
src/superio/winbond/w83627thg/superio.c
src/superio/winbond/w83627uhg/superio.c
src/superio/winbond/w83697hf/superio.c
src/superio/winbond/w83977f/superio.c
src/superio/winbond/w83977tf/superio.c