Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions drivers/misc/mathworks/mathworks_generic_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,32 @@

#define DRIVER_NAME "mathworks_generic_of"

static void mwgen_of_unlink_i2c_device(struct mathworks_ip_info *thisIpcore){
#if defined(CONFIG_I2C)
static inline void mwgen_of_node_put(void *data)
{
struct device_node *node = data;

of_node_put(node);
}

static inline void mwgen_put_device(void *data)
{
struct device *dev = data;

put_device(dev);
}

static inline void mwgen_of_unlink_i2c_device(void *data)
{
struct mathworks_ip_info *thisIpcore = data;

sysfs_remove_link(&thisIpcore->char_device->kobj, "i2c_device");
}

static void mwgen_of_unlink_i2c_adapter(struct mathworks_ip_info *thisIpcore){
static inline void mwgen_of_unlink_i2c_adapter(void *data)
{
struct mathworks_ip_info *thisIpcore = data;

sysfs_remove_link(&thisIpcore->char_device->kobj, "i2c_adapter");
}

Expand All @@ -34,7 +55,8 @@

slave_node = of_parse_phandle(nodePointer, "i2c-controller", 0);
if (slave_node) {
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)of_node_put, slave_node);
status = devm_add_action_helper(thisIpcore->dev,
mwgen_of_node_put, slave_node);
if(status)
return status;

Expand All @@ -45,7 +67,9 @@
dev_err(thisIpcore->dev, "could not find i2c device\n");
return -ENODEV;
}
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)put_device, &thisIpcore->i2c->dev);
status = devm_add_action_helper(thisIpcore->dev,
mwgen_put_device,
&thisIpcore->i2c->dev);
if(status)
return status;

Expand All @@ -55,15 +79,19 @@
status = sysfs_create_link(&thisIpcore->char_device->kobj, &thisIpcore->i2c->dev.kobj, "i2c_device");
if (status)
return status;
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)mwgen_of_unlink_i2c_device, thisIpcore);
status = devm_add_action_helper(thisIpcore->dev,
mwgen_of_unlink_i2c_device,
thisIpcore);
if(status)
return status;

/* add a link to the i2c bus */
status = sysfs_create_link(&thisIpcore->char_device->kobj, &thisIpcore->i2c->adapter->dev.kobj, "i2c_adapter");
if (status)
return status;
status = devm_add_action_helper(thisIpcore->dev, (devm_action_fn)mwgen_of_unlink_i2c_adapter, thisIpcore);
status = devm_add_action_helper(thisIpcore->dev,
mwgen_of_unlink_i2c_adapter,
thisIpcore);
if(status)
return status;

Expand All @@ -73,6 +101,7 @@

return 0;
}
#endif

static int mathworks_generic_of_get_param(struct mathworks_ip_info *thisIpcore, void *arg)
{
Expand All @@ -80,7 +109,7 @@
const void *paramData;
int len;

if( copy_from_user(&pinfo, (struct mathworks_ip_param_info *)arg, sizeof(struct mathworks_ip_param_info)) ) {

Check warning on line 112 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 2 (different address spaces)

Check warning on line 112 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 2 (different address spaces)

Check warning on line 112 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_sparse: incorrect type in argument 2 (different address spaces)
return -EACCES;
}

Expand All @@ -88,13 +117,13 @@
pinfo.size = len;

/* Copy the struct back to user space */
if( copy_to_user((struct mathworks_ip_param_info*)arg, &pinfo, sizeof(struct mathworks_ip_param_info)) ) {

Check warning on line 120 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 1 (different address spaces)

Check warning on line 120 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 1 (different address spaces)

Check warning on line 120 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_sparse: incorrect type in argument 1 (different address spaces)
return -EACCES;
}

/* Copy any data to the user buf */
if (paramData) {
if( copy_to_user((void *)pinfo.buf, paramData, pinfo.size) ){

Check warning on line 126 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 1 (different address spaces)

Check warning on line 126 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: incorrect type in argument 1 (different address spaces)
return -EACCES;
}
} else {
Expand All @@ -110,7 +139,7 @@
snprintf(devname,MATHWORKS_IP_DEVNAME_LEN, "%s", of_devname);
}

struct mathworks_ip_ops mw_of_ops = {

Check warning on line 142 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: symbol 'mw_of_ops' was not declared. Should it be static? CHECK drivers/misc/mathworks/mw_stream_iio_channel.c

Check warning on line 142 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

sparse: symbol 'mw_of_ops' was not declared. Should it be static? CHECK drivers/misc/mathworks/mw_mm_iio_channel.c CHECK drivers/misc/mathworks/mw_sharedmem_iio_channel.c
.get_devname = mathworks_generic_of_get_devname,
.get_param = mathworks_generic_of_get_param,
.fops = &mathworks_ip_common_fops,
Expand All @@ -129,7 +158,7 @@
static int mathworks_generic_of_probe(struct platform_device *pdev)
{
int status = 0;
struct mathworks_ip_info *thisIpcore;

Check warning on line 161 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: inconsistent indenting

Check warning on line 161 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: inconsistent indenting

Check warning on line 161 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: inconsistent indenting


thisIpcore = devm_mathworks_ip_of_init(pdev, THIS_MODULE, &mw_of_ops, false);
Expand All @@ -137,7 +166,7 @@
return PTR_ERR(thisIpcore);

status = devm_mathworks_ip_register(thisIpcore);
if(status)

Check warning on line 169 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: inconsistent indenting

Check warning on line 169 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: inconsistent indenting

Check warning on line 169 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: inconsistent indenting
{
dev_err(&pdev->dev, "mwgeneric device registration failed: %d\n", status);
return status;
Expand All @@ -157,7 +186,7 @@
static struct platform_driver mathworks_ip_driver = {
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,

Check warning on line 189 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 3-8 No need to set .owner here. The core will do it.

Check warning on line 189 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 3-8 No need to set .owner here. The core will do it.

Check warning on line 189 in drivers/misc/mathworks/mathworks_generic_of.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 3-8 No need to set .owner here. The core will do it.
.of_match_table = mathworks_generic_of_match,
},
.probe = mathworks_generic_of_probe,
Expand Down
9 changes: 8 additions & 1 deletion drivers/misc/mathworks/mw_mm_iio_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@
{
}

static inline void mw_device_unregister(void *data)
{
struct device *dev = data;

device_unregister(dev);
}

static struct iio_dev *devm_mw_mm_iio_alloc(
struct mathworks_ipcore_dev *mwdev,
struct device_node *node,
Expand Down Expand Up @@ -222,7 +229,7 @@
mwchan->dev.parent = IP2DEVP(mwdev);
mwchan->dev.of_node = node;
mwchan->dev.id = ida_simple_get(&mw_mm_iio_channel_ida, 0, 0, GFP_KERNEL);
if (mwchan->dev.id < 0) {

Check warning on line 232 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: unsigned 'mwchan->dev.id' is never less than zero.

Check warning on line 232 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: unsigned 'mwchan->dev.id' is never less than zero.

Check warning on line 232 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: unsigned 'mwchan->dev.id' is never less than zero.
return ERR_PTR(mwchan->dev.id);
}
status = devm_add_action(IP2DEVP(mwdev),mw_mm_iio_chan_ida_remove, mwchan);
Expand Down Expand Up @@ -253,7 +260,7 @@
if (status)
return ERR_PTR(status);

status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
if (status) {
device_unregister(&mwchan->dev);
return ERR_PTR(status);
Expand Down Expand Up @@ -305,7 +312,7 @@
const struct of_device_id *match;


for_each_child_of_node(IP2DEVP(mwdev)->of_node,child) {

Check warning on line 315 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 320.

Check warning on line 315 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 320.

Check warning on line 315 in drivers/misc/mathworks/mw_mm_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 320.
match = of_match_node(mw_mm_iio_channel_of_match, child);
if(match){
status = mw_mm_iio_channel_probe(mwdev, child, (struct mw_mm_iio_channel_info *)match->data);
Expand Down
20 changes: 15 additions & 5 deletions drivers/misc/mathworks/mw_sharedmem_iio_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
mutex_unlock(&region->lock);
mutex_unlock(&region->read_count_lock);

return ret;

Check warning on line 211 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-7 preceding lock on line 187

Check warning on line 211 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-7 preceding lock on line 187

Check warning on line 211 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-7 preceding lock on line 187
}

static int mw_sharedmem_buffer_set_bytes_per_datum(struct iio_buffer *buffer, size_t bpd)
Expand Down Expand Up @@ -332,8 +332,10 @@
return &sharedmem_buff->buffer;
}

static void mw_sharedmem_buffer_free(struct iio_buffer *buffer)
static void mw_sharedmem_buffer_free(void *data)
{
struct iio_buffer *buffer = data;

iio_buffer_put(buffer);
}

Expand Down Expand Up @@ -528,7 +530,7 @@

buffer->direction = direction;

status = devm_add_action(indio_dev->dev.parent,(devm_action_fn)mw_sharedmem_buffer_free, buffer);
status = devm_add_action(indio_dev->dev.parent, mw_sharedmem_buffer_free, buffer);
if(status){
mw_sharedmem_buffer_free(buffer);
return status;
Expand Down Expand Up @@ -657,7 +659,15 @@
return 0;
}

static void mw_sharedmem_iio_unregister(void *opaque) {
static inline void mw_device_unregister(void *data)
{
struct device *dev = data;

device_unregister(dev);
}

static inline void mw_sharedmem_iio_unregister(void *opaque)
{
struct device *dev = opaque;

/* Unregister the IIO device */
Expand Down Expand Up @@ -818,7 +828,7 @@
if (status)
return ERR_PTR(status);

status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
if (status) {
device_unregister(&mwchan->dev);
return ERR_PTR(status);
Expand Down Expand Up @@ -986,7 +996,7 @@
if (status)
return ERR_PTR(status);

status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwregion->dev);
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwregion->dev);
if (status) {
device_unregister(&mwregion->dev);
return ERR_PTR(status);
Expand Down Expand Up @@ -1034,7 +1044,7 @@
}

/* Probe the read/write channels */
for_each_child_of_node(node,child) {

Check warning on line 1047 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1053.

Check warning on line 1047 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1053.

Check warning on line 1047 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1053.
match = of_match_node(mw_sharedmem_iio_channel_of_match, child);
if(match){
info = (struct mw_sharedmem_iio_channel_info *)match->data;
Expand All @@ -1060,7 +1070,7 @@
const struct of_device_id *match;


for_each_child_of_node(IP2DEVP(mwdev)->of_node,child) {

Check warning on line 1073 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1078.

Check warning on line 1073 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1078.

Check warning on line 1073 in drivers/misc/mathworks/mw_sharedmem_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 1078.
match = of_match_node(mw_sharedmem_iio_of_match, child);
if(match){
status = mw_sharedmem_iio_probe(mwdev, child);
Expand Down
29 changes: 25 additions & 4 deletions drivers/misc/mathworks/mw_stream_channel.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* MathWorks Streaming Channel
*
Expand Down Expand Up @@ -59,7 +59,7 @@
{
MW_DBG_text("INODE is NULL\n");
}
mw_ip_info = container_of(inode->i_cdev, struct mathworks_ip_info, cdev);

Check failure on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: we previously assumed 'inode' could be null (see line 58)

Check warning on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Dereference of null pointer [core.NullDereference] 62 | mw_ip_info = container_of(inode->i_cdev, struct mathworks_ip_info, cdev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check failure on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

smatch: we previously assumed 'inode' could be null (see line 58)

Check warning on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Dereference of null pointer [core.NullDereference] 62 | mw_ip_info = container_of(inode->i_cdev, struct mathworks_ip_info, cdev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check failure on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: we previously assumed 'inode' could be null (see line 58)

Check warning on line 62 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Dereference of null pointer [core.NullDereference] 62 | mw_ip_info = container_of(inode->i_cdev, struct mathworks_ip_info, cdev); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mw_ipcore_dev = (struct mathworks_ipcore_dev *)mw_ip_info->private;
mwdev = (struct mwadma_dev *)mw_ipcore_dev->private;
fp->private_data = mwdev;
Expand Down Expand Up @@ -283,7 +283,7 @@
dma_cookie_t ck;
unsigned long flags;
if(NULL == mwchan) {
dev_err(&mwchan->dev, "mw-axidma: Channel queue pointer is NULL.\n");

Check warning on line 286 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 25-28 ERROR mwchan is NULL but dereferenced.

Check warning on line 286 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 25-28 ERROR mwchan is NULL but dereferenced.

Check warning on line 286 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 25-28 ERROR mwchan is NULL but dereferenced.
ret = -ENODEV;
goto start_failed;
}
Expand Down Expand Up @@ -476,7 +476,7 @@
{
return -ENOMEM;
}
ret = mw_axidma_setupchannel(mwdev, mwchan, &usrbuf);

Check warning on line 479 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'ret' is never read [deadcode.DeadStores] 479 | ret = mw_axidma_setupchannel(mwdev, mwchan, &usrbuf); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check warning on line 479 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'ret' is never read [deadcode.DeadStores] 479 | ret = mw_axidma_setupchannel(mwdev, mwchan, &usrbuf); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check warning on line 479 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'ret' is never read [deadcode.DeadStores] 479 | ret = mw_axidma_setupchannel(mwdev, mwchan, &usrbuf); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
break;

case MWADMA_TX_ENQUEUE:
Expand Down Expand Up @@ -833,7 +833,7 @@
}
dev_dbg(IP2DEVP(mwdev), "dma setup_cdev successful\n");

status = 0;

Check warning on line 836 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'status' is never read [deadcode.DeadStores] 836 | status = 0; | ^ ~

Check warning on line 836 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'status' is never read [deadcode.DeadStores] 836 | status = 0; | ^ ~

Check warning on line 836 in drivers/misc/mathworks/mw_stream_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'status' is never read [deadcode.DeadStores] 836 | status = 0; | ^ ~
if (MWDEV_TO_MWIP(mwdev)->dma_info.virt == NULL){
return -EINVAL;
}
Expand Down Expand Up @@ -1087,6 +1087,27 @@
}
}

static inline void mw_dma_release_channel(void *data)
{
struct dma_chan *chan = data;

dma_release_channel(chan);
}

static inline void mw_device_unregister(void *data)
{
struct device *dev = data;

device_unregister(dev);
}

static inline void mw_sysfs_put(void *data)
{
struct kernfs_node *kn = data;

sysfs_put(kn);
}

static struct mwadma_chan* __must_check mw_stream_chan_probe(
struct mwadma_dev *mwdev,
enum dma_transfer_direction direction,
Expand All @@ -1111,7 +1132,7 @@
return (void *)chan;
}
/* Create the cleanup action */
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)dma_release_channel, chan);
status = devm_add_action(IP2DEVP(mwdev), mw_dma_release_channel, chan);
if(status){
dma_release_channel(chan);
return ERR_PTR(status);
Expand All @@ -1135,7 +1156,7 @@
if (mwchan->dev.id < 0) {
return ERR_PTR(mwchan->dev.id);
}
status = devm_add_action(IP2DEVP(mwdev),mw_stream_chan_ida_remove, mwchan);
status = devm_add_action(IP2DEVP(mwdev), mw_stream_chan_ida_remove, mwchan);
if(status){
ida_simple_remove(&mw_stream_channel_ida, mwchan->dev.id);
return ERR_PTR(status);
Expand All @@ -1148,7 +1169,7 @@
status = device_add(&mwchan->dev);
if (status)
return ERR_PTR(status);
status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
if(status){
device_unregister(&mwchan->dev);
return ERR_PTR(status);
Expand All @@ -1159,7 +1180,7 @@
if(!mwchan->irq_kn){
return ERR_PTR(-ENODEV);
}
status = devm_add_action(&mwchan->dev, (devm_action_fn)sysfs_put, mwchan->irq_kn);
status = devm_add_action(&mwchan->dev, mw_sysfs_put, mwchan->irq_kn);
if(status) {
sysfs_put(mwchan->irq_kn);
return ERR_PTR(status);
Expand Down
9 changes: 8 additions & 1 deletion drivers/misc/mathworks/mw_stream_iio_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}
static int mw_stream_iio_buffer_postenable(struct iio_dev *indio_dev)
{
struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev);

Check warning on line 108 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 108 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

Check warning on line 108 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 108 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

Check warning on line 108 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 108 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

dev_dbg(&mwchan->dev, "buffer postenable\n");
return 0;
Expand Down Expand Up @@ -135,7 +135,7 @@

static int mw_stream_iio_buffer_postdisable(struct iio_dev *indio_dev)
{
struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev);

Check warning on line 138 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 138 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

Check warning on line 138 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 138 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

Check warning on line 138 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'mwchan' during its initialization is never read [deadcode.DeadStores] 138 | struct mw_stream_iio_chandev *mwchan = iio_priv(indio_dev); | ^~~~~~ ~~~~~~~~~~~~~~~~~~~

dev_dbg(&mwchan->dev, "buffer postdisable\n");
return 0;
Expand Down Expand Up @@ -377,7 +377,7 @@
unsigned long *available_scan_masks;


for_each_child_of_node(mwchan->dev.of_node,data_node) {

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 396.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 391.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 387.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 396.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 391.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 387.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 396.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 391.

Check warning on line 380 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 387.
status = of_device_is_compatible(data_node, mw_stream_iio_data_channel_compat);
if(!status)
continue;
Expand Down Expand Up @@ -490,6 +490,13 @@
{
}

static inline void mw_device_unregister(void *data)
{
struct device *dev = data;

device_unregister(dev);
}

static struct iio_dev *devm_mw_stream_iio_alloc(
struct mathworks_ipcore_dev *mwdev,
struct device_node *node,
Expand Down Expand Up @@ -565,7 +572,7 @@
if (status)
return ERR_PTR(status);

status = devm_add_action(IP2DEVP(mwdev), (devm_action_fn)device_unregister, &mwchan->dev);
status = devm_add_action(IP2DEVP(mwdev), mw_device_unregister, &mwchan->dev);
if (status) {
device_unregister(&mwchan->dev);
return ERR_PTR(status);
Expand Down Expand Up @@ -617,7 +624,7 @@
const struct of_device_id *match;


for_each_child_of_node(IP2DEVP(mwdev)->of_node,child) {

Check warning on line 627 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 632.

Check warning on line 627 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 632.

Check warning on line 627 in drivers/misc/mathworks/mw_stream_iio_channel.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 1-23 WARNING Function "for_each_child_of_node" should have of_node_put() before return around line 632.
match = of_match_node(mw_stream_iio_channel_of_match, child);
if(match){
status = mw_stream_iio_channel_probe(mwdev, child, (struct mw_stream_iio_channel_info *)match->data);
Expand Down
1 change: 0 additions & 1 deletion include/linux/mathworks/mathworks_ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/*********************************************************
* Devm Helpers
*********************************************************/
typedef void (*devm_action_fn)(void *);

static inline int devm_add_action_helper(struct device *dev, void (*action)(void *), void *data){
int status;
Expand Down
Loading