pnp: Provide alternative pnp_enable() implementation
The current default implementation of pnp_enable() only disables devices - if set so in the devicetree - but does not enable them. Enablement takes place in pnp_enable_resources(). Yet, many PnP chips implement their own version of pnp_enable() which also enables devices if set in the devicetree. It's arguable, if enabling those devices makes sense, before they get resources assigned. Maybe we can't write the resource registers if not, who knows? The least we can do is providing a common implementation for this behavior, and get rid of some code duplication. Used the following cocci: @@ expression e; @@ +pnp_alt_enable(e); -pnp_set_logical_device(e); ( -pnp_set_enable(e, !!e->enabled); | -(e->enabled) ? pnp_set_enable(e, 1) : pnp_set_enable(e, 0); | -if (e->enabled) { pnp_set_enable(e, 1); } -else { pnp_set_enable(e, 0); } ) Change-Id: I8d695e8fcd3cf8b847b1aa99326b51a554700bc4 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: http://review.coreboot.org/3480 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
a00f9830fb
commit
f898f7ba4d
|
@ -155,6 +155,12 @@ void pnp_enable(device_t dev)
|
|||
}
|
||||
}
|
||||
|
||||
void pnp_alt_enable(device_t dev)
|
||||
{
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
}
|
||||
|
||||
struct device_operations pnp_ops = {
|
||||
.read_resources = pnp_read_resources,
|
||||
.set_resources = pnp_set_resources,
|
||||
|
|
|
@ -21,6 +21,7 @@ void pnp_read_resources(device_t dev);
|
|||
void pnp_set_resources(device_t dev);
|
||||
void pnp_enable_resources(device_t dev);
|
||||
void pnp_enable(device_t dev);
|
||||
void pnp_alt_enable(device_t dev);
|
||||
|
||||
extern struct device_operations pnp_ops;
|
||||
|
||||
|
|
|
@ -62,8 +62,7 @@ static void f71805f_pnp_enable_resources(device_t dev)
|
|||
static void f71805f_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,7 @@ static void f71859_pnp_enable_resources(device_t dev)
|
|||
static void f71859_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,7 @@ static void f71863fg_pnp_enable_resources(device_t dev)
|
|||
static void f71863fg_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ static void f71872_pnp_enable_resources(device_t dev)
|
|||
static void f71872_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ static void f71889_pnp_enable_resources(device_t dev)
|
|||
static void f71889_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ static void f81865f_pnp_enable_resources(device_t dev)
|
|||
static void f81865f_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
(dev->enabled) ? pnp_set_enable(dev, 1) : pnp_set_enable(dev, 0);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ static void i3100_pnp_enable_resources(device_t dev)
|
|||
static void i3100_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,7 @@ static void it8712f_pnp_enable_resources(device_t dev)
|
|||
static void it8712f_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ static void it8716f_pnp_enable_resources(device_t dev)
|
|||
static void it8716f_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -205,8 +205,7 @@ static void it8772f_pnp_enable_resources(device_t dev)
|
|||
static void it8772f_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,7 @@ static void nct5104d_pnp_enable_resources(device_t dev)
|
|||
static void nct5104d_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_exteded_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
(dev->enabled) ? pnp_set_enable(dev,1) : pnp_set_enable(dev,0);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_extended_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,14 +80,7 @@ static void kbc1100_pnp_enable_resources(device_t dev)
|
|||
static void kbc1100_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
|
||||
if(dev->enabled) {
|
||||
pnp_set_enable(dev, 1);
|
||||
}
|
||||
else {
|
||||
pnp_set_enable(dev, 0);
|
||||
}
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,8 +103,7 @@ static void lpc47b272_pnp_enable_resources(device_t dev)
|
|||
static void lpc47b272_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -105,8 +105,7 @@ static void lpc47b397_pnp_enable_resources(device_t dev)
|
|||
static void lpc47b397_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,7 @@ static void lpc47m10x_pnp_enable_resources(device_t dev)
|
|||
static void lpc47m10x_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ static void lpc47m15x_pnp_enable_resources(device_t dev)
|
|||
static void lpc47m15x_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,14 +60,7 @@ static void mec1308_pnp_enable_resources(device_t dev)
|
|||
static void mec1308_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
|
||||
if(dev->enabled) {
|
||||
pnp_set_enable(dev, 1);
|
||||
}
|
||||
else {
|
||||
pnp_set_enable(dev, 0);
|
||||
}
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,14 +81,7 @@ static void sch4037_pnp_enable_resources(device_t dev)
|
|||
static void sch4037_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
|
||||
if(dev->enabled) {
|
||||
pnp_set_enable(dev, 1);
|
||||
}
|
||||
else {
|
||||
pnp_set_enable(dev, 0);
|
||||
}
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,14 +80,7 @@ static void sio1036_pnp_enable_resources(device_t dev)
|
|||
static void sio1036_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
|
||||
if(dev->enabled) {
|
||||
pnp_set_enable(dev, 1);
|
||||
}
|
||||
else {
|
||||
pnp_set_enable(dev, 0);
|
||||
}
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -194,8 +194,7 @@ static void smsc_pnp_enable_resources(device_t dev)
|
|||
static void smsc_pnp_enable(device_t dev)
|
||||
{
|
||||
smsc_pnp_enter_conf_state(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
smsc_pnp_exit_conf_state(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,8 +177,7 @@ static void vt1211_pnp_set_resources(struct device *dev)
|
|||
static void vt1211_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,7 @@ static void w83627dhg_pnp_enable_resources(device_t dev)
|
|||
static void w83627dhg_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -152,8 +152,7 @@ static void w83627ehg_pnp_enable_resources(device_t dev)
|
|||
static void w83627ehg_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,8 +157,7 @@ static void w83627hf_pnp_enable_resources(device_t dev)
|
|||
static void w83627hf_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,8 +91,7 @@ static void w83697hf_pnp_set_resources(device_t dev)
|
|||
static void w83697hf_pnp_enable(device_t dev)
|
||||
{
|
||||
pnp_enter_ext_func_mode(dev);
|
||||
pnp_set_logical_device(dev);
|
||||
pnp_set_enable(dev, !!dev->enabled);
|
||||
pnp_alt_enable(dev);
|
||||
pnp_exit_ext_func_mode(dev);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue