Skip to content

Commit c6fc759

Browse files
committed
drivers/misc/mathworks: Use wrapper mathods for devm
To solve cast from 'void (*)(struct device *)' to 'devm_action_fn' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] on strict compile Signed-off-by: Jorge Marques <[email protected]>
1 parent d841859 commit c6fc759

File tree

6 files changed

+89
-18
lines changed

6 files changed

+89
-18
lines changed

drivers/misc/mathworks/mathworks_generic_of.c

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,31 @@
1919

2020
#define DRIVER_NAME "mathworks_generic_of"
2121

22-
static void mwgen_of_unlink_i2c_device(struct mathworks_ip_info *thisIpcore){
22+
static inline void mwgen_of_node_put(void *data)
23+
{
24+
struct device_node *node = data;
25+
26+
of_node_put(node);
27+
}
28+
29+
static inline void mwgen_put_device(void *data)
30+
{
31+
struct device *dev = data;
32+
33+
put_device(dev);
34+
}
35+
36+
static inline void mwgen_of_unlink_i2c_device(void *data)
37+
{
38+
struct mathworks_ip_info *thisIpcore = data;
39+
2340
sysfs_remove_link(&thisIpcore->char_device->kobj, "i2c_device");
2441
}
2542

26-
static void mwgen_of_unlink_i2c_adapter(struct mathworks_ip_info *thisIpcore){
43+
static inline void mwgen_of_unlink_i2c_adapter(void *data)
44+
{
45+
struct mathworks_ip_info *thisIpcore = data;
46+
2747
sysfs_remove_link(&thisIpcore->char_device->kobj, "i2c_adapter");
2848
}
2949

@@ -34,7 +54,8 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
3454

3555
slave_node = of_parse_phandle(nodePointer, "i2c-controller", 0);
3656
if (slave_node) {
37-
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)of_node_put, slave_node);
57+
status = devm_add_action_helper(thisIpcore->dev,
58+
mwgen_of_node_put, slave_node);
3859
if(status)
3960
return status;
4061

@@ -45,7 +66,9 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
4566
dev_err(thisIpcore->dev, "could not find i2c device\n");
4667
return -ENODEV;
4768
}
48-
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)put_device, &thisIpcore->i2c->dev);
69+
status = devm_add_action_helper(thisIpcore->dev,
70+
mwgen_put_device,
71+
&thisIpcore->i2c->dev);
4972
if(status)
5073
return status;
5174

@@ -55,15 +78,19 @@ static int mathworks_generic_of_i2c_init(struct mathworks_ip_info *thisIpcore){
5578
status = sysfs_create_link(&thisIpcore->char_device->kobj, &thisIpcore->i2c->dev.kobj, "i2c_device");
5679
if (status)
5780
return status;
58-
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)mwgen_of_unlink_i2c_device, thisIpcore);
81+
status = devm_add_action_helper(thisIpcore->dev,
82+
mwgen_of_unlink_i2c_device,
83+
thisIpcore);
5984
if(status)
6085
return status;
6186

6287
/* add a link to the i2c bus */
6388
status = sysfs_create_link(&thisIpcore->char_device->kobj, &thisIpcore->i2c->adapter->dev.kobj, "i2c_adapter");
6489
if (status)
6590
return status;
66-
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)mwgen_of_unlink_i2c_adapter, thisIpcore);
91+
status = devm_add_action_helper(thisIpcore->dev,
92+
mwgen_of_unlink_i2c_adapter,
93+
thisIpcore);
6794
if(status)
6895
return status;
6996

drivers/misc/mathworks/mw_mm_iio_channel.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ static void mw_mm_iio_channel_release(struct device *dev)
192192
{
193193
}
194194

195+
static inline void mw_device_unregister(void *data)
196+
{
197+
struct device *dev = data;
198+
199+
device_unregister(dev);
200+
}
201+
195202
static struct iio_dev *devm_mw_mm_iio_alloc(
196203
struct mathworks_ipcore_dev *mwdev,
197204
struct device_node *node,
@@ -253,7 +260,7 @@ static struct iio_dev *devm_mw_mm_iio_alloc(
253260
if (status)
254261
return ERR_PTR(status);
255262

256-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
263+
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
257264
if (status) {
258265
device_unregister(&mwchan->dev);
259266
return ERR_PTR(status);

drivers/misc/mathworks/mw_sharedmem_iio_channel.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ static struct iio_buffer *mw_sharedmem_buffer_alloc(struct device *dev,
332332
return &sharedmem_buff->buffer;
333333
}
334334

335-
static void mw_sharedmem_buffer_free(struct iio_buffer *buffer)
335+
static void mw_sharedmem_buffer_free(void *data)
336336
{
337+
struct iio_buffer *buffer = data;
338+
337339
iio_buffer_put(buffer);
338340
}
339341

@@ -528,7 +530,7 @@ static int devm_mw_sharedmem_configure_buffer(struct iio_dev *indio_dev, enum ii
528530

529531
buffer->direction = direction;
530532

531-
status = devm_add_action(indio_dev->dev.parent,(devm_action_fn)mw_sharedmem_buffer_free, buffer);
533+
status = devm_add_action(indio_dev->dev.parent, mw_sharedmem_buffer_free, buffer);
532534
if(status){
533535
mw_sharedmem_buffer_free(buffer);
534536
return status;
@@ -657,7 +659,15 @@ static int mw_sharedmem_setup_offset_channel(struct iio_dev *indio_dev, struct i
657659
return 0;
658660
}
659661

660-
static void mw_sharedmem_iio_unregister(void *opaque) {
662+
static inline void mw_device_unregister(void *data)
663+
{
664+
struct device *dev = data;
665+
666+
device_unregister(dev);
667+
}
668+
669+
static inline void mw_sharedmem_iio_unregister(void *opaque)
670+
{
661671
struct device *dev = opaque;
662672

663673
/* Unregister the IIO device */
@@ -818,7 +828,7 @@ static struct iio_dev *devm_mw_sharedmem_iio_alloc(
818828
if (status)
819829
return ERR_PTR(status);
820830

821-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
831+
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
822832
if (status) {
823833
device_unregister(&mwchan->dev);
824834
return ERR_PTR(status);
@@ -986,7 +996,7 @@ static struct mw_sharedmem_region_dev *devm_mw_sharedmem_region_alloc(
986996
if (status)
987997
return ERR_PTR(status);
988998

989-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwregion->dev);
999+
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwregion->dev);
9901000
if (status) {
9911001
device_unregister(&mwregion->dev);
9921002
return ERR_PTR(status);

drivers/misc/mathworks/mw_stream_channel.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,27 @@ static void mw_stream_chan_release(struct device *dev)
10871087
}
10881088
}
10891089

1090+
static inline void mw_dma_release_channel(void *data)
1091+
{
1092+
struct dma_chan *chan = data;
1093+
1094+
dma_release_channel(chan);
1095+
}
1096+
1097+
static inline void mw_device_unregister(void *data)
1098+
{
1099+
struct device *dev = data;
1100+
1101+
device_unregister(dev);
1102+
}
1103+
1104+
static inline void mw_sysfs_put(void *data)
1105+
{
1106+
struct kernfs_node *kn = data;
1107+
1108+
sysfs_put(kn);
1109+
}
1110+
10901111
static struct mwadma_chan* __must_check mw_stream_chan_probe(
10911112
struct mwadma_dev *mwdev,
10921113
enum dma_transfer_direction direction,
@@ -1111,7 +1132,7 @@ static struct mwadma_chan* __must_check mw_stream_chan_probe(
11111132
return (void *)chan;
11121133
}
11131134
/* Create the cleanup action */
1114-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)dma_release_channel, chan);
1135+
status = devm_add_action(IP2DEVP(mwdev), mw_dma_release_channel, chan);
11151136
if(status){
11161137
dma_release_channel(chan);
11171138
return ERR_PTR(status);
@@ -1135,7 +1156,7 @@ static struct mwadma_chan* __must_check mw_stream_chan_probe(
11351156
if (mwchan->dev.id < 0) {
11361157
return ERR_PTR(mwchan->dev.id);
11371158
}
1138-
status = devm_add_action(IP2DEVP(mwdev),mw_stream_chan_ida_remove, mwchan);
1159+
status = devm_add_action(IP2DEVP(mwdev), mw_stream_chan_ida_remove, mwchan);
11391160
if(status){
11401161
ida_simple_remove(&mw_stream_channel_ida, mwchan->dev.id);
11411162
return ERR_PTR(status);
@@ -1148,7 +1169,7 @@ static struct mwadma_chan* __must_check mw_stream_chan_probe(
11481169
status = device_add(&mwchan->dev);
11491170
if (status)
11501171
return ERR_PTR(status);
1151-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
1172+
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
11521173
if(status){
11531174
device_unregister(&mwchan->dev);
11541175
return ERR_PTR(status);
@@ -1159,7 +1180,7 @@ static struct mwadma_chan* __must_check mw_stream_chan_probe(
11591180
if(!mwchan->irq_kn){
11601181
return ERR_PTR(-ENODEV);
11611182
}
1162-
status = devm_add_action(&mwchan->dev, (devm_action_fn)sysfs_put, mwchan->irq_kn);
1183+
status = devm_add_action(&mwchan->dev, mw_sysfs_put, mwchan->irq_kn);
11631184
if(status) {
11641185
sysfs_put(mwchan->irq_kn);
11651186
return ERR_PTR(status);

drivers/misc/mathworks/mw_stream_iio_channel.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ static void mw_stream_iio_channel_release(struct device *dev)
490490
{
491491
}
492492

493+
static inline void mw_device_unregister(void *data)
494+
{
495+
struct device *dev = data;
496+
497+
device_unregister(dev);
498+
}
499+
493500
static struct iio_dev *devm_mw_stream_iio_alloc(
494501
struct mathworks_ipcore_dev *mwdev,
495502
struct device_node *node,
@@ -565,7 +572,7 @@ static struct iio_dev *devm_mw_stream_iio_alloc(
565572
if (status)
566573
return ERR_PTR(status);
567574

568-
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
575+
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
569576
if (status) {
570577
device_unregister(&mwchan->dev);
571578
return ERR_PTR(status);

include/linux/mathworks/mathworks_ip.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
/*********************************************************
3535
* Devm Helpers
3636
*********************************************************/
37-
typedef void (*devm_action_fn)(void *);
3837

3938
static inline int devm_add_action_helper(struct device *dev, void (*action)(void *), void *data){
4039
int status;

0 commit comments

Comments
 (0)