@@ -262,27 +262,16 @@ static void sec_pmic_configure(struct sec_pmic_dev *sec_pmic)
* Only the common platform data elements for s5m8767 are parsed here from the
* device tree. Other sub-modules of s5m8767 such as pmic, rtc , charger and
* others have to parse their own platform data elements from device tree.
- *
- * The s5m8767 platform data structure is instantiated here and the drivers for
- * the sub-modules need not instantiate another instance while parsing their
- * platform data.
*/
-static struct sec_platform_data *
-sec_pmic_i2c_parse_dt_pdata(struct device *dev)
+static void sec_pmic_i2c_parse_dt_pdata(struct device *dev,
+ struct sec_platform_data *pd)
{
- struct sec_platform_data *pd;
-
- pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
- if (!pd)
- return ERR_PTR(-ENOMEM);
-
pd->manual_poweroff =
of_property_read_bool(dev->of_node,
"samsung,s2mps11-acokb-ground");
pd->disable_wrstbi =
of_property_read_bool(dev->of_node,
"samsung,s2mps11-wrstbi-ground");
- return pd;
}
static int sec_pmic_probe(struct i2c_client *i2c)
@@ -303,11 +292,16 @@ static int sec_pmic_probe(struct i2c_client *i2c)
sec_pmic->i2c = i2c;
sec_pmic->irq = i2c->irq;
- pdata = sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev);
- if (IS_ERR(pdata)) {
- ret = PTR_ERR(pdata);
- return ret;
- }
+ /*
+ * The s5m8767 platform data structure is instantiated here and the
+ * drivers for the sub-modules need not instantiate another instance
+ * while parsing their platform data.
+ */
+ pdata = devm_kzalloc(sec_pmic->dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return -ENOMEM;
+
+ sec_pmic_i2c_parse_dt_pdata(sec_pmic->dev, pdata);
sec_pmic->device_type = (unsigned long)of_device_get_match_data(sec_pmic->dev);
sec_pmic->pdata = pdata;
As a preparation for adding support for Samsung's S2MPG10, which is connected via SPEEDY / ACPM rather than I2C, we're going to split out (move) all I2C-specific driver code into its own kernel module, and create a (common) core transport-agnostic kernel module. Transport drivers will have to do device tree parsing, and the core driver will allocate its own additional memory as needed. In preparation for that change, separate out runtime platform data allocation from device tree parsing. Having this change will create less churn in the upcoming split of the transport-specific parts. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/mfd/sec-core.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)