Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 925bb9c6 authored by Grant Likely's avatar Grant Likely Committed by Jean Delvare
Browse files

of/i2c: Fix module load order issue caused by of_i2c.c



Commit 959e85f7, "i2c: add OF-style registration and binding" caused a
module dependency loop where of_i2c.c calls functions in i2c-core, and
i2c-core calls of_i2c_register_devices() in of_i2c.  This means that
when i2c support is built as a module when CONFIG_OF is set, then
neither i2c_core nor of_i2c are able to be loaded.

This patch fixes the problem by moving the of_i2c_register_devices()
calls back into the device drivers.  Device drivers already
specifically request the core code to parse the device tree for
devices anyway by setting the of_node pointer, so it isn't a big
deal to also call the registration function.  The drivers just become
slightly more verbose.

Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent 64b4782f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -677,6 +677,11 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev,
	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
		cpm->adap.name);

	/*
	 * register OF I2C devices
	 */
	of_i2c_register_devices(&cpm->adap);

	return 0;
out_shut:
	cpm_i2c_shutdown(cpm);
+3 −0
Original line number Diff line number Diff line
@@ -761,6 +761,9 @@ static int __devinit iic_probe(struct platform_device *ofdev,
	dev_info(&ofdev->dev, "using %s mode\n",
		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");

	/* Now register all the child nodes */
	of_i2c_register_devices(adap);

	return 0;

error_cleanup:
+1 −0
Original line number Diff line number Diff line
@@ -632,6 +632,7 @@ static int __devinit fsl_i2c_probe(struct platform_device *op,
		dev_err(i2c->dev, "failed to add adapter\n");
		goto fail_add;
	}
	of_i2c_register_devices(&i2c->adap);

	return result;

+0 −4
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/mutex.h>
#include <linux/of_i2c.h>
#include <linux/of_device.h>
#include <linux/completion.h>
#include <linux/hardirq.h>
@@ -874,9 +873,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
	if (adap->nr < __i2c_first_dynamic_bus_num)
		i2c_scan_static_board_info(adap);

	/* Register devices from the device tree */
	of_i2c_register_devices(adap);

	/* Notify drivers */
	mutex_lock(&core_lock);
	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);