diff mbox

[17/21] patches: backport the probe_new for i2c drivers

Message ID 20170821222817.17376-18-hauke@hauke-m.de (mailing list archive)
State Accepted
Headers show

Commit Message

Hauke Mehrtens Aug. 21, 2017, 10:28 p.m. UTC
I2C got a new probe function which does not take the struct
i2c_device_id any more, backport this to older kernel versions with a
spatch.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 patches/0080-i2c-proble-new.cocci | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 patches/0080-i2c-proble-new.cocci
diff mbox

Patch

diff --git a/patches/0080-i2c-proble-new.cocci b/patches/0080-i2c-proble-new.cocci
new file mode 100644
index 00000000..35580aca
--- /dev/null
+++ b/patches/0080-i2c-proble-new.cocci
@@ -0,0 +1,25 @@ 
+@r@
+identifier OPS;
+identifier i2c_probe;
+fresh identifier i2c_probe_wrap = "bp_" ## i2c_probe;
+position p;
+@@
+struct i2c_driver OPS@p = {
++#if LINUX_VERSION_IS_GEQ(4,10,0)
+	.probe_new = i2c_probe,
++#else
++	.probe = i2c_probe_wrap,
++#endif
+};
+
+@@
+identifier r.i2c_probe_wrap;
+identifier r.i2c_probe;
+@@
+int i2c_probe(...) {...}
++#if LINUX_VERSION_IS_LESS(4,10,0)
++static int i2c_probe_wrap(struct i2c_client *client, const struct i2c_device_id *id)
++{
++	return i2c_probe(client);
++}
++#endif