Furquan Shaikh (furquan@google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17857
-gerrit
commit 407b6d1640f2f0dce3575375f6a41c59b0380179 Author: Furquan Shaikh furquan@chromium.org Date: Tue Dec 13 21:50:32 2016 -0800
drivers/i2c: Pass in i2c_generic_config into i2c_generic_fill_ssdt
Remove any assumptions required for the drivers using i2c_generic to have drivers_i2c_generic_config structure at the start of the driver config. Instead prepare a structure i2c_generic_fill_options with pointers to device, drivers_i2c_generic_config and callback (if any required) by the calling device.
Change-Id: I51dc4cad1c1f246b51891abf7115a7120e87b098 Signed-off-by: Furquan Shaikh furquan@chromium.org --- src/drivers/i2c/alps/alps.c | 7 +++++++ src/drivers/i2c/generic/chip.h | 13 +++++++------ src/drivers/i2c/generic/generic.c | 16 ++++++++++------ src/drivers/i2c/wacom/wacom.c | 8 +++++++- 4 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/src/drivers/i2c/alps/alps.c b/src/drivers/i2c/alps/alps.c index 2686f6c..945fc7e 100644 --- a/src/drivers/i2c/alps/alps.c +++ b/src/drivers/i2c/alps/alps.c @@ -30,6 +30,13 @@ static void i2c_alps_fill_dsm(struct device *dev)
static void i2c_alps_fill_ssdt_generator(struct device *dev) { + struct drivers_i2c_alps_config *config = dev->chip_info; + const struct i2c_generic_fill_options opt = { + .dev = dev, + .config = &config->generic, + .callback = i2c_alps_fill_dsm, + }; + i2c_generic_fill_ssdt(dev, &i2c_alps_fill_dsm); }
diff --git a/src/drivers/i2c/generic/chip.h b/src/drivers/i2c/generic/chip.h index 736de51..e438c5c 100644 --- a/src/drivers/i2c/generic/chip.h +++ b/src/drivers/i2c/generic/chip.h @@ -52,16 +52,17 @@ struct drivers_i2c_generic_config { unsigned enable_delay_ms; };
+struct i2c_generic_fill_options { + struct device *dev; + struct drivers_i2c_generic_config *config; + void (*callback)(struct device *dev); +}; + /* * Fills in generic information about i2c device from device-tree * properties. Callback can be provided to fill in any * device-specific information in SSDT. - * - * Drivers calling into this function to generate should place - * drivers_i2c_generic_config structure at the beginning of their device config - * structure. */ -void i2c_generic_fill_ssdt(struct device *dev, - void (*callback)(struct device *dev)); +void i2c_generic_fill_ssdt(const struct i2c_generic_fill_options *opt);
#endif /* __I2C_GENERIC_CHIP_H__ */ diff --git a/src/drivers/i2c/generic/generic.c b/src/drivers/i2c/generic/generic.c index b8e5d86..9211ab0 100644 --- a/src/drivers/i2c/generic/generic.c +++ b/src/drivers/i2c/generic/generic.c @@ -65,10 +65,10 @@ static void i2c_generic_add_power_res(struct drivers_i2c_generic_config *config) acpigen_pop_len(); /* PowerResource PRIC */ }
-void i2c_generic_fill_ssdt(struct device *dev, - void (*callback)(struct device *dev)) +void i2c_generic_fill_ssdt(const struct i2c_generic_fill_options *opt) { - struct drivers_i2c_generic_config *config = dev->chip_info; + struct drivers_i2c_generic_config *config = opt->config; + struct device *dev = opt->dev; const char *scope = acpi_device_scope(dev); struct acpi_i2c i2c = { .address = dev->path.i2c.device, @@ -119,8 +119,8 @@ void i2c_generic_fill_ssdt(struct device *dev, i2c_generic_add_power_res(config);
/* Callback if any. */ - if (callback) - callback(dev); + if (opt->callback) + opt->callback(dev);
acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ @@ -131,7 +131,11 @@ void i2c_generic_fill_ssdt(struct device *dev,
static void i2c_generic_fill_ssdt_generator(struct device *dev) { - i2c_generic_fill_ssdt(dev, NULL); + const struct i2c_generic_fill_options opt = { + .dev = dev, + .config = dev->chip_info, + }; + i2c_generic_fill_ssdt(&opt); }
/* Use name specified in config or build one from I2C address */ diff --git a/src/drivers/i2c/wacom/wacom.c b/src/drivers/i2c/wacom/wacom.c index c54194f..5703244 100644 --- a/src/drivers/i2c/wacom/wacom.c +++ b/src/drivers/i2c/wacom/wacom.c @@ -30,7 +30,13 @@ static void i2c_wacom_fill_dsm(struct device *dev)
static void i2c_wacom_fill_ssdt_generator(struct device *dev) { - i2c_generic_fill_ssdt(dev, &i2c_wacom_fill_dsm); + struct drivers_i2c_wacom_config *config = dev->chip_info; + const struct i2c_generic_fill_options opt = { + .dev = dev, + .config = &config->generic, + .callback = i2c_wacom_fill_dsm, + }; + i2c_generic_fill_ssdt(&opt); }
static const char *i2c_wacom_acpi_name(struct device *dev)