Skip to contentSkip to conversation

i2c: mchp-pci1xxxx: Avoid cast to incompatible function type

PATCH Applied Simon Horman 5 participants 5 messages May 10, 2023 – Jun 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: mchp-pci1xxxx: Avoid cast to incompatible function type

Rather than casting pci1xxxx_i2c_shutdown to an incompatible function type, update the type to match that expected by __devm_add_action.

Reported by clang-16 with W-1:

.../i2c-mchp-pci1xxxx.c:1159:29: error: cast from 'void (*)(struct pci1xxxx_i2c *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

         ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

./include/linux/device.h:251:29: note: expanded from macro 'devm_add_action'
__devm_add_action(release, action, data, #action)
^~~~~~

No functional change intended.
Compile tested only.

---
 drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-mchp-pci1xxxx.c +4 -2
index b21ffd6df927..5ef136c3ecb1 100644
@@ -1118,8 +1118,10 @@ static int pci1xxxx_i2c_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(pci1xxxx_i2c_pm_ops, pci1xxxx_i2c_suspend,
 			 pci1xxxx_i2c_resume);
 
-static void pci1xxxx_i2c_shutdown(struct pci1xxxx_i2c *i2c)
+static void pci1xxxx_i2c_shutdown(void *data)
 {
+	struct pci1xxxx_i2c *i2c = data;
+
 	pci1xxxx_i2c_config_padctrl(i2c, false);
 	pci1xxxx_i2c_configure_core_reg(i2c, false);
 }
@@ -1156,7 +1158,7 @@ static int pci1xxxx_i2c_probe_pci(struct pci_dev *pdev,
 	init_completion(&i2c->i2c_xfer_done);
 	pci1xxxx_i2c_init(i2c);
 
-	ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
+	ret = devm_add_action(dev, pci1xxxx_i2c_shutdown, i2c);
 	if (ret)
 		return ret;
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Simon Horman

Rather than casting pci1xxxx_i2c_shutdown to an incompatible function type, update the type to match that expected by __devm_add_action.

Reported by clang-16 with W-1:

.../i2c-mchp-pci1xxxx.c:1159:29: error: cast from 'void (*)(struct pci1xxxx_i2c *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

Quoted 8 lines
         ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

./include/linux/device.h:251:29: note: expanded from macro 'devm_add_action'
__devm_add_action(release, action, data, #action)
^~~~~~

No functional change intended.
Compile tested only.

Quoted 32 lines
---
 drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-mchp-pci1xxxx.c +4 -2
index b21ffd6df927..5ef136c3ecb1 100644
@@ -1118,8 +1118,10 @@ static int pci1xxxx_i2c_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(pci1xxxx_i2c_pm_ops, pci1xxxx_i2c_suspend,
                         pci1xxxx_i2c_resume);
 
-static void pci1xxxx_i2c_shutdown(struct pci1xxxx_i2c *i2c)
+static void pci1xxxx_i2c_shutdown(void *data)
 {
+       struct pci1xxxx_i2c *i2c = data;
+
        pci1xxxx_i2c_config_padctrl(i2c, false);
        pci1xxxx_i2c_configure_core_reg(i2c, false);
 }
@@ -1156,7 +1158,7 @@ static int pci1xxxx_i2c_probe_pci(struct pci_dev *pdev,
        init_completion(&i2c->i2c_xfer_done);
        pci1xxxx_i2c_init(i2c);
 
-       ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
+       ret = devm_add_action(dev, pci1xxxx_i2c_shutdown, i2c);
        if (ret)
                return ret;
 
Signature · 1 line
/Horatiu
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Simon Horman

Hi Simon,

Quoted 8 lines · Simon Horman

Rather than casting pci1xxxx_i2c_shutdown to an incompatible function type, update the type to match that expected by __devm_add_action.

Reported by clang-16 with W-1:

.../i2c-mchp-pci1xxxx.c:1159:29: error: cast from 'void (*)(struct pci1xxxx_i2c *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

         ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines

./include/linux/device.h:251:29: note: expanded from macro 'devm_add_action'
__devm_add_action(release, action, data, #action)
^~~~~~

No functional change intended.
Compile tested only.

Andi

Reviewed-by on v1 1/1
#3 lore raw
In reply to Simon Horman
Quoted 57 lines · Simon Horman

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Rather than casting pci1xxxx_i2c_shutdown to an incompatible function type,
update the type to match that expected by __devm_add_action.

Reported by clang-16 with W-1:

 .../i2c-mchp-pci1xxxx.c:1159:29: error: cast from 'void (*)(struct pci1xxxx_i2c *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
         ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/device.h:251:29: note: expanded from macro 'devm_add_action'
         __devm_add_action(release, action, data, #action) ^~~~~~

No functional change intended.
Compile tested only.

---
 drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-mchp-pci1xxxx.c +3 -1
index b21ffd6df927..5ef136c3ecb1 100644
@@ -1118,8 +1118,10 @@ static int pci1xxxx_i2c_resume(struct device
 *dev)
  static DEFINE_SIMPLE_DEV_PM_OPS(pci1xxxx_i2c_pm_ops,
 pci1xxxx_i2c_suspend,
                          pci1xxxx_i2c_resume);
 
-static void pci1xxxx_i2c_shutdown(struct pci1xxxx_i2c *i2c)
+static void pci1xxxx_i2c_shutdown(void *data)
  {
+       struct pci1xxxx_i2c *i2c = data;
+
         pci1xxxx_i2c_config_padctrl(i2c, false);

        pci1xxxx_i2c_configure_core_reg(i2c, false); }

drivers/i2c/busses/i2c-mchp-pci1xxxx.c +1 -1
@@ -1156,7 +1158,7 @@ static int pci1xxxx_i2c_probe_pci(struct
 pci_dev *pdev,
         init_completion(&i2c->i2c_xfer_done);
         pci1xxxx_i2c_init(i2c);
 
-       ret = devm_add_action(dev, (void (*)(void
 *))pci1xxxx_i2c_shutdown, i2c);
+       ret = devm_add_action(dev, pci1xxxx_i2c_shutdown, i2c);
         if (ret)
Quoted 3 lines

                return ret;

---
with Best Regards,
Tharun Kumar P

Applied
#4 lore raw
In reply to Simon Horman
Quoted 8 lines · Simon Horman

Rather than casting pci1xxxx_i2c_shutdown to an incompatible function type, update the type to match that expected by __devm_add_action.

Reported by clang-16 with W-1:

.../i2c-mchp-pci1xxxx.c:1159:29: error: cast from 'void (*)(struct pci1xxxx_i2c *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]

         ret = devm_add_action(dev, (void (*)(void *))pci1xxxx_i2c_shutdown, i2c);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines

./include/linux/device.h:251:29: note: expanded from macro 'devm_add_action'
__devm_add_action(release, action, data, #action)
^~~~~~

No functional change intended.
Compile tested only.

Applied to for-current, thanks!