Re: hyperv/netvsc: Delete two error messages for a failed memory allocation in netvsc_init_buf()

2018-01-15 Thread SF Markus Elfring
> These messages are not displayed anywhere else:
> "unable to allocate receive buffer of size %u\n"
> "unable to allocate send buffer of size %u\n",
> 
> After set ret = -ENOMEM; and cleanup, we won't know which buffer allocation 
> failed without the error message.

How do you think about to achieve the distinction for these buffers by any 
other means?

Can a detailed function call stack dump be appropriate?


> So please do not remove these messages.

Would you dare to adjust this function implementation in any other ways?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: hyperv/netvsc: Delete two error messages for a failed memory allocation in netvsc_init_buf()

2018-01-08 Thread SF Markus Elfring
> These messages are not displayed anywhere else:
> "unable to allocate receive buffer of size %u\n"
> "unable to allocate send buffer of size %u\n",
> 
> After set ret = -ENOMEM; and cleanup, we won't know which buffer allocation 
> failed without the error message.

Do you notice a Linux allocation failure report before them in your system?


> So please do not remove these messages.

How much does the distinction matter for these buffers?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] hyperv/netvsc: Delete two error messages for a failed memory allocation in netvsc_init_buf()

2018-01-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 7 Jan 2018 21:03:26 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/net/hyperv/netvsc.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 17e529af79dc..c1ec02f801f6 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -275,9 +275,6 @@ static int netvsc_init_buf(struct hv_device *device,
 
net_device->recv_buf = vzalloc(buf_size);
if (!net_device->recv_buf) {
-   netdev_err(ndev,
-  "unable to allocate receive buffer of size %u\n",
-  buf_size);
ret = -ENOMEM;
goto cleanup;
}
@@ -357,8 +354,6 @@ static int netvsc_init_buf(struct hv_device *device,
 
net_device->send_buf = vzalloc(buf_size);
if (!net_device->send_buf) {
-   netdev_err(ndev, "unable to allocate send buffer of size %u\n",
-  buf_size);
ret = -ENOMEM;
goto cleanup;
}
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/rtl8192u/ieee80211: Delete an error message for a failed memory allocation in ieee80211_networks_allocate()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 15:46:07 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_module.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index 90a097f2cd4e..f900dee19a7f 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -67,11 +67,8 @@ static inline int ieee80211_networks_allocate(struct 
ieee80211_device *ieee)
ieee->networks = kcalloc(
MAX_NETWORK_COUNT, sizeof(struct ieee80211_network),
GFP_KERNEL);
-   if (!ieee->networks) {
-   printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
-  ieee->dev->name);
+   if (!ieee->networks)
return -ENOMEM;
-   }
 
return 0;
 }
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: Delete an error message for a failed memory allocation in vnt_alloc_bufs()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 15:15:45 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/vt6656/main_usb.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index cc6d8778fe5b..554b21e40298 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -437,11 +437,8 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
 
for (ii = 0; ii < priv->num_rcb; ii++) {
priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL);
-   if (!priv->rcb[ii]) {
-   dev_err(&priv->usb->dev,
-   "failed to allocate rcb no %d\n", ii);
+   if (!priv->rcb[ii])
goto free_rx_tx;
-   }
 
rcb = priv->rcb[ii];
 
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging/wlan-ng/prism2fw: Use common error handling code in writeimage()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 13:41:41 +0100

Replace two calls of the function "kfree" by a jump to the same statements
at the end of this function so that the generated object code could become
a bit smaller.

Signed-off-by: Markus Elfring 
---
 drivers/staging/wlan-ng/prism2fw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c 
b/drivers/staging/wlan-ng/prism2fw.c
index e6f7ed17106a..42ad5ff7772e 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -1012,9 +1012,8 @@ static int writeimage(struct wlandevice *wlandev, struct 
imgchunk *fchunk,
rstmsg = kzalloc(sizeof(*rstmsg), GFP_KERNEL);
rwrmsg = kzalloc(sizeof(*rwrmsg), GFP_KERNEL);
if (!rstmsg || !rwrmsg) {
-   kfree(rstmsg);
-   kfree(rwrmsg);
-   return -ENOMEM;
+   result = -ENOMEM;
+   goto free_result;
}
 
/* Initialize the messages */
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in writeimage()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 13:28:15 +0100

Omit an extra message for a memory allocation failure in this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/wlan-ng/prism2fw.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c 
b/drivers/staging/wlan-ng/prism2fw.c
index efca9108dad8..e6f7ed17106a 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -1014,9 +1014,6 @@ static int writeimage(struct wlandevice *wlandev, struct 
imgchunk *fchunk,
if (!rstmsg || !rwrmsg) {
kfree(rstmsg);
kfree(rwrmsg);
-   netdev_err(wlandev->netdev,
-  "%s: no memory for firmware download, aborting 
download\n",
-  __func__);
return -ENOMEM;
}
 
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging/wlan-ng/prism2fw: Use a known error code after a failed kzalloc() in mkimage()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 13:20:10 +0100

Make a memory allocation failure clearer by using the error code "-ENOMEM"
(instead of the constant "1") in this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/wlan-ng/prism2fw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c 
b/drivers/staging/wlan-ng/prism2fw.c
index 6888d1b093fa..efca9108dad8 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -558,7 +558,7 @@ static int mkimage(struct imgchunk *clist, unsigned int 
*ccnt)
for (i = 0; i < *ccnt; i++) {
clist[i].data = kzalloc(clist[i].len, GFP_KERNEL);
if (!clist[i].data)
-   return 1;
+   return -ENOMEM;
 
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
 i, clist[i].addr, clist[i].len);
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging/wlan-ng/prism2fw: Delete an error message for a failed memory allocation in mkimage()

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 12:57:13 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/wlan-ng/prism2fw.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c 
b/drivers/staging/wlan-ng/prism2fw.c
index 344bec8cc31b..6888d1b093fa 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -557,10 +557,9 @@ static int mkimage(struct imgchunk *clist, unsigned int 
*ccnt)
/* Allocate buffer space for chunks */
for (i = 0; i < *ccnt; i++) {
clist[i].data = kzalloc(clist[i].len, GFP_KERNEL);
-   if (!clist[i].data) {
-   pr_err("failed to allocate image space, exitting.\n");
+   if (!clist[i].data)
return 1;
-   }
+
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
 i, clist[i].addr, clist[i].len);
}
-- 
2.15.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/4] staging/wlan-ng/prism2fw: Adjustments for two function implementations

2017-12-13 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 13 Dec 2017 14:03:02 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
  Delete an error message for a failed memory allocation in mkimage()
  Use a known error code after a failed kzalloc() in mkimage()
  Delete an error message for a failed memory allocation in writeimage()
  Use common error handling code in writeimage()

 drivers/staging/wlan-ng/prism2fw.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

-- 
2.15.1


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_work_queue()

2017-11-03 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 3 Nov 2017 20:37:03 +0100

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace four calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/unisys/visorbus/visorchipset.c | 36 --
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchipset.c 
b/drivers/staging/unisys/visorbus/visorchipset.c
index fed554a43151..1d54821dd7b6 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1231,11 +1231,9 @@ static void setup_crash_devices_work_queue(struct 
work_struct *work)
if (visorchannel_read(chipset_dev->controlvm_channel,
  offsetof(struct visor_controlvm_channel,
   saved_crash_message_count),
- &local_crash_msg_count, sizeof(u16)) < 0) {
-   dev_err(&chipset_dev->acpi_device->dev,
-   "failed to read channel\n");
-   return;
-   }
+ &local_crash_msg_count, sizeof(u16)) < 0)
+   goto report_read_failure;
+
if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
dev_err(&chipset_dev->acpi_device->dev, "invalid count\n");
return;
@@ -1244,30 +1242,24 @@ static void setup_crash_devices_work_queue(struct 
work_struct *work)
if (visorchannel_read(chipset_dev->controlvm_channel,
  offsetof(struct visor_controlvm_channel,
   saved_crash_message_offset),
- &local_crash_msg_offset, sizeof(u32)) < 0) {
-   dev_err(&chipset_dev->acpi_device->dev,
-   "failed to read channel\n");
-   return;
-   }
+ &local_crash_msg_offset, sizeof(u32)) < 0)
+   goto report_read_failure;
+
/* read create device message for storage bus offset */
if (visorchannel_read(chipset_dev->controlvm_channel,
  local_crash_msg_offset,
  &local_crash_bus_msg,
- sizeof(struct controlvm_message)) < 0) {
-   dev_err(&chipset_dev->acpi_device->dev,
-   "failed to read channel\n");
-   return;
-   }
+ sizeof(struct controlvm_message)) < 0)
+   goto report_read_failure;
+
/* read create device message for storage device */
if (visorchannel_read(chipset_dev->controlvm_channel,
  local_crash_msg_offset +
  sizeof(struct controlvm_message),
  &local_crash_dev_msg,
- sizeof(struct controlvm_message)) < 0) {
-   dev_err(&chipset_dev->acpi_device->dev,
-   "failed to read channel\n");
-   return;
-   }
+ sizeof(struct controlvm_message)) < 0)
+   goto report_read_failure;
+
/* reuse IOVM create bus message */
if (!local_crash_bus_msg.cmd.create_bus.channel_addr) {
dev_err(&chipset_dev->acpi_device->dev,
@@ -1282,6 +1274,10 @@ static void setup_crash_devices_work_queue(struct 
work_struct *work)
return;
}
visorbus_device_create(&local_crash_dev_msg);
+   return;
+
+report_read_failure:
+   dev_err(&chipset_dev->acpi_device->dev, "failed to read channel\n");
 }
 
 void visorbus_response(struct visor_device *bus_info, int response,
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/rts5208/rtsx: Improve unlocking of a mutex in rtsx_resume()

2017-11-03 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 3 Nov 2017 20:02:22 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only twice in this function implementation.

* Replace two calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/rts5208/rtsx.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index 89e2cfe7d1cc..14022a76ecfb 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -349,9 +349,7 @@ static int rtsx_resume(struct pci_dev *pci)
dev_err(&dev->pci->dev,
"%s: pci_enable_device failed, disabling device\n",
CR_DRIVER_NAME);
-   /* unlock the device pointers */
-   mutex_unlock(&dev->dev_mutex);
-   return -EIO;
+   goto unlock;
}
pci_set_master(pci);
 
@@ -360,11 +358,8 @@ static int rtsx_resume(struct pci_dev *pci)
chip->msi_en = 0;
}
 
-   if (rtsx_acquire_irq(dev) < 0) {
-   /* unlock the device pointers */
-   mutex_unlock(&dev->dev_mutex);
-   return -EIO;
-   }
+   if (rtsx_acquire_irq(dev) < 0)
+   goto unlock;
 
rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00);
rtsx_init_chip(chip);
@@ -373,6 +368,10 @@ static int rtsx_resume(struct pci_dev *pci)
mutex_unlock(&dev->dev_mutex);
 
return 0;
+
+unlock:
+   mutex_unlock(&dev->dev_mutex);
+   return -EIO;
 }
 #endif /* CONFIG_PM */
 
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: comedi: usbduxfast: Improve unlocking of a mutex in usbduxfast_ai_insn_read()

2017-11-03 Thread SF Markus Elfring
> FYI, you are responding to someone who is on my blacklist

I am curious if this communication setting will ever be adjusted.


> and I never accept patches from.

The history shows that our collaboration style changed over time.
I got a few update suggestions integrated (also by you) because
other contributors found them good enough to repeat them.

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: usbduxfast: Improve unlocking of a mutex in usbduxfast_ai_insn_read()

2017-11-03 Thread SF Markus Elfring
>> @@ -838,6 +834,10 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
>> *dev,
>>   mutex_unlock(&devpriv->mut);
>>     return insn->n;
> 
> Minor niggle: You could also remove that call to mutex_unlock() by replacing 
> the above three lines with:
> 
> ret = insn->n;
> 
> which will fall through to the 'unlock:' label below.

Thanks for your suggestion.

Such a software refactoring is also possible if a corresponding
consensus could be achieved.
* Can such a change mean that the lock scope will be extended
  for both use cases (successful and failed function execution)?

* How much does this implementation matter for you?

* Would you like to achieve a small reduction of the object code there?

* How do you think about consequences from special communication settings
  by a well-known maintainer for my update suggestions?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/media/davinci_vpfe: Use common error handling code in vpfe_attach_irq()

2017-11-03 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 3 Nov 2017 10:45:31 +0100

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c 
b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index bffe2153b910..80297d2df31d 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -309,8 +309,7 @@ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
if (ret < 0) {
v4l2_err(&vpfe_dev->v4l2_dev,
"Error: requesting VINT1 interrupt\n");
-   free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
-   return ret;
+   goto free_irq;
}
 
ret = request_irq(vpfe_dev->imp_dma_irq, vpfe_imp_dma_isr,
@@ -319,11 +318,14 @@ static int vpfe_attach_irq(struct vpfe_device *vpfe_dev)
v4l2_err(&vpfe_dev->v4l2_dev,
 "Error: requesting IMP IRQ interrupt\n");
free_irq(vpfe_dev->ccdc_irq1, vpfe_dev);
-   free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
-   return ret;
+   goto free_irq;
}
 
return 0;
+
+free_irq:
+   free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
+   return ret;
 }
 
 /*
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: iio: ad7746: Improve unlocking of a mutex in ad7746_start_calib()

2017-11-03 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 3 Nov 2017 09:26:28 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only twice in this function implementation.

* Replace two calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/iio/cdc/ad7746.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index a124853a05f0..c4a864725376 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -302,23 +302,24 @@ static inline ssize_t ad7746_start_calib(struct device 
*dev,
mutex_lock(&chip->lock);
regval |= chip->config;
ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval);
-   if (ret < 0) {
-   mutex_unlock(&chip->lock);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
do {
msleep(20);
ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG);
-   if (ret < 0) {
-   mutex_unlock(&chip->lock);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
+
} while ((ret == regval) && timeout--);
 
mutex_unlock(&chip->lock);
 
return len;
+
+unlock:
+   mutex_unlock(&chip->lock);
+   return ret;
 }
 
 static ssize_t ad7746_start_offset_calib(struct device *dev,
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: iio: ad7152: Improve unlocking of a mutex in ad7152_start_calib()

2017-11-03 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 3 Nov 2017 09:00:25 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only twice in this function implementation.

* Replace two calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/iio/cdc/ad7152.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
index 61377ca444de..59d1b35f6a4e 100644
--- a/drivers/staging/iio/cdc/ad7152.c
+++ b/drivers/staging/iio/cdc/ad7152.c
@@ -118,22 +118,23 @@ static inline ssize_t ad7152_start_calib(struct device 
*dev,
 
mutex_lock(&chip->state_lock);
ret = i2c_smbus_write_byte_data(chip->client, AD7152_REG_CFG, regval);
-   if (ret < 0) {
-   mutex_unlock(&chip->state_lock);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
do {
mdelay(20);
ret = i2c_smbus_read_byte_data(chip->client, AD7152_REG_CFG);
-   if (ret < 0) {
-   mutex_unlock(&chip->state_lock);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
+
} while ((ret == regval) && timeout--);
 
mutex_unlock(&chip->state_lock);
return len;
+
+unlock:
+   mutex_unlock(&chip->state_lock);
+   return ret;
 }
 
 static ssize_t ad7152_start_offset_calib(struct device *dev,
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fbtft: fb_ssd1331: Use common error handling code in write_reg8_bus8()

2017-11-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 2 Nov 2017 22:27:13 +0100

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/fbtft/fb_ssd1331.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/fbtft/fb_ssd1331.c 
b/drivers/staging/fbtft/fb_ssd1331.c
index 9aa9864fcf30..b3a8f2668951 100644
--- a/drivers/staging/fbtft/fb_ssd1331.c
+++ b/drivers/staging/fbtft/fb_ssd1331.c
@@ -76,12 +76,9 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, 
...)
if (par->gpio.dc != -1)
gpio_set_value(par->gpio.dc, 0);
ret = par->fbtftops.write(par, par->buf, sizeof(u8));
-   if (ret < 0) {
-   va_end(args);
-   dev_err(par->info->device,
-   "write() failed and returned %d\n", ret);
-   return;
-   }
+   if (ret < 0)
+   goto end_va;
+
len--;
 
if (len) {
@@ -89,16 +86,17 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, 
...)
while (i--)
*buf++ = (u8)va_arg(args, unsigned int);
ret = par->fbtftops.write(par, par->buf, len * (sizeof(u8)));
-   if (ret < 0) {
-   va_end(args);
-   dev_err(par->info->device,
-   "write() failed and returned %d\n", ret);
-   return;
-   }
+   if (ret < 0)
+   goto end_va;
}
if (par->gpio.dc != -1)
gpio_set_value(par->gpio.dc, 1);
va_end(args);
+   return;
+
+end_va:
+   va_end(args);
+   dev_err(par->info->device, "write() failed and returned %d\n", ret);
 }
 
 /*
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fbtft: fb_ra8875: Use common error handling code in write_reg8_bus8()

2017-11-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 2 Nov 2017 22:12:58 +0100

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/fbtft/fb_ra8875.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/fbtft/fb_ra8875.c 
b/drivers/staging/fbtft/fb_ra8875.c
index 6d1cad85957b..6a94b5810a31 100644
--- a/drivers/staging/fbtft/fb_ra8875.c
+++ b/drivers/staging/fbtft/fb_ra8875.c
@@ -218,12 +218,9 @@ static void write_reg8_bus8(struct fbtft_par *par, int 
len, ...)
*buf++ = 0x80;
*buf = (u8)va_arg(args, unsigned int);
ret = par->fbtftops.write(par, par->buf, 2);
-   if (ret < 0) {
-   va_end(args);
-   dev_err(par->info->device, "write() failed and returned %dn",
-   ret);
-   return;
-   }
+   if (ret < 0)
+   goto end_va;
+
len--;
 
udelay(100);
@@ -236,18 +233,19 @@ static void write_reg8_bus8(struct fbtft_par *par, int 
len, ...)
*buf++ = (u8)va_arg(args, unsigned int);
 
ret = par->fbtftops.write(par, par->buf, len + 1);
-   if (ret < 0) {
-   va_end(args);
-   dev_err(par->info->device,
-   "write() failed and returned %dn", ret);
-   return;
-   }
+   if (ret < 0)
+   goto end_va;
}
va_end(args);
 
/* restore user spi-speed */
par->fbtftops.write = fbtft_write_spi;
udelay(100);
+   return;
+
+end_va:
+   va_end(args);
+   dev_err(par->info->device, "write() failed and returned %dn", ret);
 }
 
 static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: usbduxsigma: Improve unlocking of a mutex in three functions

2017-11-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 2 Nov 2017 21:16:50 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only twice in these function implementations.

* Replace seven calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 48 +++-
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 456e9f13becb..7e8284ed265a 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -672,10 +672,8 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
devpriv->dux_commands[8] = sysred;
 
ret = usbbuxsigma_send_cmd(dev, USBBUXSIGMA_AD_CMD);
-   if (ret < 0) {
-   mutex_unlock(&devpriv->mut);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
devpriv->ai_counter = devpriv->ai_timer;
 
@@ -686,8 +684,7 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
  devpriv->n_ai_urbs, 1);
if (ret < 0) {
devpriv->ai_cmd_running = 0;
-   mutex_unlock(&devpriv->mut);
-   return ret;
+   goto unlock;
}
s->async->inttrig = NULL;
} else {/* TRIG_INT */
@@ -697,6 +694,10 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
mutex_unlock(&devpriv->mut);
 
return 0;
+
+unlock:
+   mutex_unlock(&devpriv->mut);
+   return ret;
 }
 
 static int usbduxsigma_ai_insn_read(struct comedi_device *dev,
@@ -714,8 +715,8 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
 
mutex_lock(&devpriv->mut);
if (devpriv->ai_cmd_running) {
-   mutex_unlock(&devpriv->mut);
-   return -EBUSY;
+   ret = -EBUSY;
+   goto unlock;
}
 
create_adc_command(chan, &muxsg0, &muxsg1);
@@ -730,19 +731,15 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
 
/* adc commands */
ret = usbbuxsigma_send_cmd(dev, USBDUXSIGMA_SINGLE_AD_CMD);
-   if (ret < 0) {
-   mutex_unlock(&devpriv->mut);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
for (i = 0; i < insn->n; i++) {
u32 val;
 
ret = usbduxsigma_receive_cmd(dev, USBDUXSIGMA_SINGLE_AD_CMD);
-   if (ret < 0) {
-   mutex_unlock(&devpriv->mut);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
/* 32 bits big endian from the A/D converter */
val = be32_to_cpu(get_unaligned((__be32
@@ -753,6 +750,10 @@ static int usbduxsigma_ai_insn_read(struct comedi_device 
*dev,
mutex_unlock(&devpriv->mut);
 
return insn->n;
+
+unlock:
+   mutex_unlock(&devpriv->mut);
+   return ret;
 }
 
 static int usbduxsigma_ao_insn_read(struct comedi_device *dev,
@@ -782,8 +783,8 @@ static int usbduxsigma_ao_insn_write(struct comedi_device 
*dev,
 
mutex_lock(&devpriv->mut);
if (devpriv->ao_cmd_running) {
-   mutex_unlock(&devpriv->mut);
-   return -EBUSY;
+   ret = -EBUSY;
+   goto unlock;
}
 
for (i = 0; i < insn->n; i++) {
@@ -791,15 +792,18 @@ static int usbduxsigma_ao_insn_write(struct comedi_device 
*dev,
devpriv->dux_commands[2] = data[i]; /* value */
devpriv->dux_commands[3] = chan;/* channel number */
ret = usbbuxsigma_send_cmd(dev, USBDUXSIGMA_DA_CMD);
-   if (ret < 0) {
-   mutex_unlock(&devpriv->mut);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
+
s->readback[chan] = data[i];
}
mutex_unlock(&devpriv->mut);
 
return insn->n;
+
+unlock:
+   mutex_unlock(&devpriv->mut);
+   return ret;
 }
 
 static int usbduxsigma_ao_inttrig(struct comedi_device *dev,
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: usbduxfast: Improve unlocking of a mutex in usbduxfast_ai_insn_read()

2017-11-02 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 2 Nov 2017 20:30:31 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only twice in this function implementation.

* Replace five calls by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbduxfast.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxfast.c 
b/drivers/staging/comedi/drivers/usbduxfast.c
index 608403c7586b..e5884faf7275 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -777,8 +777,8 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
*dev,
if (devpriv->ai_cmd_running) {
dev_err(dev->class_dev,
"ai_insn_read not possible, async cmd is running\n");
-   mutex_unlock(&devpriv->mut);
-   return -EBUSY;
+   ret = -EBUSY;
+   goto unlock;
}
 
/* set command for the first channel */
@@ -798,10 +798,8 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
*dev,
usbduxfast_cmd_data(dev, 6, 0x01, 0x00, rngmask, 0x00);
 
ret = usbduxfast_send_cmd(dev, SENDADCOMMANDS);
-   if (ret < 0) {
-   mutex_unlock(&devpriv->mut);
-   return ret;
-   }
+   if (ret < 0)
+   goto unlock;
 
for (i = 0; i < PACKETS_TO_IGNORE; i++) {
ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, BULKINEP),
@@ -809,8 +807,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
*dev,
   &actual_length, 1);
if (ret < 0) {
dev_err(dev->class_dev, "insn timeout, no data\n");
-   mutex_unlock(&devpriv->mut);
-   return ret;
+   goto unlock;
}
}
 
@@ -820,14 +817,13 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
*dev,
   &actual_length, 1);
if (ret < 0) {
dev_err(dev->class_dev, "insn data error: %d\n", ret);
-   mutex_unlock(&devpriv->mut);
-   return ret;
+   goto unlock;
}
n = actual_length / sizeof(u16);
if ((n % 16) != 0) {
dev_err(dev->class_dev, "insn data packet corrupted\n");
-   mutex_unlock(&devpriv->mut);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto unlock;
}
for (j = chan; (j < n) && (i < insn->n); j = j + 16) {
data[i] = ((u16 *)(devpriv->inbuf))[j];
@@ -838,6 +834,10 @@ static int usbduxfast_ai_insn_read(struct comedi_device 
*dev,
mutex_unlock(&devpriv->mut);
 
return insn->n;
+
+unlock:
+   mutex_unlock(&devpriv->mut);
+   return ret;
 }
 
 static int usbduxfast_upload_firmware(struct comedi_device *dev,
-- 
2.15.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging/irda/net: Adjustments for several function implementations

2017-10-12 Thread SF Markus Elfring
> Did you read drivers/staging/irda/TODO ?

Yes.

How do recent contributions (by other software developers) fit to information
that is provided in this file?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/10] staging/irda/net: Use seq_puts() in four functions

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 12 Oct 2017 11:08:36 +0200

Strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/ircomm/ircomm_core.c | 8 
 drivers/staging/irda/net/ircomm/ircomm_tty.c  | 2 +-
 drivers/staging/irda/net/irlan/irlan_common.c | 3 +--
 drivers/staging/irda/net/irlmp.c  | 2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/irda/net/ircomm/ircomm_core.c 
b/drivers/staging/irda/net/ircomm/ircomm_core.c
index 6c02fbf380bd..9bb2ff306470 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_core.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_core.c
@@ -530,13 +530,13 @@ static int ircomm_seq_show(struct seq_file *seq, void *v)
   self->slsap_sel, self->dlsap_sel);
 
if(self->service_type & IRCOMM_3_WIRE_RAW)
-   seq_printf(seq, " 3-wire-raw");
+   seq_puts(seq, " 3-wire-raw");
if(self->service_type & IRCOMM_3_WIRE)
-   seq_printf(seq, " 3-wire");
+   seq_puts(seq, " 3-wire");
if(self->service_type & IRCOMM_9_WIRE)
-   seq_printf(seq, " 9-wire");
+   seq_puts(seq, " 9-wire");
if(self->service_type & IRCOMM_CENTRONICS)
-   seq_printf(seq, " Centronics");
+   seq_puts(seq, " Centronics");
seq_putc(seq, '\n');
 
return 0;
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c 
b/drivers/staging/irda/net/ircomm/ircomm_tty.c
index d1beec413fa3..dc7097576917 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
@@ -1174,7 +1174,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb 
*self, struct seq_file *m)
 
seq_printf(m, "Port name: %s\n", self->settings.port_name);
 
-   seq_printf(m, "DTE status:");
+   seq_puts(m, "DTE status:");
sep = ' ';
if (self->settings.dte & IRCOMM_RTS) {
seq_printf(m, "%cRTS", sep);
diff --git a/drivers/staging/irda/net/irlan/irlan_common.c 
b/drivers/staging/irda/net/irlan/irlan_common.c
index 481bbc2a4349..f4633d4dc390 100644
--- a/drivers/staging/irda/net/irlan/irlan_common.c
+++ b/drivers/staging/irda/net/irlan/irlan_common.c
@@ -1138,8 +1138,7 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,"media: %s\n",
   irlan_media[self->media]);
 
-   seq_printf(seq,"local filter:\n");
-   seq_printf(seq,"remote filter: ");
+   seq_puts(seq, "local filter:\nremote filter: ");
irlan_print_filter(seq, self->client.filter_type);
seq_printf(seq,"tx busy: %s\n",
   netif_queue_stopped(self->dev) ? "TRUE" : 
"FALSE");
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 6a09cf621bd4..60a3dd7d6f49 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -1937,7 +1937,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
 * the object spinlock, so we are safe. Jean II */
spin_lock(&lap->lsaps->hb_spinlock);
 
-   seq_printf(seq, "\n  Connected LSAPs:\n");
+   seq_puts(seq, "\n  Connected LSAPs:\n");
for (self = (struct lsap_cb *) hashbin_get_first(lap->lsaps);
 self;
 self = (struct lsap_cb *)hashbin_get_next(lap->lsaps)) {
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/10] staging/irda/net: Combine some seq_printf() calls in two functions

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 12 Oct 2017 08:58:38 +0200

Some data were printed into a sequence by separate function calls.
Print the same data by a single function call at each place instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irlap.c | 9 -
 drivers/staging/irda/net/irlmp.c | 6 ++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/irda/net/irlap.c b/drivers/staging/irda/net/irlap.c
index 715cedab2f41..345c4eb55a59 100644
--- a/drivers/staging/irda/net/irlap.c
+++ b/drivers/staging/irda/net/irlap.c
@@ -1141,9 +1141,9 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "vr: %d ", self->vr);
seq_printf(seq, "va: %d\n", self->va);
 
-   seq_printf(seq, "  
qos\tbps\tmaxtt\tdsize\twinsize\taddbofs\tmintt\tldisc\tcomp\n");
-
-   seq_printf(seq, "  tx\t%d\t",
+   seq_printf(seq,
+  "  
qos\tbps\tmaxtt\tdsize\twinsize\taddbofs\tmintt\tldisc\tcomp\n"
+  "  tx\t%d\t",
   self->qos_tx.baud_rate.value);
seq_printf(seq, "%d\t",
   self->qos_tx.max_turn_time.value);
@@ -1157,9 +1157,8 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
   self->qos_tx.min_turn_time.value);
seq_printf(seq, "%d\t",
   self->qos_tx.link_disc_time.value);
-   seq_printf(seq, "\n");
 
-   seq_printf(seq, "  rx\t%d\t",
+   seq_printf(seq, "\n  rx\t%d\t",
   self->qos_rx.baud_rate.value);
seq_printf(seq, "%d\t",
   self->qos_rx.max_turn_time.value);
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 318660fbc094..6a09cf621bd4 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -1920,8 +1920,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,
   "slsap_sel: %#02x, dlsap_sel: %#02x, ",
   self->slsap_sel, self->dlsap_sel);
-   seq_printf(seq, "(%s)", self->notify.name);
-   seq_printf(seq, "\n");
+   seq_printf(seq, "(%s)\n", self->notify.name);
} else if (iter->hashbin == irlmp->links) {
struct lap_cb *lap = v;
 
@@ -1930,9 +1929,8 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
 
seq_printf(seq, "saddr: %#08x, daddr: %#08x, ",
   lap->saddr, lap->daddr);
-   seq_printf(seq, "num lsaps: %d",
+   seq_printf(seq, "num lsaps: %d\n",
   HASHBIN_GET_SIZE(lap->lsaps));
-   seq_printf(seq, "\n");
 
/* Careful for priority inversions here !
 * All other uses of attrib spinlock are independent of
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/10] staging/irda/net: Use common error handling code in irias_new_object()

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 12 Oct 2017 08:52:53 +0200

Add a jump target so that a bit of exception handling can be better
reused at the end of this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irias_object.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/irda/net/irias_object.c 
b/drivers/staging/irda/net/irias_object.c
index 4c2c65e28836..0c89800d597d 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -54,10 +54,9 @@ struct ias_object *irias_new_object( char *name, int id)
 
obj->magic = IAS_OBJECT_MAGIC;
obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
-   if (!obj->name) {
-   kfree(obj);
-   return NULL;
-   }
+   if (!obj->name)
+   goto free_object;
+
obj->id = id;
 
/* Locking notes : the attrib spinlock has lower precendence
@@ -68,11 +67,14 @@ struct ias_object *irias_new_object( char *name, int id)
net_warn_ratelimited("%s(), Unable to allocate attribs!\n",
 __func__);
kfree(obj->name);
-   kfree(obj);
-   return NULL;
+   goto free_object;
}
 
return obj;
+
+free_object:
+   kfree(obj);
+   return NULL;
 }
 EXPORT_SYMBOL(irias_new_object);
 
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/10] staging/irda/net: Delete an unnecessary variable initialisation in four functions

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 11 Oct 2017 22:26:00 +0200

The variable "tx_skb" will eventually be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irlap_frame.c | 6 +++---
 drivers/staging/irda/net/irttp.c   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/irda/net/irlap_frame.c 
b/drivers/staging/irda/net/irlap_frame.c
index 25ceb06efd58..16fe7f53fdb7 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -258,7 +258,7 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, 
struct qos_info *qos)
  */
 void irlap_send_dm_frame( struct irlap_cb *self)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
struct dm_frame *frame;
 
IRDA_ASSERT(self, return;);
@@ -288,7 +288,7 @@ void irlap_send_dm_frame( struct irlap_cb *self)
  */
 void irlap_send_disc_frame(struct irlap_cb *self)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
struct disc_frame *frame;
 
IRDA_ASSERT(self, return;);
@@ -315,7 +315,7 @@ void irlap_send_disc_frame(struct irlap_cb *self)
 void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
__u8 command, discovery_t *discovery)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
struct xid_frame *frame;
__u32 bcast = BROADCAST;
__u8 *info;
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/irda/net/irttp.c
index 2adba87aeb68..bc612227cdc3 100644
--- a/drivers/staging/irda/net/irttp.c
+++ b/drivers/staging/irda/net/irttp.c
@@ -811,7 +811,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
  */
 static inline void irttp_give_credit(struct tsap_cb *self)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
unsigned long flags;
int n;
 
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/10] staging/irda/net: Delete an unnecessary variable initialisation in two functions

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 11 Oct 2017 22:22:13 +0200

The local variable "tx_skb" will only be used in a single if branch
of these functions. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irlap_frame.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/irda/net/irlap_frame.c 
b/drivers/staging/irda/net/irlap_frame.c
index 5b8be5b9812e..25ceb06efd58 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -862,7 +862,7 @@ void irlap_send_data_primary_poll(struct irlap_cb *self, 
struct sk_buff *skb)
 void irlap_send_data_secondary_final(struct irlap_cb *self,
 struct sk_buff *skb)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
 
IRDA_ASSERT(self, return;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
@@ -922,7 +922,7 @@ void irlap_send_data_secondary_final(struct irlap_cb *self,
  */
 void irlap_send_data_secondary(struct irlap_cb *self, struct sk_buff *skb)
 {
-   struct sk_buff *tx_skb = NULL;
+   struct sk_buff *tx_skb;
 
/* Is this reliable or unreliable data? */
if (skb->data[1] == I_FRAME) {
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discovery_xid_rsp()

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 11 Oct 2017 22:20:22 +0200

The variable "discovery" will eventually be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irlap_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/irda/net/irlap_frame.c 
b/drivers/staging/irda/net/irlap_frame.c
index 33259ed5f3cd..5b8be5b9812e 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -408,7 +408,7 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb 
*self,
 struct irlap_info *info)
 {
struct xid_frame *xid;
-   discovery_t *discovery = NULL;
+   discovery_t *discovery;
__u8 *discovery_info;
char *text;
 
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discovery_xid_cmd()

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 11 Oct 2017 22:18:34 +0200

The local variable "discovery" will only be used in a single if branch
of this function. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irlap_frame.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/irda/net/irlap_frame.c 
b/drivers/staging/irda/net/irlap_frame.c
index 94972db87951..33259ed5f3cd 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -481,7 +481,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb 
*self,
 struct irlap_info *info)
 {
struct xid_frame *xid;
-   discovery_t *discovery = NULL;
+   discovery_t *discovery;
__u8 *discovery_info;
char *text;
 
-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/10] staging/irda/net: Adjust 385 checks for null pointers

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 11 Oct 2017 22:10:26 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.


Use space characters at some places according to the Linux coding
style convention.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/af_irda.c  |  56 ++---
 drivers/staging/irda/net/discovery.c|  31 ---
 drivers/staging/irda/net/irda_device.c  |   2 +-
 drivers/staging/irda/net/iriap.c|  61 +++---
 drivers/staging/irda/net/iriap_event.c  |  34 
 drivers/staging/irda/net/irias_object.c |  62 +++---
 drivers/staging/irda/net/irlap.c|  73 
 drivers/staging/irda/net/irlap_event.c  |  77 +
 drivers/staging/irda/net/irlap_frame.c  |  51 +--
 drivers/staging/irda/net/irlmp.c| 144 +++-
 drivers/staging/irda/net/irlmp_event.c  |  50 ++-
 drivers/staging/irda/net/irlmp_frame.c  |  24 +++---
 drivers/staging/irda/net/irnetlink.c|   2 +-
 drivers/staging/irda/net/irproc.c   |   2 +-
 drivers/staging/irda/net/irqueue.c  |  32 +++
 drivers/staging/irda/net/irsysctl.c |   4 +-
 drivers/staging/irda/net/irttp.c|  68 +++
 drivers/staging/irda/net/parameters.c   |  12 +--
 drivers/staging/irda/net/qos.c  |  20 ++---
 drivers/staging/irda/net/timer.c|  12 +--
 drivers/staging/irda/net/wrapper.c  |   3 +-
 21 files changed, 396 insertions(+), 424 deletions(-)

diff --git a/drivers/staging/irda/net/af_irda.c 
b/drivers/staging/irda/net/af_irda.c
index 23fa7c8b09a5..cb60b89053dd 100644
--- a/drivers/staging/irda/net/af_irda.c
+++ b/drivers/staging/irda/net/af_irda.c
@@ -121,7 +121,7 @@ static void irda_disconnect_indication(void *instance, void 
*sap,
dev_kfree_skb(skb);
 
sk = instance;
-   if (sk == NULL) {
+   if (!sk) {
pr_debug("%s(%p) : BUG : sk is NULL\n",
 __func__, self);
return;
@@ -182,7 +182,7 @@ static void irda_connect_confirm(void *instance, void *sap,
pr_debug("%s(%p)\n", __func__, self);
 
sk = instance;
-   if (sk == NULL) {
+   if (!sk) {
dev_kfree_skb(skb);
return;
}
@@ -246,7 +246,7 @@ static void irda_connect_indication(void *instance, void 
*sap,
pr_debug("%s(%p)\n", __func__, self);
 
sk = instance;
-   if (sk == NULL) {
+   if (!sk) {
dev_kfree_skb(skb);
return;
}
@@ -301,7 +301,7 @@ static void irda_connect_response(struct irda_sock *self)
struct sk_buff *skb;
 
skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER, GFP_KERNEL);
-   if (skb == NULL) {
+   if (!skb) {
pr_debug("%s() Unable to allocate sk_buff!\n",
 __func__);
return;
@@ -326,7 +326,7 @@ static void irda_flow_indication(void *instance, void *sap, 
LOCAL_FLOW flow)
 
self = instance;
sk = instance;
-   BUG_ON(sk == NULL);
+   BUG_ON(!sk);
 
switch (flow) {
case FLOW_STOP:
@@ -434,7 +434,7 @@ static void irda_discovery_timeout(u_long priv)
struct irda_sock *self;
 
self = (struct irda_sock *) priv;
-   BUG_ON(self == NULL);
+   BUG_ON(!self);
 
/* Nothing for the caller */
self->cachelog = NULL;
@@ -473,7 +473,7 @@ static int irda_open_tsap(struct irda_sock *self, __u8 
tsap_sel, char *name)
 
self->tsap = irttp_open_tsap(tsap_sel, DEFAULT_INITIAL_CREDIT,
 ¬ify);
-   if (self->tsap == NULL) {
+   if (!self->tsap) {
pr_debug("%s(), Unable to allocate TSAP!\n",
 __func__);
return -ENOMEM;
@@ -507,7 +507,7 @@ static int irda_open_lsap(struct irda_sock *self, int pid)
strncpy(notify.name, "Ultra", NOTIFY_MAX_NAME);
 
self->lsap = irlmp_open_lsap(LSAP_CONNLESS, ¬ify, pid);
-   if (self->lsap == NULL) {
+   if (!self->lsap) {
pr_debug("%s(), Unable to allocate LSAP!\n", __func__);
return -ENOMEM;
}
@@ -539,7 +539,7 @@ static int irda_find_lsap_sel(struct irda_sock *self, char 
*name)
 
self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
 irda_getvalue_confirm);
-   if(self->iriap == NULL)
+   if (!self->iriap)
return -ENOMEM;
 
/* Treat unexpected wakeup as disconnect */
@@ -625,7 +625,7 @@ static int irda_discover_daddr_and_lsap_sel(struct 
irda_sock *self, char *name)
discoveries = irlmp_get_discoveries(&number, self->mask.word,
self->nslots);
/* Check if the we got so

[PATCH 02/10] staging: irda: Delete ten error messages for a failed memory allocation

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 10 Oct 2017 21:10:43 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/irias_object.c | 24 
 drivers/staging/irda/net/irlap_frame.c  |  4 +---
 drivers/staging/irda/net/irlmp.c|  1 -
 drivers/staging/irda/net/irttp.c|  1 -
 4 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/irda/net/irias_object.c 
b/drivers/staging/irda/net/irias_object.c
index 1064fac2fd36..4db986b9d756 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -49,17 +49,12 @@ struct ias_object *irias_new_object( char *name, int id)
struct ias_object *obj;
 
obj = kzalloc(sizeof(*obj), GFP_ATOMIC);
-   if (obj == NULL) {
-   net_warn_ratelimited("%s(), Unable to allocate object!\n",
-__func__);
+   if (!obj)
return NULL;
-   }
 
obj->magic = IAS_OBJECT_MAGIC;
obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
if (!obj->name) {
-   net_warn_ratelimited("%s(), Unable to allocate name!\n",
-__func__);
kfree(obj);
return NULL;
}
@@ -319,11 +314,8 @@ void irias_add_integer_attrib(struct ias_object *obj, char 
*name, int value,
IRDA_ASSERT(name != NULL, return;);
 
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
-   if (attrib == NULL) {
-   net_warn_ratelimited("%s: Unable to allocate attribute!\n",
-__func__);
+   if (!attrib)
return;
-   }
 
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -363,11 +355,8 @@ void irias_add_octseq_attrib(struct ias_object *obj, char 
*name, __u8 *octets,
IRDA_ASSERT(octets != NULL, return;);
 
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
-   if (attrib == NULL) {
-   net_warn_ratelimited("%s: Unable to allocate attribute!\n",
-__func__);
+   if (!attrib)
return;
-   }
 
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -405,11 +394,8 @@ void irias_add_string_attrib(struct ias_object *obj, char 
*name, char *value,
IRDA_ASSERT(value != NULL, return;);
 
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
-   if (attrib == NULL) {
-   net_warn_ratelimited("%s: Unable to allocate attribute!\n",
-__func__);
+   if (!attrib)
return;
-   }
 
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -470,7 +456,6 @@ struct ias_value *irias_new_string_value(char *string)
value->charset = CS_ASCII;
value->t.string = kstrndup(string, IAS_MAX_STRING, GFP_ATOMIC);
if (!value->t.string) {
-   net_warn_ratelimited("%s: Unable to kmalloc!\n", __func__);
kfree(value);
return NULL;
}
@@ -503,7 +488,6 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int 
len)
 
value->t.oct_seq = kmemdup(octseq, len, GFP_ATOMIC);
if (value->t.oct_seq == NULL){
-   net_warn_ratelimited("%s: Unable to kmalloc!\n", __func__);
kfree(value);
return NULL;
}
diff --git a/drivers/staging/irda/net/irlap_frame.c 
b/drivers/staging/irda/net/irlap_frame.c
index 21891ef7ee33..d4d88a5d2976 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -433,10 +433,8 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb 
*self,
}
 
discovery = kzalloc(sizeof(*discovery), GFP_ATOMIC);
-   if (!discovery) {
-   net_warn_ratelimited("%s: kmalloc failed!\n", __func__);
+   if (!discovery)
return;
-   }
 
discovery->data.daddr = info->daddr;
discovery->data.saddr = self->saddr;
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 38772a3b9df8..f075735e4b9b 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -641,7 +641,6 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void 
*instance)
/* Allocate a new instance */
new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
if (!new)  {
-   pr_debug("%s(), unable to kmalloc\n", __func__);
spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
   flags);
return NULL;
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/

[PATCH 01/10] staging: irda: Improve a size determination in 20 functions

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 10 Oct 2017 19:35:56 +0200

* Replace the specification of data types by pointer dereferences
  as the parameter for the operator "sizeof" to make the corresponding size
  determination a bit safer according to the Linux coding style convention.

  This issue was detected by using the Coccinelle software.

* The script "checkpatch.pl" pointed information out like the following.

  ERROR: do not use assignment in if condition

  Thus fix the affected source code place.

Signed-off-by: Markus Elfring 
---
 drivers/staging/irda/net/ircomm/ircomm_core.c |  2 +-
 drivers/staging/irda/net/ircomm/ircomm_tty.c  |  2 +-
 drivers/staging/irda/net/irias_object.c   | 16 
 drivers/staging/irda/net/irlap.c  |  2 +-
 drivers/staging/irda/net/irlap_frame.c|  7 ---
 drivers/staging/irda/net/irlmp.c  |  8 
 drivers/staging/irda/net/irttp.c  |  4 ++--
 7 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/irda/net/ircomm/ircomm_core.c 
b/drivers/staging/irda/net/ircomm/ircomm_core.c
index 3af219545f6d..6c02fbf380bd 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_core.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_core.c
@@ -114,7 +114,7 @@ struct ircomm_cb *ircomm_open(notify_t *notify, __u8 
service_type, int line)
 
IRDA_ASSERT(ircomm != NULL, return NULL;);
 
-   self = kzalloc(sizeof(struct ircomm_cb), GFP_KERNEL);
+   self = kzalloc(sizeof(*self), GFP_KERNEL);
if (self == NULL)
return NULL;
 
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c 
b/drivers/staging/irda/net/ircomm/ircomm_tty.c
index ec157c3419b5..d1beec413fa3 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
@@ -380,7 +380,7 @@ static int ircomm_tty_install(struct tty_driver *driver, 
struct tty_struct *tty)
self = hashbin_lock_find(ircomm_tty, line, NULL);
if (!self) {
/* No, so make new instance */
-   self = kzalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);
+   self = kzalloc(sizeof(*self), GFP_KERNEL);
if (self == NULL)
return -ENOMEM;
 
diff --git a/drivers/staging/irda/net/irias_object.c 
b/drivers/staging/irda/net/irias_object.c
index 53b86d0e1630..1064fac2fd36 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -48,7 +48,7 @@ struct ias_object *irias_new_object( char *name, int id)
 {
struct ias_object *obj;
 
-   obj = kzalloc(sizeof(struct ias_object), GFP_ATOMIC);
+   obj = kzalloc(sizeof(*obj), GFP_ATOMIC);
if (obj == NULL) {
net_warn_ratelimited("%s(), Unable to allocate object!\n",
 __func__);
@@ -318,7 +318,7 @@ void irias_add_integer_attrib(struct ias_object *obj, char 
*name, int value,
IRDA_ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;);
IRDA_ASSERT(name != NULL, return;);
 
-   attrib = kzalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
+   attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib == NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
 __func__);
@@ -362,7 +362,7 @@ void irias_add_octseq_attrib(struct ias_object *obj, char 
*name, __u8 *octets,
IRDA_ASSERT(name != NULL, return;);
IRDA_ASSERT(octets != NULL, return;);
 
-   attrib = kzalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
+   attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib == NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
 __func__);
@@ -404,7 +404,7 @@ void irias_add_string_attrib(struct ias_object *obj, char 
*name, char *value,
IRDA_ASSERT(name != NULL, return;);
IRDA_ASSERT(value != NULL, return;);
 
-   attrib = kzalloc(sizeof( struct ias_attrib), GFP_ATOMIC);
+   attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib == NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
 __func__);
@@ -439,7 +439,7 @@ struct ias_value *irias_new_integer_value(int integer)
 {
struct ias_value *value;
 
-   value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+   value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value == NULL)
return NULL;
 
@@ -462,7 +462,7 @@ struct ias_value *irias_new_string_value(char *string)
 {
struct ias_value *value;
 
-   value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+   value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value == NULL)
return NULL;
 
@@ -491,7 +491,7 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int 
len)
 {
struct ias_value *value;
 
-   value = kzallo

[PATCH 00/10] staging/irda/net: Adjustments for several function implementations

2017-10-12 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 12 Oct 2017 11:25:43 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (10):
  Improve a size determination in 20 functions
  Delete ten error messages for a failed memory allocation
  Adjust 385 checks for null pointers
  Delete an unnecessary variable initialisation in 
irlap_recv_discovery_xid_cmd()
  Delete an unnecessary variable initialisation in 
irlap_recv_discovery_xid_rsp()
  Delete an unnecessary variable initialisation in two functions
  Delete an unnecessary variable initialisation in four functions
  Use common error handling code in irias_new_object()
  Combine some seq_printf() calls in two functions
  Use seq_puts() in four functions

 drivers/staging/irda/net/af_irda.c|  56 +
 drivers/staging/irda/net/discovery.c  |  31 +++--
 drivers/staging/irda/net/ircomm/ircomm_core.c |  10 +-
 drivers/staging/irda/net/ircomm/ircomm_tty.c  |   4 +-
 drivers/staging/irda/net/irda_device.c|   2 +-
 drivers/staging/irda/net/iriap.c  |  61 +-
 drivers/staging/irda/net/iriap_event.c|  34 +++---
 drivers/staging/irda/net/irias_object.c   | 116 ---
 drivers/staging/irda/net/irlan/irlan_common.c |   3 +-
 drivers/staging/irda/net/irlap.c  |  84 +++---
 drivers/staging/irda/net/irlap_event.c|  77 ++--
 drivers/staging/irda/net/irlap_frame.c|  74 ++--
 drivers/staging/irda/net/irlmp.c  | 161 --
 drivers/staging/irda/net/irlmp_event.c|  50 
 drivers/staging/irda/net/irlmp_frame.c|  24 ++--
 drivers/staging/irda/net/irnetlink.c  |   2 +-
 drivers/staging/irda/net/irproc.c |   2 +-
 drivers/staging/irda/net/irqueue.c|  32 ++---
 drivers/staging/irda/net/irsysctl.c   |   4 +-
 drivers/staging/irda/net/irttp.c  |  75 ++--
 drivers/staging/irda/net/parameters.c |  12 +-
 drivers/staging/irda/net/qos.c|  20 ++--
 drivers/staging/irda/net/timer.c  |  12 +-
 drivers/staging/irda/net/wrapper.c|   3 +-
 24 files changed, 450 insertions(+), 499 deletions(-)

-- 
2.14.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-30 Thread SF Markus Elfring
 @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
 struct pci_device_id *id)
  master_num--;

  tsi148_device->flush_image =
 -kmalloc(sizeof(struct vme_master_resource), 
 GFP_KERNEL);
 +kmalloc(sizeof(*tsi148_device->flush_image), 
 GFP_KERNEL);
>>>
>>> This line is now a tiny bit too long
>>
>> Can you eventually tolerate a line length of 81 characters at such a source 
>> code place?
>>
> 
> I think there's some irony here. On the one hand you are submitting
> patches that correct coding style issues, on the other you are asking
> whether we can ignore the coding style...

I test somehow how strict you would like to handle the length limit there.

I imagine that the affected source code formatting could also become different
if the involved variable name would be shorter.


>> * It seems that you would not like to perform such a tweak yourself.
> 
> To be honest, it is quicker and easier in this instance to do just that.

Interesting …


> So that's now done.

Thanks that you picked some of my ideas up.


> Patches now in my testing branch:
> 
> https://gitlab.collabora.com/martyn/linux/commits/vme-testing

I am curious on how the shown change possibilities will evolve from
this repository.


>> * Do you expect a resend for the complete patch series?
>>
> 
> Unless the maintainer has commented that they have accepted patches x,
> y and z, then sending the entire series again is generally the right
> thing to do.

Would you like to respond further to Greg's comments (from 2017-08-26)
for this patch series?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: netlogic: Delete an error message for a failed memory allocation in xlr_config_spill()

2017-08-26 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 26 Aug 2017 18:44:12 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/netlogic/xlr_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/netlogic/xlr_net.c 
b/drivers/staging/netlogic/xlr_net.c
index e05ae4645d91..04cdcf3f329f 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -423,10 +423,8 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, 
int reg_start_0,
base = priv->base_addr;
spill_size = size;
spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_ATOMIC);
-   if (!spill) {
-   pr_err("Unable to allocate memory for spill area!\n");
+   if (!spill)
return ZERO_SIZE_PTR;
-   }
 
spill = PTR_ALIGN(spill, SMP_CACHE_BYTES);
phys_addr = virt_to_phys(spill);
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fsl-mc: Delete an error message for a failed memory allocation in fsl_mc_resource_pool_add_device()

2017-08-26 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 26 Aug 2017 18:23:52 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/fsl-mc/bus/fsl-mc-allocator.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c 
b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
index b37a6f48225f..53312e32d94a 100644
--- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
+++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c
@@ -66,8 +66,6 @@ static int __must_check 
fsl_mc_resource_pool_add_device(struct fsl_mc_bus
GFP_KERNEL);
if (!resource) {
error = -ENOMEM;
-   dev_err(&mc_bus_dev->dev,
-   "Failed to allocate memory for fsl_mc_resource\n");
goto out_unlock;
}
 
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-26 Thread SF Markus Elfring
>> @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
>> struct pci_device_id *id)
>>  master_num--;
>>  
>>  tsi148_device->flush_image =
>> -kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
>> +kmalloc(sizeof(*tsi148_device->flush_image), 
>> GFP_KERNEL);
> 
> This line is now a tiny bit too long

Can you eventually tolerate a line length of 81 characters at such a source 
code place?


> and needs to be broken over two lines.

How would like to achieve this?

* It seems that you would not like to perform such a tweak yourself.

* Do you expect a resend for the complete patch series?

* Will it be sufficient to send another patch only for the requested 
reformatting
  of a single line?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/14] vme: tsi148: Adjust 14 checks for null pointers

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 12:00:17 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_tsi148.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index 61946f5d356f..cba9514605b7 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -748,9 +748,9 @@ static int tsi148_alloc_resource(struct vme_master_resource 
*image,
if (size == 0)
return 0;
 
-   if (image->bus_resource.name == NULL) {
+   if (!image->bus_resource.name) {
image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
-   if (image->bus_resource.name == NULL) {
+   if (!image->bus_resource.name) {
retval = -ENOMEM;
goto err_name;
}
@@ -776,7 +776,7 @@ static int tsi148_alloc_resource(struct vme_master_resource 
*image,
 
image->kern_base = ioremap_nocache(
image->bus_resource.start, size);
-   if (image->kern_base == NULL) {
+   if (!image->kern_base) {
dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
retval = -ENOMEM;
goto err_remap;
@@ -1640,7 +1640,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
 
/* Descriptor must be aligned on 64-bit boundaries */
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
-   if (entry == NULL) {
+   if (!entry) {
retval = -ENOMEM;
goto err_mem;
}
@@ -1943,7 +1943,7 @@ static int tsi148_lm_set(struct vme_lm_resource *lm, 
unsigned long long lm_base,
 
/* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) {
-   if (bridge->lm_callback[i] != NULL) {
+   if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx);
dev_err(tsi148_bridge->parent, "Location monitor "
"callback attached, can't reset\n");
@@ -2068,7 +2068,7 @@ static int tsi148_lm_attach(struct vme_lm_resource *lm, 
int monitor,
}
 
/* Check that a callback isn't already attached */
-   if (bridge->lm_callback[monitor] != NULL) {
+   if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx);
dev_err(tsi148_bridge->parent, "Existing callback attached\n");
return -EBUSY;
@@ -2205,7 +2205,7 @@ static int tsi148_crcsr_init(struct vme_bridge 
*tsi148_bridge,
/* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
 &bridge->crcsr_bus);
-   if (bridge->crcsr_kernel == NULL) {
+   if (!bridge->crcsr_kernel) {
dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
"CR/CSR image\n");
return -ENOMEM;
@@ -2292,14 +2292,14 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 * dynamically generate this so we get one per device
 */
tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL);
-   if (tsi148_bridge == NULL) {
+   if (!tsi148_bridge) {
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(tsi148_bridge);
 
tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL);
-   if (tsi148_device == NULL) {
+   if (!tsi148_device) {
retval = -ENOMEM;
goto err_driver;
}
@@ -2365,7 +2365,7 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
tsi148_device->flush_image =
kmalloc(sizeof(*tsi148_device->flush_image), 
GFP_KERNEL);
-   if (tsi148_device->flush_image == NULL) {
+   if (!tsi148_device->flush_image) {
retval = -ENOMEM;
goto err_master;
}
@@ -2381,7 +2381,7 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* Add master windows to list */
for (i = 0; i < master_num; i++) {
master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
-   if (master_image == NULL) {
+   if (!master_image) {
retval = -ENOMEM;
goto err_master;
}
@@ -2407,7 +2407,7 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* Add slave windows to l

[PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 11:55:03 +0200

Replace the specification of data structures by variable references
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_tsi148.c | 36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index fb91fddc6312..61946f5d356f 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -741,7 +741,7 @@ static int tsi148_alloc_resource(struct vme_master_resource 
*image,
image->kern_base = NULL;
kfree(image->bus_resource.name);
release_resource(&image->bus_resource);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
}
 
/* Exit here if size is zero */
@@ -788,7 +788,7 @@ static int tsi148_alloc_resource(struct vme_master_resource 
*image,
release_resource(&image->bus_resource);
 err_resource:
kfree(image->bus_resource.name);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
 err_name:
return retval;
 }
@@ -802,7 +802,7 @@ static void tsi148_free_resource(struct vme_master_resource 
*image)
image->kern_base = NULL;
release_resource(&image->bus_resource);
kfree(image->bus_resource.name);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
 }
 
 /*
@@ -1639,5 +1639,5 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
tsi148_bridge = list->parent->parent;
 
/* Descriptor must be aligned on 64-bit boundaries */
-   entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL);
+   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL) {
@@ -1657,7 +1657,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
/* Given we are going to fill out the structure, we probably don't
 * need to zero it, but better safe than sorry for now.
 */
-   memset(&entry->descriptor, 0, sizeof(struct tsi148_dma_descriptor));
+   memset(&entry->descriptor, 0, sizeof(entry->descriptor));
 
/* Fill out source part */
switch (src->type) {
@@ -1752,8 +1752,9 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
list_add_tail(&entry->list, &list->entries);
 
entry->dma_handle = dma_map_single(tsi148_bridge->parent,
-   &entry->descriptor,
-   sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
+  &entry->descriptor,
+  sizeof(entry->descriptor),
+  DMA_TO_DEVICE);
if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
dev_err(tsi148_bridge->parent, "DMA mapping error\n");
retval = -EINVAL;
@@ -2290,12 +2291,12 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* If we want to support more than one of each bridge, we need to
 * dynamically generate this so we get one per device
 */
-   tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
+   tsi148_bridge = kzalloc(sizeof(*tsi148_bridge), GFP_KERNEL);
if (tsi148_bridge == NULL) {
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(tsi148_bridge);
 
-   tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL);
+   tsi148_device = kzalloc(sizeof(*tsi148_device), GFP_KERNEL);
if (tsi148_device == NULL) {
@@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
master_num--;
 
tsi148_device->flush_image =
-   kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
+   kmalloc(sizeof(*tsi148_device->flush_image), 
GFP_KERNEL);
if (tsi148_device->flush_image == NULL) {
@@ -2373,12 +2374,11 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
tsi148_device->flush_image->locked = 1;
tsi148_device->flush_image->number = master_num;
memset(&tsi148_device->flush_image->bus_resource, 0,
-   sizeof(struct resource));
+  sizeof(tsi148_device->flush_image->bus_resource));
tsi148_device->flush_image->kern_base  = NULL;
}
 
/* Add master windows to list */
for (i = 0; i < master_num; i++) {
-   master_image = k

[PATCH 12/14] vme: tsi148: Delete nine error messages for a failed memory allocation

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 11:10:07 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_tsi148.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c
index fc1b634b969a..fb91fddc6312 100644
--- a/drivers/vme/bridges/vme_tsi148.c
+++ b/drivers/vme/bridges/vme_tsi148.c
@@ -754,5 +754,3 @@ static int tsi148_alloc_resource(struct vme_master_resource 
*image,
-   dev_err(tsi148_bridge->parent, "Unable to allocate "
-   "memory for resource name\n");
retval = -ENOMEM;
goto err_name;
}
@@ -1646,5 +1644,3 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
-   dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
-   "dma resource structure\n");
retval = -ENOMEM;
goto err_mem;
}
@@ -2299,5 +2295,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for device "
-   "structure\n");
retval = -ENOMEM;
goto err_struct;
}
@@ -2308,5 +2302,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for device "
-   "structure\n");
retval = -ENOMEM;
goto err_driver;
}
@@ -2376,5 +2368,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "flush resource structure\n");
retval = -ENOMEM;
goto err_master;
}
@@ -2395,5 +2385,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "master resource structure\n");
retval = -ENOMEM;
goto err_master;
}
@@ -2424,5 +2412,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "slave resource structure\n");
retval = -ENOMEM;
goto err_slave;
}
@@ -2448,5 +2434,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "dma resource structure\n");
retval = -ENOMEM;
goto err_dma;
}
@@ -2470,5 +2454,3 @@ static int tsi148_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "location monitor resource structure\n");
retval = -ENOMEM;
goto err_lm;
}
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/14] vme: ca91cx42: Adjust 14 checks for null pointers

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 11:01:29 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_ca91cx42.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index 61990c7f4543..5dd284008630 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -511,7 +511,7 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
ca91cx42_bridge = image->parent;
 
/* Find pci_dev container of dev */
-   if (ca91cx42_bridge->parent == NULL) {
+   if (!ca91cx42_bridge->parent) {
dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n");
return -EINVAL;
}
@@ -532,9 +532,9 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
memset(&image->bus_resource, 0, sizeof(image->bus_resource));
}
 
-   if (image->bus_resource.name == NULL) {
+   if (!image->bus_resource.name) {
image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
-   if (image->bus_resource.name == NULL) {
+   if (!image->bus_resource.name) {
retval = -ENOMEM;
goto err_name;
}
@@ -560,7 +560,7 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
 
image->kern_base = ioremap_nocache(
image->bus_resource.start, size);
-   if (image->kern_base == NULL) {
+   if (!image->kern_base) {
dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n");
retval = -ENOMEM;
goto err_remap;
@@ -1035,7 +1035,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list 
*list,
 
/* XXX descriptor must be aligned on 64-bit boundaries */
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
-   if (entry == NULL) {
+   if (!entry) {
retval = -ENOMEM;
goto err_mem;
}
@@ -1319,7 +1319,7 @@ static int ca91cx42_lm_set(struct vme_lm_resource *lm,
 
/* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) {
-   if (bridge->lm_callback[i] != NULL) {
+   if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx);
dev_err(dev, "Location monitor callback attached, "
"can't reset\n");
@@ -1428,7 +1428,7 @@ static int ca91cx42_lm_attach(struct vme_lm_resource *lm, 
int monitor,
}
 
/* Check that a callback isn't already attached */
-   if (bridge->lm_callback[monitor] != NULL) {
+   if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx);
dev_err(dev, "Existing callback attached\n");
return -EBUSY;
@@ -1563,7 +1563,7 @@ static int ca91cx42_crcsr_init(struct vme_bridge 
*ca91cx42_bridge,
/* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
 &bridge->crcsr_bus);
-   if (bridge->crcsr_kernel == NULL) {
+   if (!bridge->crcsr_kernel) {
dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
"image\n");
return -ENOMEM;
@@ -1615,14 +1615,14 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 * dynamically allocate the bridge structure
 */
ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
-   if (ca91cx42_bridge == NULL) {
+   if (!ca91cx42_bridge) {
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(ca91cx42_bridge);
 
ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
-   if (ca91cx42_device == NULL) {
+   if (!ca91cx42_device) {
retval = -ENOMEM;
goto err_driver;
}
@@ -1679,7 +1679,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* Add master windows to list */
for (i = 0; i < CA91C142_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
-   if (master_image == NULL) {
+   if (!master_image) {
retval = -ENOMEM;
goto err_master;
}
@@ -1702,7 +1702,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* Add slave windows to list */
for (i = 0; i < CA91C142_MAX_S

[PATCH 10/14] vme: ca91cx42: Improve 12 size determinations

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 10:56:41 +0200

Replace the specification of data structures by variable references
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_ca91cx42.c | 29 -
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index d25f997e8aeb..61990c7f4543 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -529,7 +529,7 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
image->kern_base = NULL;
kfree(image->bus_resource.name);
release_resource(&image->bus_resource);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
}
 
if (image->bus_resource.name == NULL) {
@@ -572,7 +572,7 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
release_resource(&image->bus_resource);
 err_resource:
kfree(image->bus_resource.name);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
 err_name:
return retval;
 }
@@ -586,7 +586,7 @@ static void ca91cx42_free_resource(struct 
vme_master_resource *image)
image->kern_base = NULL;
release_resource(&image->bus_resource);
kfree(image->bus_resource.name);
-   memset(&image->bus_resource, 0, sizeof(struct resource));
+   memset(&image->bus_resource, 0, sizeof(image->bus_resource));
 }
 
 
@@ -1034,5 +1034,5 @@ static int ca91cx42_dma_list_add(struct vme_dma_list 
*list,
dev = list->parent->parent->parent;
 
/* XXX descriptor must be aligned on 64-bit boundaries */
-   entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL);
+   entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry == NULL) {
@@ -1048,7 +1048,7 @@ static int ca91cx42_dma_list_add(struct vme_dma_list 
*list,
goto err_align;
}
 
-   memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor));
+   memset(&entry->descriptor, 0, sizeof(entry->descriptor));
 
if (dest->type == VME_DMA_VME) {
entry->descriptor.dctl |= CA91CX42_DCTL_L2V;
@@ -1614,14 +1614,12 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
/* We want to support more than one of each bridge so we need to
 * dynamically allocate the bridge structure
 */
-   ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
-
+   ca91cx42_bridge = kzalloc(sizeof(*ca91cx42_bridge), GFP_KERNEL);
if (ca91cx42_bridge == NULL) {
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(ca91cx42_bridge);
 
-   ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL);
-
+   ca91cx42_device = kzalloc(sizeof(*ca91cx42_device), GFP_KERNEL);
if (ca91cx42_device == NULL) {
@@ -1680,6 +1678,5 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
/* Add master windows to list */
for (i = 0; i < CA91C142_MAX_MASTER; i++) {
-   master_image = kmalloc(sizeof(struct vme_master_resource),
-   GFP_KERNEL);
+   master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
if (master_image == NULL) {
@@ -1696,7 +1693,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
VME_SUPER | VME_USER | VME_PROG | VME_DATA;
master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64;
memset(&master_image->bus_resource, 0,
-   sizeof(struct resource));
+  sizeof(master_image->bus_resource));
master_image->kern_base  = NULL;
list_add_tail(&master_image->list,
&ca91cx42_bridge->master_resources);
@@ -1704,6 +1701,5 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
/* Add slave windows to list */
for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
-   slave_image = kmalloc(sizeof(struct vme_slave_resource),
-   GFP_KERNEL);
+   slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
if (slave_image == NULL) {
@@ -1729,6 +1725,5 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
 
/* Add dma engines to list */
for (i = 0; i < CA91C142_MAX_DMA; i++) {
-   dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
- 

[PATCH 09/14] vme: ca91cx42: Delete eight error messages for a failed memory allocation

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 10:20:03 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_ca91cx42.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
b/drivers/vme/bridges/vme_ca91cx42.c
index 7cc51223db1c..d25f997e8aeb 100644
--- a/drivers/vme/bridges/vme_ca91cx42.c
+++ b/drivers/vme/bridges/vme_ca91cx42.c
@@ -538,5 +538,3 @@ static int ca91cx42_alloc_resource(struct 
vme_master_resource *image,
-   dev_err(ca91cx42_bridge->parent, "Unable to allocate "
-   "memory for resource name\n");
retval = -ENOMEM;
goto err_name;
}
@@ -1041,5 +1039,3 @@ static int ca91cx42_dma_list_add(struct vme_dma_list 
*list,
-   dev_err(dev, "Failed to allocate memory for dma resource "
-   "structure\n");
retval = -ENOMEM;
goto err_mem;
}
@@ -1624,5 +1620,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for device "
-   "structure\n");
retval = -ENOMEM;
goto err_struct;
}
@@ -1634,5 +1628,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for device "
-   "structure\n");
retval = -ENOMEM;
goto err_driver;
}
@@ -1694,5 +1686,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "master resource structure\n");
retval = -ENOMEM;
goto err_master;
}
@@ -1720,5 +1710,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "slave resource structure\n");
retval = -ENOMEM;
goto err_slave;
}
@@ -1747,5 +1735,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "dma resource structure\n");
retval = -ENOMEM;
goto err_dma;
}
@@ -1767,5 +1753,3 @@ static int ca91cx42_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
-   dev_err(&pdev->dev, "Failed to allocate memory for "
-   "location monitor resource structure\n");
retval = -ENOMEM;
goto err_lm;
}
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/14] vme: fake: Adjust 11 checks for null pointers

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 10:01:16 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_fake.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 39f84df44557..7d83691047f4 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -409,7 +409,7 @@ static void fake_lm_check(struct fake_driver *bridge, 
unsigned long long addr,
/* Each location monitor covers 8 bytes */
if (((lm_base + (8 * i)) <= addr) &&
((lm_base + (8 * i) + 8) > addr)) {
-   if (bridge->lm_callback[i] != NULL)
+   if (bridge->lm_callback[i])
bridge->lm_callback[i](
bridge->lm_data[i]);
}
@@ -866,7 +866,7 @@ static int fake_lm_set(struct vme_lm_resource *lm, unsigned 
long long lm_base,
 
/* If we already have a callback attached, we can't move it! */
for (i = 0; i < lm->monitors; i++) {
-   if (bridge->lm_callback[i] != NULL) {
+   if (bridge->lm_callback[i]) {
mutex_unlock(&lm->mtx);
pr_err("Location monitor callback attached, can't 
reset\n");
return -EBUSY;
@@ -940,7 +940,7 @@ static int fake_lm_attach(struct vme_lm_resource *lm, int 
monitor,
}
 
/* Check that a callback isn't already attached */
-   if (bridge->lm_callback[monitor] != NULL) {
+   if (bridge->lm_callback[monitor]) {
mutex_unlock(&lm->mtx);
pr_err("Existing callback attached\n");
return -EBUSY;
@@ -978,7 +978,7 @@ static int fake_lm_detach(struct vme_lm_resource *lm, int 
monitor)
/* If all location monitors disabled, disable global Location Monitor */
tmp = 0;
for (i = 0; i < lm->monitors; i++) {
-   if (bridge->lm_callback[i] != NULL)
+   if (bridge->lm_callback[i])
tmp = 1;
}
 
@@ -1003,7 +1003,7 @@ static void *fake_alloc_consistent(struct device *parent, 
size_t size,
 {
void *alloc = kmalloc(size, GFP_KERNEL);
 
-   if (alloc != NULL)
+   if (alloc)
*dma = fake_ptr_to_pci(alloc);
 
return alloc;
@@ -1039,7 +1039,7 @@ static int fake_crcsr_init(struct vme_bridge *fake_bridge)
/* Allocate mem for CR/CSR image */
bridge->crcsr_kernel = kzalloc(VME_CRCSR_BUF_SIZE, GFP_KERNEL);
bridge->crcsr_bus = fake_ptr_to_pci(bridge->crcsr_kernel);
-   if (bridge->crcsr_kernel == NULL)
+   if (!bridge->crcsr_kernel)
return -ENOMEM;
 
vstat = fake_slot_get(fake_bridge);
@@ -1076,13 +1076,13 @@ static int __init fake_init(void)
 * dynamically allocate this so we get one per device.
 */
fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
-   if (fake_bridge == NULL) {
+   if (!fake_bridge) {
retval = -ENOMEM;
goto err_struct;
}
 
fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
-   if (fake_device == NULL) {
+   if (!fake_device) {
retval = -ENOMEM;
goto err_driver;
}
@@ -1105,7 +1105,7 @@ static int __init fake_init(void)
INIT_LIST_HEAD(&fake_bridge->master_resources);
for (i = 0; i < FAKE_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
-   if (master_image == NULL) {
+   if (!master_image) {
retval = -ENOMEM;
goto err_master;
}
@@ -1131,7 +1131,7 @@ static int __init fake_init(void)
INIT_LIST_HEAD(&fake_bridge->slave_resources);
for (i = 0; i < FAKE_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
-   if (slave_image == NULL) {
+   if (!slave_image) {
retval = -ENOMEM;
goto err_slave;
}
@@ -1153,7 +1153,7 @@ static int __init fake_init(void)
/* Add location monitor to list */
INIT_LIST_HEAD(&fake_bridge->lm_resources);
lm = kmalloc(sizeof(*lm), GFP_KERNEL);
-   if (lm == NULL) {
+   if (!lm) {
retval = -ENOMEM;
goto err_lm;
}
-- 
2.14.0

___
devel mailing list
de...@linuxdrive

[PATCH 07/14] vme: fake: Improve five size determinations in fake_init()

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 09:46:13 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_fake.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 6ceea5e9fd8b..39f84df44557 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -1075,11 +1075,11 @@ static int __init fake_init(void)
/* If we want to support more than one bridge at some point, we need to
 * dynamically allocate this so we get one per device.
 */
-   fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
+   fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
if (fake_bridge == NULL) {
retval = -ENOMEM;
goto err_struct;
}
 
-   fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL);
+   fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
if (fake_device == NULL) {
@@ -1104,6 +1104,5 @@ static int __init fake_init(void)
/* Add master windows to list */
INIT_LIST_HEAD(&fake_bridge->master_resources);
for (i = 0; i < FAKE_MAX_MASTER; i++) {
-   master_image = kmalloc(sizeof(struct vme_master_resource),
-   GFP_KERNEL);
+   master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
if (master_image == NULL) {
@@ -1131,6 +1130,5 @@ static int __init fake_init(void)
/* Add slave windows to list */
INIT_LIST_HEAD(&fake_bridge->slave_resources);
for (i = 0; i < FAKE_MAX_SLAVE; i++) {
-   slave_image = kmalloc(sizeof(struct vme_slave_resource),
-   GFP_KERNEL);
+   slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
if (slave_image == NULL) {
@@ -1154,5 +1152,5 @@ static int __init fake_init(void)
 
/* Add location monitor to list */
INIT_LIST_HEAD(&fake_bridge->lm_resources);
-   lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
+   lm = kmalloc(sizeof(*lm), GFP_KERNEL);
if (lm == NULL) {
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/14] vme: fake: Delete an error message for a failed memory allocation in fake_init()

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 09:31:46 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/bridges/vme_fake.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index 30b3acc93833..6ceea5e9fd8b 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -1159,4 +1159,3 @@ static int __init fake_init(void)
-   pr_err("Failed to allocate memory for location monitor resource 
structure\n");
retval = -ENOMEM;
goto err_lm;
}
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/14] vme: Return directly in two functions

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 24 Aug 2017 22:32:14 +0200

Return directly without using an intermediate local variable
in these functions.

Signed-off-by: Markus Elfring 
---
 drivers/vme/vme.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index a2e36e6a0d84..986799d64993 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1996,28 +1996,26 @@ static int vme_bus_match(struct device *dev, struct 
device_driver *drv)
 
 static int vme_bus_probe(struct device *dev)
 {
-   int retval = -ENODEV;
struct vme_driver *driver;
struct vme_dev *vdev = dev_to_vme_dev(dev);
 
driver = dev->platform_data;
if (driver->probe)
-   retval = driver->probe(vdev);
+   return driver->probe(vdev);
 
-   return retval;
+   return -ENODEV;
 }
 
 static int vme_bus_remove(struct device *dev)
 {
-   int retval = -ENODEV;
struct vme_driver *driver;
struct vme_dev *vdev = dev_to_vme_dev(dev);
 
driver = dev->platform_data;
if (driver->remove)
-   retval = driver->remove(vdev);
+   return driver->remove(vdev);
 
-   return retval;
+   return -ENODEV;
 }
 
 struct bus_type vme_bus_type = {
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/14] vme: Improve 11 size determinations

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 24 Aug 2017 21:52:00 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/vme.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 53e87af8e0b8..1afddf5eafd4 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -337,4 +337,4 @@ struct vme_resource *vme_slave_request(struct vme_dev 
*vdev, u32 address,
goto err_image;
 
-   resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
+   resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (!resource)
@@ -540,5 +540,5 @@ struct vme_resource *vme_master_request(struct vme_dev 
*vdev, u32 address,
goto err_image;
}
 
-   resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
+   resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (!resource)
@@ -917,4 +917,4 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, 
u32 route)
goto err_ctrlr;
 
-   resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
+   resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (!resource)
@@ -958,5 +958,5 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource 
*resource)
 
ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
 
-   dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
+   dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
if (!dma_list)
@@ -986,9 +986,9 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, 
u32 type)
struct vme_dma_attr *attributes;
struct vme_dma_pattern *pattern_attr;
 
-   attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
+   attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
if (!attributes)
goto err_attr;
 
-   pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL);
+   pattern_attr = kmalloc(sizeof(*pattern_attr), GFP_KERNEL);
if (!pattern_attr)
@@ -1026,9 +1026,9 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t 
address)
 
/* XXX Run some sanity checks here */
 
-   attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
+   attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
if (!attributes)
goto err_attr;
 
-   pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL);
+   pci_attr = kmalloc(sizeof(*pci_attr), GFP_KERNEL);
if (!pci_attr)
@@ -1067,10 +1067,9 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long 
long address,
struct vme_dma_attr *attributes;
struct vme_dma_vme *vme_attr;
 
-   attributes = kmalloc(
-   sizeof(struct vme_dma_attr), GFP_KERNEL);
+   attributes = kmalloc(sizeof(*attributes), GFP_KERNEL);
if (!attributes)
goto err_attr;
 
-   vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL);
+   vme_attr = kmalloc(sizeof(*vme_attr), GFP_KERNEL);
if (!vme_attr)
@@ -1521,4 +1520,4 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
goto err_lm;
 
-   resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
+   resource = kmalloc(sizeof(*resource), GFP_KERNEL);
if (!resource)
@@ -1869,5 +1868,5 @@ static int __vme_register_driver_bus(struct vme_driver 
*drv,
struct vme_dev *tmp;
 
for (i = 0; i < ndevs; i++) {
-   vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL);
+   vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
if (!vdev) {
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/14] vme: Adjust 48 checks for null pointers

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 24 Aug 2017 22:24:38 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/vme/vme.c | 101 ++
 1 file changed, 48 insertions(+), 53 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index d890410e472d..a2e36e6a0d84 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -92,23 +92,23 @@ void *vme_alloc_consistent(struct vme_resource *resource, 
size_t size,
 {
struct vme_bridge *bridge;
 
-   if (resource == NULL) {
+   if (!resource) {
printk(KERN_ERR "No resource\n");
return NULL;
}
 
bridge = find_bridge(resource);
-   if (bridge == NULL) {
+   if (!bridge) {
printk(KERN_ERR "Can't find bridge\n");
return NULL;
}
 
-   if (bridge->parent == NULL) {
+   if (!bridge->parent) {
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
return NULL;
}
 
-   if (bridge->alloc_consistent == NULL) {
+   if (!bridge->alloc_consistent) {
printk(KERN_ERR "alloc_consistent not supported by bridge %s\n",
   bridge->name);
return NULL;
@@ -132,23 +132,23 @@ void vme_free_consistent(struct vme_resource *resource, 
size_t size,
 {
struct vme_bridge *bridge;
 
-   if (resource == NULL) {
+   if (!resource) {
printk(KERN_ERR "No resource\n");
return;
}
 
bridge = find_bridge(resource);
-   if (bridge == NULL) {
+   if (!bridge) {
printk(KERN_ERR "Can't find bridge\n");
return;
}
 
-   if (bridge->parent == NULL) {
+   if (!bridge->parent) {
printk(KERN_ERR "Dev entry NULL for bridge %s\n", bridge->name);
return;
}
 
-   if (bridge->free_consistent == NULL) {
+   if (!bridge->free_consistent) {
printk(KERN_ERR "free_consistent not supported by bridge %s\n",
   bridge->name);
return;
@@ -303,7 +303,7 @@ struct vme_resource *vme_slave_request(struct vme_dev 
*vdev, u32 address,
struct vme_resource *resource = NULL;
 
bridge = vdev->bridge;
-   if (bridge == NULL) {
+   if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n");
goto err_bus;
}
@@ -313,7 +313,7 @@ struct vme_resource *vme_slave_request(struct vme_dev 
*vdev, u32 address,
slave_image = list_entry(slave_pos,
struct vme_slave_resource, list);
 
-   if (slave_image == NULL) {
+   if (!slave_image) {
printk(KERN_ERR "Registered NULL Slave resource\n");
continue;
}
@@ -333,7 +333,7 @@ struct vme_resource *vme_slave_request(struct vme_dev 
*vdev, u32 address,
}
 
/* No free image */
-   if (allocated_image == NULL)
+   if (!allocated_image)
goto err_image;
 
resource = kmalloc(sizeof(*resource), GFP_KERNEL);
@@ -388,7 +388,7 @@ int vme_slave_set(struct vme_resource *resource, int 
enabled,
 
image = list_entry(resource->entry, struct vme_slave_resource, list);
 
-   if (bridge->slave_set == NULL) {
+   if (!bridge->slave_set) {
printk(KERN_ERR "Function not supported\n");
return -ENOSYS;
}
@@ -437,7 +437,7 @@ int vme_slave_get(struct vme_resource *resource, int 
*enabled,
 
image = list_entry(resource->entry, struct vme_slave_resource, list);
 
-   if (bridge->slave_get == NULL) {
+   if (!bridge->slave_get) {
printk(KERN_ERR "vme_slave_get not supported\n");
return -EINVAL;
}
@@ -464,7 +464,7 @@ void vme_slave_free(struct vme_resource *resource)
 
slave_image = list_entry(resource->entry, struct vme_slave_resource,
list);
-   if (slave_image == NULL) {
+   if (!slave_image) {
printk(KERN_ERR "Can't find slave resource\n");
return;
}
@@ -504,7 +504,7 @@ struct vme_resource *vme_master_request(struct vme_dev 
*vdev, u32 address,
struct vme_resource *resource = NULL;
 
bridge = vdev->bridge;
-   if (bridge == NULL) {
+   if (!bridge) {
printk(KERN_ERR "Can't find VME bus\n");
goto err_bus;
}
@@ -514,7 +514,7 @@ struct vme_resource *vme_master_request(struct vme_dev 
*vdev, u32 address,
master_image = list_entry(master_pos,
struct vme_master_resource, list);
 
-   if 

[PATCH 03/14] vme: Move an assignment in vme_new_dma_list()

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 24 Aug 2017 22:04:45 +0200

Assign a pointer to a data structure member without using an intermediate
local variable.

Signed-off-by: Markus Elfring 
---
 drivers/vme/vme.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 1afddf5eafd4..d890410e472d 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -948,7 +948,6 @@ EXPORT_SYMBOL(vme_dma_request);
  */
 struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
 {
-   struct vme_dma_resource *ctrlr;
struct vme_dma_list *dma_list;
 
if (resource->type != VME_DMA) {
@@ -956,14 +955,14 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource 
*resource)
return NULL;
}
 
-   ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
-
dma_list = kmalloc(sizeof(*dma_list), GFP_KERNEL);
if (!dma_list)
return NULL;
 
INIT_LIST_HEAD(&dma_list->entries);
-   dma_list->parent = ctrlr;
+   dma_list->parent = list_entry(resource->entry,
+ struct vme_dma_resource,
+ list);
mutex_init(&dma_list->mtx);
 
return dma_list;
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/14] vme: Delete 11 error messages for a failed memory allocation

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 24 Aug 2017 21:38:20 +0200

Omit extra messages for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/vme/vme.c | 51 ---
 1 file changed, 16 insertions(+), 35 deletions(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index 6a3ead42aba8..53e87af8e0b8 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -340,7 +340,6 @@ struct vme_resource *vme_slave_request(struct vme_dev 
*vdev, u32 address,
-   if (resource == NULL) {
-   printk(KERN_WARNING "Unable to allocate resource structure\n");
+   if (!resource)
goto err_alloc;
-   }
+
resource->type = VME_SLAVE;
resource->entry = &allocated_image->list;
 
@@ -545,7 +544,6 @@ struct vme_resource *vme_master_request(struct vme_dev 
*vdev, u32 address,
-   if (resource == NULL) {
-   printk(KERN_ERR "Unable to allocate resource structure\n");
+   if (!resource)
goto err_alloc;
-   }
+
resource->type = VME_MASTER;
resource->entry = &allocated_image->list;
 
@@ -922,7 +920,6 @@ struct vme_resource *vme_dma_request(struct vme_dev *vdev, 
u32 route)
-   if (resource == NULL) {
-   printk(KERN_WARNING "Unable to allocate resource structure\n");
+   if (!resource)
goto err_alloc;
-   }
+
resource->type = VME_DMA;
resource->entry = &allocated_ctrlr->list;
 
@@ -965,7 +962,6 @@ struct vme_dma_list *vme_new_dma_list(struct vme_resource 
*resource)
-   if (dma_list == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for new DMA list\n");
+   if (!dma_list)
return NULL;
-   }
+
INIT_LIST_HEAD(&dma_list->entries);
dma_list->parent = ctrlr;
mutex_init(&dma_list->mtx);
@@ -994,13 +990,9 @@ struct vme_dma_attr *vme_dma_pattern_attribute(u32 
pattern, u32 type)
-   if (attributes == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for attributes 
structure\n");
+   if (!attributes)
goto err_attr;
-   }
 
pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL);
-   if (pattern_attr == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for pattern 
attributes\n");
+   if (!pattern_attr)
goto err_pat;
-   }
 
attributes->type = VME_DMA_PATTERN;
attributes->private = (void *)pattern_attr;
@@ -1038,15 +1030,9 @@ struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t 
address)
-   if (attributes == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for attributes 
structure\n");
+   if (!attributes)
goto err_attr;
-   }
 
pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL);
-   if (pci_attr == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for PCI 
attributes\n");
+   if (!pci_attr)
goto err_pci;
-   }
-
-
 
attributes->type = VME_DMA_PCI;
attributes->private = (void *)pci_attr;
@@ -1086,13 +1072,9 @@ struct vme_dma_attr *vme_dma_vme_attribute(unsigned long 
long address,
-   if (attributes == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for attributes 
structure\n");
+   if (!attributes)
goto err_attr;
-   }
 
vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL);
-   if (vme_attr == NULL) {
-   printk(KERN_ERR "Unable to allocate memory for VME 
attributes\n");
+   if (!vme_attr)
goto err_vme;
-   }
 
attributes->type = VME_DMA_VME;
attributes->private = (void *)vme_attr;
@@ -1542,7 +1524,6 @@ struct vme_resource *vme_lm_request(struct vme_dev *vdev)
-   if (resource == NULL) {
-   printk(KERN_ERR "Unable to allocate resource structure\n");
+   if (!resource)
goto err_alloc;
-   }
+
resource->type = VME_LM;
resource->entry = &allocated_lm->list;
 
-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/14] VME: Adjustments for several function implementations

2017-08-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 25 Aug 2017 13:15:43 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (14):
  Delete 11 error messages for a failed memory allocation
  Improve 11 size determinations
  Move an assignment in vme_new_dma_list()
  Adjust 48 checks for null pointers
  Return directly in two functions
  fake: Delete an error message for a failed memory allocation in fake_init()
  fake: Improve five size determinations in fake_init()
  fake: Adjust 11 checks for null pointers
  ca91cx42: Delete eight error messages for a failed memory allocation
  ca91cx42: Improve 12 size determinations
  ca91cx42: Adjust 14 checks for null pointers
  tsi148: Delete nine error messages for a failed memory allocation
  tsi148: Improve 17 size determinations
  tsi148: Adjust 14 checks for null pointers

 drivers/vme/bridges/vme_ca91cx42.c |  73 +-
 drivers/vme/bridges/vme_fake.c |  35 +++
 drivers/vme/bridges/vme_tsi148.c   |  82 ++--
 drivers/vme/vme.c  | 194 -
 4 files changed, 156 insertions(+), 228 deletions(-)

-- 
2.14.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: Delete an error message for a failed memory allocation in Handle_Key()

2017-05-17 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 17 May 2017 22:26:07 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/staging/wilc1000/host_interface.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index c3a8af081880..17a31bbd3665 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1688,7 +1688,6 @@ static int Handle_Key(struct wilc_vif *vif,
} else if (pstrHostIFkeyAttr->action & ADDKEY) {
pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
if (!pu8keybuf) {
-   netdev_err(vif->ndev, "No buffer send PTK\n");
ret = -ENOMEM;
goto _WPAPtk_end_case_;
}
-- 
2.13.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: netlogic: Delete an error message for a failed memory allocation in xlr_config_spill()

2017-05-17 Thread SF Markus Elfring
From: Markus Elfring 
Date: Wed, 17 May 2017 19:01:10 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/staging/netlogic/xlr_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/netlogic/xlr_net.c 
b/drivers/staging/netlogic/xlr_net.c
index 781ef623233e..864304eb5f36 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -420,10 +420,8 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, 
int reg_start_0,
base = priv->base_addr;
spill_size = size;
spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_ATOMIC);
-   if (!spill) {
-   pr_err("Unable to allocate memory for spill area!\n");
+   if (!spill)
return ZERO_SIZE_PTR;
-   }
 
spill = PTR_ALIGN(spill, SMP_CACHE_BYTES);
phys_addr = virt_to_phys(spill);
-- 
2.13.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Clarification for general change acceptance

2017-05-12 Thread SF Markus Elfring
> When you make a patch, you are not obliged to eliminate all of the other
> checkpatch warnings on the file.

Your view is generally fine.


> I don't know where you got this idea from.

I got used as a professional software developer to some approaches for
reducing development warnings to some degree. So I picked further update
suggestions up also from this source code analysis tool.

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Clarification for general change acceptance

2017-05-12 Thread SF Markus Elfring
> Developer reputation matters for somewhat controversial
> patches being applied as well as non-controversial and
> obviously correct patches being ignored.

I am aware that there are more factors involved.


> Your reputation means most all of your patches fall into
> the latter category.

I hope that this situation will evolve into directions which you would prefer 
more.


> You have produced many trivial patches

This is true.

I started my concrete contributions to Linux software modules with simple
source code search patterns.


> that have caused new defects.

A few unwanted programming mistakes just happened somehow.


> That is simply unacceptable.

Glitches are not desired as usual.



> Especially when you don't immediately fix the problems you cause.

I find my response times reasonable to some degree so far.

Remaining open issues can be clarified by a corresponding constructive
development dialogue, can't they?



> If you would stop producing the trivial and instead
> channel your efforts into actual bug fixing and logic
> corrections and not just style modifications with no
> code impact, your patch acceptance rate would increase.

I find your conclusion appropriate.

But I will come along source code places where I am going to update details
which are also trivial.


> I have given you many suggestions for actual structural
> improvements to kernel code.

I have got an other impression. There were a few occasions where advanced
change possibilities were proposed.


> You have ignored _all_ of them and I am unlikely to try
> to interact with you any longer until your wheat:chaff
> ratio changes.

Can the efforts for deleting questionable error messages around Linux memory
allocation functions improve this situation?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: vmbus: Delete an error message for a failed memory allocation in vmbus_device_create()

2017-05-12 Thread SF Markus Elfring
>> Just because an automated tool says that this needs to change does not
>> mean it has to.
> 
> Checkpatch.pl is correct here.  This message is useless.  It's during
> init so it's unlikely to fail ever.  In current kernels small kmallocs
> are quaranteed to succeed so it can't actually fail currently.  The
> stack trace is more useful than this message because it tells you a lot
> about what memory is free and the whole call tree.
> 
> The error message is dead useless code.

Would you like to clarify corresponding software evolution any more?

Is there a need for better documentation of the involved programming interfaces?


> This patch is not going to be merged because Markus doesn't listen to
> feedback and he's blocked but otherwise it's an OK patch.

Does this information contain a contradiction?
Will patches be picked up also from contributors who got a special
development reputation anyhow?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: vmbus: Delete an error message for a failed memory allocation in vmbus_device_create()

2017-05-11 Thread SF Markus Elfring
> Taking out the message assumes that all callers of this function either log an
> error or pass appropriate error code back to userspace.

Do you like the default error response by Linux memory allocation functions?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] vmbus: Adjust five checks for null pointers

2017-05-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 11 May 2017 17:52:38 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/hv/vmbus_drv.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ff94b111ed8d..b55b979ecf8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -93,7 +93,7 @@ static DEFINE_SEMAPHORE(hyperv_mmio_lock);
 
 static int vmbus_exists(void)
 {
-   if (hv_acpi_dev == NULL)
+   if (!hv_acpi_dev)
return -ENODEV;
 
return 0;
@@ -568,7 +568,7 @@ static const struct hv_vmbus_device_id 
*hv_vmbus_get_id(struct hv_driver *drv,
return id;
 
id = drv->id_table;
-   if (id == NULL)
+   if (!id)
return NULL; /* empty device table */
 
for (; !is_null_guid(&id->guid); id++)
@@ -871,7 +871,7 @@ void vmbus_on_msg_dpc(unsigned long data)
entry = &channel_message_table[hdr->msgtype];
if (entry->handler_type == VMHT_BLOCKING) {
ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
-   if (ctx == NULL)
+   if (!ctx)
return;
 
INIT_WORK(&ctx->work, vmbus_onmessage_work);
@@ -894,7 +894,7 @@ static void vmbus_channel_isr(struct vmbus_channel *channel)
void (*callback_fn)(void *);
 
callback_fn = READ_ONCE(channel->onchannel_callback);
-   if (likely(callback_fn != NULL))
+   if (likely(callback_fn))
(*callback_fn)(channel->channel_callback_context);
 }
 
@@ -970,7 +970,7 @@ static void vmbus_isr(void)
union hv_synic_event_flags *event;
bool handled = false;
 
-   if (unlikely(page_addr == NULL))
+   if (unlikely(!page_addr))
return;
 
event = (union hv_synic_event_flags *)page_addr +
-- 
2.12.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] vmbus: Fix a typo in a comment line

2017-05-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 11 May 2017 17:43:55 +0200

Add a missing character in this description.

Signed-off-by: Markus Elfring 
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 96328aebae5a..ff94b111ed8d 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -991,7 +991,7 @@ static void vmbus_isr(void)
/*
 * Our host is win8 or above. The signaling mechanism
 * has changed and we can directly look at the event page.
-* If bit n is set then we have an interrup on the channel
+* If bit n is set then we have an interrupt on the channel
 * whose id is n.
 */
handled = true;
-- 
2.12.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] vmbus: Delete an error message for a failed memory allocation in vmbus_device_create()

2017-05-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 11 May 2017 17:33:14 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/hv/vmbus_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 6802d74f162c..96328aebae5a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1149,7 +1149,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
-   if (!child_device_obj) {
-   pr_err("Unable to allocate device object for child device\n");
+   if (!child_device_obj)
return NULL;
-   }
 
child_device_obj->channel = channel;
memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le));
-- 
2.12.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] vmbus: Improve a size determination in vmbus_device_create()

2017-05-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 11 May 2017 17:30:10 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/hv/vmbus_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0087b49095eb..6802d74f162c 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1145,5 +1145,5 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
 {
struct hv_device *child_device_obj;
 
-   child_device_obj = kzalloc(sizeof(struct hv_device), GFP_KERNEL);
+   child_device_obj = kzalloc(sizeof(*child_device_obj), GFP_KERNEL);
if (!child_device_obj) {
-- 
2.12.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/4] VMBus: Adjustments for some function implementations

2017-05-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 11 May 2017 18:00:18 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
  Improve a size determination in vmbus_device_create()
  Delete an error message for a failed memory allocation in 
vmbus_device_create()
  Fix a typo in a comment line
  Adjust five checks for null pointers

 drivers/hv/vmbus_drv.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

-- 
2.12.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] android: binder: Use seq_putc() in print_binder_node()

2017-05-07 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 7 May 2017 22:07:16 +0200

A single character (line break) should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index aae4d8d4be36..041b49b0bbd9 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3871,7 +3871,7 @@ static void print_binder_node(struct seq_file *m, struct 
binder_node *node)
hlist_for_each_entry(ref, &node->refs, node_entry)
seq_printf(m, " %d", ref->proc->pid);
}
-   seq_puts(m, "\n");
+   seq_putc(m, '\n');
list_for_each_entry(w, &node->async_todo, entry)
print_binder_work(m, "",
  "pending async transaction", w);
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()

2017-04-12 Thread SF Markus Elfring
> This patch does not apply to Greg's staging-testing branch.

Could the proposed changes be applied with a bit of “fuzz” for the
implementation of the function “ks7010_sdio_probe”?


> Markus a patch was merged the same day you submitted this one that
> refactored this code.

Do you refer to your contributions from 2017-04-10 here which seem to
touch only other functions?
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/log/?h=staging-testing&qt=author&q=Tobin+C.+Harding


> The patch was good though, good spotting.

Will there any more approaches be needed for a corresponding
editing conflict resolution?
Which day would be better to dare a resend for my small update suggestion?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()

2017-04-11 Thread SF Markus Elfring
From: Markus Elfring 
Date: Tue, 11 Apr 2017 14:54:35 +0200

The use of the logging function "dev_err" was introduced here on 2016-09-26.

I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".

* Omit an extra module prefix in passed error messages because the device name
  will be displayed by the function "__dev_printk".

Fixes: 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings 
on printk() usage")

Signed-off-by: Markus Elfring 
---
 drivers/staging/ks7010/ks7010_sdio.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b16618b41253..85feb170869b 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,
/* private memory allocate */
netdev = alloc_etherdev(sizeof(*priv));
if (!netdev) {
-   dev_err(&card->func->dev, "ks7010 : Unable to alloc new net 
device\n");
+   dev_err(&func->dev, "Unable to alloc new net device\n");
goto err_release_irq;
}
if (dev_alloc_name(netdev, "wlan%d") < 0) {
-   dev_err(&card->func->dev,
-   "ks7010 :  Couldn't get name!\n");
+   dev_err(&func->dev, "Couldn't get name!\n");
goto err_free_netdev;
}
 
@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,
/* Upload firmware */
ret = ks7010_upload_firmware(priv, card);   /* firmware load */
if (ret) {
-   dev_err(&card->func->dev,
-   "ks7010: firmware load failed !! return code = %d\n",
-ret);
+   dev_err(&func->dev,
+   "firmware load failed! return code = %d\n",
+   ret);
goto err_free_read_buf;
}
 
-- 
2.12.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging/lustre/obdclass: Use seq_puts() in three functions

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 16:45:32 +0100

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts"
so that the data output will be a bit more efficient in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/obdclass/cl_object.c  |  4 ++--
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 15 +++
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 277908d66a89..3e00aa4747b8 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -510,11 +510,11 @@ locks: .. .. .. .. .. [.. .. 
.. .. ..]
  */
lu_site_stats_print(&site->cs_lu, m);
cache_stats_print(&site->cs_pages, m, 1);
-   seq_printf(m, " [");
+   seq_puts(m, " [");
for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i)
seq_printf(m, "%s: %u ", pstate[i],
   atomic_read(&site->cs_pages_state[i]));
-   seq_printf(m, "]\n");
+   seq_puts(m, "]\n");
cache_stats_print(&cl_env_stats, m, 0);
seq_putc(m, '\n');
return 0;
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index a167cbe8a50e..3ce590cdd957 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -649,7 +649,7 @@ static int obd_import_flags2str(struct obd_import *imp, 
struct seq_file *m)
bool first = true;
 
if (imp->imp_obd->obd_no_recov) {
-   seq_printf(m, "no_recov");
+   seq_puts(m, "no_recov");
first = false;
}
 
@@ -715,15 +715,14 @@ int lprocfs_rd_import(struct seq_file *m, void *data)
   imp->imp_connect_data.ocd_instance);
obd_connect_seq_flags2str(m, imp->imp_connect_data.ocd_connect_flags,
  ", ");
-   seq_printf(m, " ]\n");
+   seq_puts(m, " ]\n");
obd_connect_data_seqprint(m, ocd);
-   seq_printf(m, "import_flags: [ ");
+   seq_puts(m, "import_flags: [ ");
obd_import_flags2str(imp, m);
-
-   seq_printf(m,
-  " ]\n"
-  "connection:\n"
-  "   failover_nids: [ ");
+   seq_puts(m,
+" ]\n"
+"connection:\n"
+"   failover_nids: [ ");
spin_lock(&imp->imp_lock);
j = 0;
list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging/lustre/obdclass: Combine two seq_printf() calls into one call in lprocfs_rd_state()

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 16:26:36 +0100

Some data were printed into a sequence by two separate function calls.
Print the same data by a single function call instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 3f6fcab5a1fc..a167cbe8a50e 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -853,10 +853,8 @@ int lprocfs_rd_state(struct seq_file *m, void *data)
return rc;
 
imp = obd->u.cli.cl_import;
-
-   seq_printf(m, "current_state: %s\n",
+   seq_printf(m, "current_state: %s\nstate_history:\n",
   ptlrpc_import_state_name(imp->imp_state));
-   seq_printf(m, "state_history:\n");
k = imp->imp_state_hist_idx;
for (j = 0; j < IMP_STATE_HIST_LEN; j++) {
struct import_state_hist *ish =
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging/lustre/obdclass: Use seq_putc() in four functions

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 16:12:23 +0100

A few single characters (line breaks) should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/obdclass/cl_object.c  | 4 ++--
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c 
b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index f5d4e23c64b7..277908d66a89 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -441,7 +441,7 @@ static int cache_stats_print(const struct cache_stats *cs,
seq_printf(m, "%6s", " ");
for (i = 0; i < CS_NR; i++)
seq_printf(m, "%8s", names[i]);
-   seq_printf(m, "\n");
+   seq_putc(m, '\n');
}
 
seq_printf(m, "%5.5s:", cs->cs_name);
@@ -516,7 +516,7 @@ locks: .. .. .. .. .. [.. .. 
.. .. ..]
   atomic_read(&site->cs_pages_state[i]));
seq_printf(m, "]\n");
cache_stats_print(&cl_env_stats, m, 0);
-   seq_printf(m, "\n");
+   seq_putc(m, '\n');
return 0;
 }
 EXPORT_SYMBOL(cl_site_stats_print);
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 2c99717b0aba..3f6fcab5a1fc 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -878,7 +878,7 @@ int lprocfs_at_hist_helper(struct seq_file *m, struct 
adaptive_timeout *at)
 
for (i = 0; i < AT_BINS; i++)
seq_printf(m, "%3u ", at->at_hist[i]);
-   seq_printf(m, "\n");
+   seq_putc(m, '\n');
return 0;
 }
 EXPORT_SYMBOL(lprocfs_at_hist_helper);
@@ -946,7 +946,7 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags;
seq_printf(m, "flags=%#llx\n", flags);
obd_connect_seq_flags2str(m, flags, "\n");
-   seq_printf(m, "\n");
+   seq_putc(m, '\n');
up_read(&obd->u.cli.cl_sem);
return 0;
 }
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging/lustre/mgc: Combine two seq_printf() calls into one call in lprocfs_mgc_rd_ir_state()

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 15:40:29 +0100

Some data were printed into a sequence by two separate function calls.
Print the same data by a single function call instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c 
b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index b9c522a3c7a4..a6ca48d7e96b 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -460,11 +460,8 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
 
imp = obd->u.cli.cl_import;
ocd = &imp->imp_connect_data;
-
-   seq_printf(m, "imperative_recovery: %s\n",
+   seq_printf(m, "imperative_recovery: %s\nclient_state:\n",
   OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED");
-   seq_printf(m, "client_state:\n");
-
spin_lock(&config_list_lock);
list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
if (!cld->cld_recover)
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging/lustre/llite: Use seq_puts() in three functions

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 15:30:45 +0100

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts"
so that the data output will be a bit more efficient in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/llite/lproc_llite.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c 
b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 03682c10fc9e..b195b7eb2883 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1325,8 +1325,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct 
seq_file *seq, void *v)
ktime_get_real_ts64(&now);
 
if (!sbi->ll_rw_stats_on) {
-   seq_printf(seq, "disabled\n"
-  "write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
+   seq_puts(seq, "disabled\n"
+"write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
return 0;
}
seq_printf(seq, "snapshot_time:  %llu.%09lu (secs.usecs)\n",
@@ -1403,8 +1403,8 @@ static int ll_rw_extents_stats_seq_show(struct seq_file 
*seq, void *v)
ktime_get_real_ts64(&now);
 
if (!sbi->ll_rw_stats_on) {
-   seq_printf(seq, "disabled\n"
-  "write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
+   seq_puts(seq, "disabled\n"
+"write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
return 0;
}
seq_printf(seq, "snapshot_time:  %llu.%09lu (secs.usecs)\n",
@@ -1583,8 +1583,8 @@ static int ll_rw_offset_stats_seq_show(struct seq_file 
*seq, void *v)
ktime_get_real_ts64(&now);
 
if (!sbi->ll_rw_stats_on) {
-   seq_printf(seq, "disabled\n"
-  "write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
+   seq_puts(seq, "disabled\n"
+"write anything in this file to activate, then 0 or 
\"[D/d]isabled\" to deactivate\n");
return 0;
}
spin_lock(&sbi->ll_process_lock);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/5] staging-Lustre: Fine-tuning for some function implementations

2017-01-01 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 1 Jan 2017 17:10:10 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  llite: Use seq_puts() in three functions
  mgc: Combine two seq_printf() calls into one call in lprocfs_mgc_rd_ir_state()
  obdclass: Use seq_putc() in four functions
  obdclass: Combine two seq_printf() calls into one call in lprocfs_rd_state()
  obdclass: Use seq_puts() in three functions

 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 12 +--
 drivers/staging/lustre/lustre/mgc/mgc_request.c|  5 +
 drivers/staging/lustre/lustre/obdclass/cl_object.c |  8 
 .../lustre/lustre/obdclass/lprocfs_status.c| 23 ++
 4 files changed, 21 insertions(+), 27 deletions(-)

-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 6/6] staging: vchiq_arm: Delete an unnecessary return statement in two functions

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 22:05:19 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: void function return statements are not generally useful

Thus remove such a statement in affected functions.

Signed-off-by: Markus Elfring 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 05a00914dba0..6fe0c72246a2 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2121,7 +2121,6 @@ vchiq_platform_check_suspend(VCHIQ_STATE_T *state)
 
 out:
vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__);
-   return;
 }
 
 
@@ -2306,7 +2305,6 @@ vchiq_check_suspend(VCHIQ_STATE_T *state)
 
 out:
vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__);
-   return;
 }
 
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/6] staging: vchiq_arm: Combine substrings for 24 messages

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 22:00:28 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

* Thus fix the affected source code places.

* Improve indentation for passed parameters.

Signed-off-by: Markus Elfring 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 164 +++--
 1 file changed, 90 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 3b7a0c87954d..05a00914dba0 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -292,12 +292,14 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T 
*header,
return VCHIQ_SUCCESS;
 
vchiq_log_trace(vchiq_arm_log_level,
-   "service_callback - service %lx(%d,%p), reason %d, header %lx, "
-   "instance %lx, bulk_userdata %lx",
-   (unsigned long)user_service,
-   service->localport, user_service->userdata,
-   reason, (unsigned long)header,
-   (unsigned long)instance, (unsigned long)bulk_userdata);
+   "service_callback - service %lx(%d,%p), reason %d, 
header %lx, instance %lx, bulk_userdata %lx",
+   (unsigned long)user_service,
+   service->localport,
+   user_service->userdata,
+   reason,
+   (unsigned long)header,
+   (unsigned long)instance,
+   (unsigned long)bulk_userdata);
 
if (header && user_service->is_vchi) {
spin_lock(&msg_queue_spinlock);
@@ -557,9 +559,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
rc = mutex_lock_killable(&instance->state->mutex);
if (rc != 0) {
vchiq_log_error(vchiq_arm_log_level,
-   "vchiq: connect: could not lock mutex for "
-   "state %d: %d",
-   instance->state->id, rc);
+   "vchiq: connect: could not lock mutex 
for state %d: %d",
+   instance->state->id, rc);
ret = -EINTR;
break;
}
@@ -720,16 +721,14 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
vchiq_release_service_internal(service);
if (status != VCHIQ_SUCCESS) {
vchiq_log_error(vchiq_susp_log_level,
-   "%s: cmd %s returned error %d for "
-   "service %c%c%c%c:%03d",
-   __func__,
-   (cmd == VCHIQ_IOC_USE_SERVICE) ?
-   "VCHIQ_IOC_USE_SERVICE" :
-   "VCHIQ_IOC_RELEASE_SERVICE",
-   status,
-   VCHIQ_FOURCC_AS_4CHARS(
-   service->base.fourcc),
-   service->client_id);
+   "%s: cmd %s returned error %d 
for service %c%c%c%c:%03d",
+   __func__,
+   (cmd == VCHIQ_IOC_USE_SERVICE)
+   ? "VCHIQ_IOC_USE_SERVICE"
+   : "VCHIQ_IOC_RELEASE_SERVICE",
+   status,
+   
VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc),
+   service->client_id);
ret = -EINVAL;
}
} else
@@ -930,8 +929,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
"header %pK: msgbufsize 
%x < msglen %x",
header, args.msgbufsize,
msglen);
-   WARN(1, "invalid message "
-   "size\n");
+   WARN(1,
+"invalid message size\n");
if (ret == 0)
ret = -EMSGSIZE;
break;
@@ -1982,19 +1981,22 @@ block_r

[PATCH 4/6] staging: vchiq_arm: Delete an error message for a failed memory allocation in dump_phys_mem()

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 21:30:31 +0100

Omit an extra message for a memory allocation failure in this function.

Link: 
http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index a316cf9ac626..3b7a0c87954d 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1559,12 +1559,8 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
 
num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
pages = kmalloc_array(num_pages, sizeof(*pages), GFP_KERNEL);
-   if (!pages) {
-   vchiq_log_error(vchiq_arm_log_level,
-   "Unable to allocation memory for %d pages\n",
-   num_pages);
+   if (!pages)
return;
-   }
 
down_read(¤t->mm->mmap_sem);
rc = get_user_pages(
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/6] staging: vchiq_arm: One check less in dump_phys_mem() after error detection

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 21:26:09 +0100

Adjust a jump target according to the Linux coding style convention
so that a redundant check for a null pointer can be avoided
in this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 2a260034189d..a316cf9ac626 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1581,7 +1581,7 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
if (rc < 0) {
vchiq_log_error(vchiq_arm_log_level,
"Failed to get user pages: %d\n", rc);
-   goto out;
+   goto put_pages;
}
 
while (offset < end_offset) {
@@ -1607,10 +1607,9 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
offset += 16;
}
 
-out:
if (page)
kunmap(page);
-
+put_pages:
for (page_idx = 0; page_idx < num_pages; page_idx++)
put_page(pages[page_idx]);
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/6] staging: vchiq_arm: Adjust 13 checks for null pointers

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 21:23:24 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 34 ++
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 4af77d790ae0..2a260034189d 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -533,7 +533,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
/* Remove all services */
i = 0;
while ((service = next_service_by_instance(instance->state,
-   instance, &i)) != NULL) {
+  instance, &i))) {
status = vchiq_remove_service(service->handle);
unlock_service(service);
if (status != VCHIQ_SUCCESS)
@@ -614,7 +614,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
&args.params, srvstate,
instance, user_service_free);
 
-   if (service != NULL) {
+   if (service) {
user_service->service = service;
user_service->userdata = userdata;
user_service->instance = instance;
@@ -661,7 +661,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
 
service = find_service_for_instance(instance, handle);
-   if (service != NULL) {
+   if (service) {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the
@@ -687,7 +687,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
 
service = find_service_for_instance(instance, handle);
-   if (service != NULL) {
+   if (service) {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
/* close_pending is false on first entry, and when the
@@ -714,7 +714,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
 
service = find_service_for_instance(instance, handle);
-   if (service != NULL) {
+   if (service) {
status = (cmd == VCHIQ_IOC_USE_SERVICE) ?
vchiq_use_service_internal(service) :
vchiq_release_service_internal(service);
@@ -747,7 +747,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
 
service = find_service_for_instance(instance, args.handle);
 
-   if ((service != NULL) && (args.count <= MAX_ELEMENTS)) {
+   if (service && (args.count <= MAX_ELEMENTS)) {
/* Copy elements into kernel space */
VCHIQ_ELEMENT_T elements[MAX_ELEMENTS];
if (copy_from_user(elements, args.elements,
@@ -1063,11 +1063,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
spin_unlock(&msg_queue_spinlock);
 
up(&user_service->remove_event);
-   if (header == NULL)
+   if (!header)
ret = -ENOTCONN;
else if (header->size <= args.bufsize) {
/* Copy to user space if msgbuf is not NULL */
-   if ((args.buf == NULL) ||
+   if (!args.buf ||
(copy_to_user((void __user *)args.buf,
header->data,
header->size) == 0)) {
@@ -1161,7 +1161,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned 
long arg)
VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg;
 
service = find_closed_service_for_instance(instance, handle);
-   if (service != NULL) {
+   if (service) {
USER_SERVICE_T *user_service =
(USER_SERVICE_T *)service->base.userdata;
close_deliver

[PATCH 1/6] staging: vchiq_arm: Use kmalloc_array() in dump_phys_mem()

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 17:50:25 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 610e0d6d93bb..4af77d790ae0 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -1558,8 +1558,7 @@ dump_phys_mem(void *virt_addr, uint32_t num_bytes)
end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1);
 
num_pages = (offset + num_bytes + PAGE_SIZE - 1) / PAGE_SIZE;
-
-   pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
+   pages = kmalloc_array(num_pages, sizeof(*pages), GFP_KERNEL);
if (pages == NULL) {
vchiq_log_error(vchiq_arm_log_level,
"Unable to allocation memory for %d pages\n",
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/6] staging: vchiq_arm: Fine-tuning for some function implementations

2016-12-31 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sat, 31 Dec 2016 22:42:34 +0100

Some update suggestions were taken into account
from static source code analysis.

Markus Elfring (6):
  Use kmalloc_array() in dump_phys_mem()
  Adjust 13 checks for null pointers
  One check less in dump_phys_mem() after error detection
  Delete an error message for a failed memory allocation in dump_phys_mem()
  Combine substrings for 24 messages
  Delete an unnecessary return statement in two functions

 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  | 212 +++--
 1 file changed, 109 insertions(+), 103 deletions(-)

-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: r8192U_core: Use kmalloc_array() in rtl8192_usb_initendpoints()

2016-12-30 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 30 Dec 2016 21:43:22 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring 
---
 drivers/staging/rtl8192u/r8192U_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/r8192U_core.c 
b/drivers/staging/rtl8192u/r8192U_core.c
index fdb03dccb449..e0791d357259 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -1682,8 +1682,9 @@ static short rtl8192_usb_initendpoints(struct net_device 
*dev)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
 
-   priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
-  GFP_KERNEL);
+   priv->rx_urb = kmalloc_array(MAX_RX_URB + 1,
+sizeof(*priv->rx_urb),
+GFP_KERNEL);
if (!priv->rx_urb)
return -ENOMEM;
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/4] staging: greybus: power_supply: Use kcalloc() in gb_power_supplies_setup()

2016-12-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 9 Dec 2016 15:04:24 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Fixes: ffe2e2487a388cf01ec44439346363aa8d654cd4 ("greybus: power_supply: rework 
and operation changes")

Signed-off-by: Markus Elfring 
---
 drivers/staging/greybus/power_supply.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c
index e85c988b7034..19080c7f1491 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -944,10 +944,9 @@ static int gb_power_supplies_setup(struct 
gb_power_supplies *supplies)
if (ret < 0)
goto out;
 
-   supplies->supply = kzalloc(supplies->supplies_count *
-sizeof(struct gb_power_supply),
-GFP_KERNEL);
-
+   supplies->supply = kcalloc(supplies->supplies_count,
+  sizeof(*supplies->supply),
+  GFP_KERNEL);
if (!supplies->supply) {
ret = -ENOMEM;
goto out;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/4] staging: greybus: light: Check return value of a kstrndup() call in gb_lights_light_config()

2016-12-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 9 Dec 2016 14:36:16 +0100

A return value was not checked after a call of the function "kstrndup".
This issue was detected by using the Coccinelle software.

Add a bit of exception handling.

Fixes: 2870b52bae4c81823ffcb3ed2b0626fb39d64f48 ("greybus: lights: add lights 
implementation")

Signed-off-by: Markus Elfring 
---
 drivers/staging/greybus/light.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 27bfc20eb9a5..c9c377f40f56 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1030,6 +1030,9 @@ static int gb_lights_light_config(struct gb_lights 
*glights, u8 id)
 
light->channels_count = conf.channel_count;
light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
+   if (!light->name)
+   return -ENOMEM;
+
light->channels = kcalloc(light->channels_count,
  sizeof(*light->channels),
  GFP_KERNEL);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/4] staging: greybus: light: Use kcalloc() in two functions

2016-12-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 9 Dec 2016 13:46:25 +0100

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Fixes: 2870b52bae4c81823ffcb3ed2b0626fb39d64f48 ("greybus: lights: add lights 
implementation")

Signed-off-by: Markus Elfring 
---
 drivers/staging/greybus/light.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 8dffd8a7e762..27bfc20eb9a5 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1030,9 +1030,9 @@ static int gb_lights_light_config(struct gb_lights 
*glights, u8 id)
 
light->channels_count = conf.channel_count;
light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
-
-   light->channels = kzalloc(light->channels_count *
- sizeof(struct gb_channel), GFP_KERNEL);
+   light->channels = kcalloc(light->channels_count,
+ sizeof(*light->channels),
+ GFP_KERNEL);
if (!light->channels)
return -ENOMEM;
 
@@ -1168,8 +1168,9 @@ static int gb_lights_create_all(struct gb_lights *glights)
if (ret < 0)
goto out;
 
-   glights->lights = kzalloc(glights->lights_count *
- sizeof(struct gb_light), GFP_KERNEL);
+   glights->lights = kcalloc(glights->lights_count,
+ sizeof(*glights->lights),
+ GFP_KERNEL);
if (!glights->lights) {
ret = -ENOMEM;
goto out;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/4] staging: greybus: camera: One function call less in gb_camera_configure_streams() after error detection

2016-12-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 18:25:13 +0100

The kfree() function was called in one case by the
gb_camera_configure_streams() function during error handling
even if the passed variable contained a null pointer.

This issue was detected by using the Coccinelle software.

Adjust a jump target according to the Linux coding style convention.

Fixes: 3265edaf0d70433699eece915fcca6509332c0e8 ("greybus: Add driver for the 
camera class protocol")

Signed-off-by: Markus Elfring 
---
 drivers/staging/greybus/camera.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index 1c5b41ae6774..4479caed81bd 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -537,14 +537,15 @@ static int gb_camera_configure_streams(struct gb_camera 
*gcam,
return -EINVAL;
 
req_size = sizeof(*req) + nstreams * sizeof(req->config[0]);
-   resp_size = sizeof(*resp) + nstreams * sizeof(resp->config[0]);
-
req = kmalloc(req_size, GFP_KERNEL);
-   resp = kmalloc(resp_size, GFP_KERNEL);
-   if (!req || !resp) {
-   kfree(req);
-   kfree(resp);
+   if (!req)
return -ENOMEM;
+
+   resp_size = sizeof(*resp) + nstreams * sizeof(resp->config[0]);
+   resp = kmalloc(resp_size, GFP_KERNEL);
+   if (!resp) {
+   ret = -ENOMEM;
+   goto free_request;
}
 
req->num_streams = nstreams;
@@ -647,8 +648,9 @@ static int gb_camera_configure_streams(struct gb_camera 
*gcam,
 
 done_skip_pm_put:
mutex_unlock(&gcam->mutex);
-   kfree(req);
kfree(resp);
+free_request:
+   kfree(req);
return ret;
 }
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/4] staging-greybus: Fine-tuning for four functions

2016-12-09 Thread SF Markus Elfring
From: Markus Elfring 
Date: Fri, 9 Dec 2016 15:25:35 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
  One function call less in gb_camera_configure_streams() after error detection
  light: Use kcalloc() in two functions
  Check return value of a kstrndup() call in gb_lights_light_config()
  Use kcalloc() in gb_power_supplies_setup()

 drivers/staging/greybus/camera.c   | 16 +---
 drivers/staging/greybus/light.c| 12 
 drivers/staging/greybus/power_supply.c |  7 +++
 3 files changed, 20 insertions(+), 15 deletions(-)

-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: comedi: usbduxsigma: Split a condition check in usbduxsigma_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
>> * Reduce memory allocation sizes for two function calls.

Is this implementation detail worth for further considerations?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: comedi: usbdux: Split a condition check in usbdux_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
> Actually, the original code worked fine,

I got my doubts when some memory allocations are attempted without checking
the desired success immediately.


> and these changes will result in an Oops if the allocations fail.  I'll 
> explain why,
> since it isn't obvious without some knowledge of the clean-up strategy used 
> by comedi drivers:

Thanks for your explanation.


> …, and all the other comedi drivers follow the same strategy of leaving 
> clean-up
> to their comedi 'detach' handler.

Are there other source code parts worth for further considerations?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging-COMEDI: Fine-tuning for three functions

2016-12-08 Thread SF Markus Elfring
> You do realize that I no longer take patches from you for any of the
> subsystems I maintain, right?

Not so far.

It seems that you would like to present new information for our
challenging collaboration.


> This patch series is one reason why...

I hope that corresponding disagreements around shown change possibilities
can still be clarified somehow.
Would you like to check further improvements for the affected
source code here?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: comedi: serial2002: Combine four kcalloc() calls into one in serial2002_setup_subdevs()

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 07:37:29 +0100

The function "kcalloc" was called in three cases by the function
"serial2002_setup_subdevs" without checking immediately if it failed.
This issue was detected by using the Coccinelle software.

* Perform the desired memory allocation (and release at the end) by a single
  function call instead.

* Adjust a jump target so that a redundant check is avoided.

Fixes: 623a73926c7012e3bb132e225621890207f5c611 ("staging: comedi: serial2002: 
split up serial_2002_open()")

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/serial2002.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/serial2002.c 
b/drivers/staging/comedi/drivers/serial2002.c
index 0d33e520f635..9542f4f8afe0 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -392,6 +392,7 @@ static int serial2002_setup_subdevice(struct 
comedi_subdevice *s,
 static int serial2002_setup_subdevs(struct comedi_device *dev)
 {
struct serial2002_private *devpriv = dev->private;
+   struct config_t *array;
struct config_t *di_cfg;
struct config_t *do_cfg;
struct config_t *ai_cfg;
@@ -402,15 +403,17 @@ static int serial2002_setup_subdevs(struct comedi_device 
*dev)
int i;
 
/* Allocate the temporary structs to hold the configuration data */
-   di_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL);
-   do_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL);
-   ai_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL);
-   ao_cfg = kcalloc(32, sizeof(*cfg), GFP_KERNEL);
-   if (!di_cfg || !do_cfg || !ai_cfg || !ao_cfg) {
+   array = kcalloc(4 * 32, sizeof(*cfg), GFP_KERNEL);
+   if (!array) {
result = -ENOMEM;
-   goto err_alloc_configs;
+   goto check_tty;
}
 
+   di_cfg = array;
+   do_cfg = array + 1 * 32;
+   ai_cfg = array + 2 * 32;
+   ao_cfg = array + 3 * 32;
+
/* Read the configuration from the connected device */
serial2002_tty_setspeed(devpriv->tty, devpriv->speed);
serial2002_poll_channel(devpriv->tty, 31);
@@ -534,13 +537,10 @@ static int serial2002_setup_subdevs(struct comedi_device 
*dev)
}
}
 
-err_alloc_configs:
-   kfree(di_cfg);
-   kfree(do_cfg);
-   kfree(ai_cfg);
-   kfree(ao_cfg);
+   kfree(array);
 
if (result) {
+check_tty:
if (devpriv->tty) {
filp_close(devpriv->tty, NULL);
devpriv->tty = NULL;
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: comedi: usbduxsigma: Move an assignment in usbduxsigma_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 11:20:38 +0100

Move one assignment for the local variable "usb" so that its setting
will only be performed after some memory allocations succeeded
by this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 8c04aa5339f3..7c1f9198447a 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1338,7 +1338,7 @@ static int usbduxsigma_firmware_upload(struct 
comedi_device *dev,
 
 static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev)
 {
-   struct usb_device *usb = comedi_to_usb_dev(dev);
+   struct usb_device *usb;
struct usbduxsigma_private *devpriv = dev->private;
struct urb *urb;
int i, x;
@@ -1367,6 +1367,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
if (!devpriv->ao_urbs)
goto free_ai_urbs;
 
+   usb = comedi_to_usb_dev(dev);
for (i = 0; i < devpriv->n_ai_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: comedi: usbduxsigma: Split a condition check in usbduxsigma_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 11:15:40 +0100

The functions "kcalloc" and "kzalloc" were called in four cases by the
function "usbduxsigma_alloc_usb_buffers" without checking immediately
if they succeded.
This issue was detected by using the Coccinelle software.

Allocated memory was also not released if one of these function
calls failed.

* Reduce memory allocation sizes for two function calls.

* Split a condition check for memory allocation failures.

* Add more exception handling.

Fixes: 65989c030bbca96be45ed137f6384dbd46030d10 ("staging: comedi: usbduxsigma: 
factor usb buffer allocation out of (*probe)")

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 61 ++--
 1 file changed, 49 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 456e9f13becb..8c04aa5339f3 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1341,22 +1341,37 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usbduxsigma_private *devpriv = dev->private;
struct urb *urb;
-   int i;
+   int i, x;
 
devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
+   if (!devpriv->dux_commands)
+   return -ENOMEM;
+
devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL);
+   if (!devpriv->in_buf)
+   goto free_commands;
+
devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL);
-   devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(urb), GFP_KERNEL);
-   devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(urb), GFP_KERNEL);
-   if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf ||
-   !devpriv->ai_urbs || !devpriv->ao_urbs)
-   return -ENOMEM;
+   if (!devpriv->insn_buf)
+   goto free_in_buf;
+
+   devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs,
+  sizeof(*devpriv->ai_urbs),
+  GFP_KERNEL);
+   if (!devpriv->ai_urbs)
+   goto free_insn_buf;
+
+   devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs,
+  sizeof(*devpriv->ao_urbs),
+  GFP_KERNEL);
+   if (!devpriv->ao_urbs)
+   goto free_ai_urbs;
 
for (i = 0; i < devpriv->n_ai_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ai_urbs;
devpriv->ai_urbs[i] = urb;
urb->dev = usb;
/* will be filled later with a pointer to the comedi-device */
@@ -1366,7 +1381,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_n_ai_urbs;
urb->complete = usbduxsigma_ai_urb_complete;
urb->number_of_packets = 1;
urb->transfer_buffer_length = SIZEINBUF;
@@ -1378,7 +1393,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
devpriv->ao_urbs[i] = urb;
urb->dev = usb;
/* will be filled later with a pointer to the comedi-device */
@@ -1388,7 +1403,7 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
urb->complete = usbduxsigma_ao_urb_complete;
urb->number_of_packets = 1;
urb->transfer_buffer_length = SIZEOUTBUF;
@@ -1400,16 +1415,38 @@ static int usbduxsigma_alloc_usb_buffers(struct 
comedi_device *dev)
if (devpriv->pwm_buf_sz) {
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
devpriv->pwm_urb = urb;
 
urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz,
   GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_pwm_urb;
}
 
return 0;
+free_pwm_urb

[PATCH 3/5] staging: comedi: usbdux: Move an assignment in usbdux_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 10:13:56 +0100

Move one assignment for the local variable "usb" so that its setting
will only be performed after some memory allocations succeeded
by this function.

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbdux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index d7d683bd669c..7efeac71161b 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1446,7 +1446,7 @@ static int usbdux_firmware_upload(struct comedi_device 
*dev,
 
 static int usbdux_alloc_usb_buffers(struct comedi_device *dev)
 {
-   struct usb_device *usb = comedi_to_usb_dev(dev);
+   struct usb_device *usb;
struct usbdux_private *devpriv = dev->private;
struct urb *urb;
int i, x;
@@ -1473,6 +1473,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
if (!devpriv->ao_urbs)
goto free_ai_urbs;
 
+   usb = comedi_to_usb_dev(dev);
for (i = 0; i < devpriv->n_ai_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: comedi: usbdux: Split a condition check in usbdux_alloc_usb_buffers()

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 10:01:54 +0100

The functions "kcalloc" and "kzalloc" were called in four cases by the
function "usbdux_alloc_usb_buffers" without checking immediately
if they succeded.
This issue was detected by using the Coccinelle software.

Allocated memory was also not released if one of these function
calls failed.

* Split a condition check for memory allocation failures.

* Add more exception handling.

Fixes: ef1e3c4a3b383c6da3979670fcb5c6e9c7de4741 ("staging: comedi: usbdux: tidy 
up usbdux_alloc_usb_buffers()")

Signed-off-by: Markus Elfring 
---
 drivers/staging/comedi/drivers/usbdux.c | 53 ++---
 1 file changed, 43 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index f4f05d29d30d..d7d683bd669c 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1449,24 +1449,35 @@ static int usbdux_alloc_usb_buffers(struct 
comedi_device *dev)
struct usb_device *usb = comedi_to_usb_dev(dev);
struct usbdux_private *devpriv = dev->private;
struct urb *urb;
-   int i;
+   int i, x;
 
devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL);
+   if (!devpriv->dux_commands)
+   return -ENOMEM;
+
devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL);
+   if (!devpriv->in_buf)
+   goto free_commands;
+
devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL);
+   if (!devpriv->insn_buf)
+   goto free_in_buf;
+
devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(void *),
   GFP_KERNEL);
+   if (!devpriv->ai_urbs)
+   goto free_insn_buf;
+
devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(void *),
   GFP_KERNEL);
-   if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf ||
-   !devpriv->ai_urbs || !devpriv->ao_urbs)
-   return -ENOMEM;
+   if (!devpriv->ao_urbs)
+   goto free_ai_urbs;
 
for (i = 0; i < devpriv->n_ai_urbs; i++) {
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ai_urbs;
devpriv->ai_urbs[i] = urb;
 
urb->dev = usb;
@@ -1475,7 +1486,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_n_ai_urbs;
 
urb->complete = usbduxsub_ai_isoc_irq;
urb->number_of_packets = 1;
@@ -1488,7 +1499,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
/* one frame: 1ms */
urb = usb_alloc_urb(1, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
devpriv->ao_urbs[i] = urb;
 
urb->dev = usb;
@@ -1497,7 +1508,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device 
*dev)
urb->transfer_flags = URB_ISO_ASAP;
urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
 
urb->complete = usbduxsub_ao_isoc_irq;
urb->number_of_packets = 1;
@@ -1514,17 +1525,39 @@ static int usbdux_alloc_usb_buffers(struct 
comedi_device *dev)
if (devpriv->pwm_buf_sz) {
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
-   return -ENOMEM;
+   goto free_n_ao_urbs;
devpriv->pwm_urb = urb;
 
/* max bulk ep size in high speed */
urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz,
   GFP_KERNEL);
if (!urb->transfer_buffer)
-   return -ENOMEM;
+   goto free_pwm_urb;
}
 
return 0;
+free_pwm_urb:
+   usb_free_urb(urb);
+free_n_ao_urbs:
+   for (x = 0; x < i; ++x) {
+   kfree(devpriv->ao_urbs[x]->transfer_buffer);
+   usb_free_urb(devpriv->ao_urbs[x]);
+   }
+free_n_ai_urbs:
+   for (x = 0; x < i; ++x) {
+   kfree(devpriv->ai_urbs[x]->transfer_buffer);
+   usb_free_urb(devpriv->ai_urbs[x]);
+   }
+   kfree(devpriv->ao_urbs);
+free_ai_urbs:
+   kfree(devpriv->ai_urbs);
+free_insn_buf:
+   kfree(devpriv->insn_buf);
+free_in_buf:
+   kfree(devpriv->in_buf);
+free_commands:
+   kfree(devpriv->dux_commands);

[PATCH 0/5] staging-COMEDI: Fine-tuning for three functions

2016-12-08 Thread SF Markus Elfring
From: Markus Elfring 
Date: Thu, 8 Dec 2016 11:37:37 +0100

Some update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Combine four kcalloc() calls into one in serial2002_setup_subdevs()
  Split a condition check in usbdux_alloc_usb_buffers()
  Move an assignment in usbdux_alloc_usb_buffers()
  Split a condition check in usbduxsigma_alloc_usb_buffers()
  Move an assignment in usbduxsigma_alloc_usb_buffers()

 drivers/staging/comedi/drivers/serial2002.c  | 22 +-
 drivers/staging/comedi/drivers/usbdux.c  | 56 ++-
 drivers/staging/comedi/drivers/usbduxsigma.c | 66 ++--
 3 files changed, 108 insertions(+), 36 deletions(-)

-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation

2016-08-21 Thread SF Markus Elfring
From: Markus Elfring 
Date: Sun, 21 Aug 2016 11:30:57 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring 
---
 drivers/staging/lustre/lustre/llite/dir.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index 031c9e4..8b70e42 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1676,14 +1676,9 @@ out_poll:
case LL_IOC_QUOTACTL: {
struct if_quotactl *qctl;
 
-   qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
-   if (!qctl)
-   return -ENOMEM;
-
-   if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
-   rc = -EFAULT;
-   goto out_quotactl;
-   }
+   qctl = memdup_user((void __user *)arg, sizeof(*qctl));
+   if (IS_ERR(qctl))
+   return PTR_ERR(qctl);
 
rc = quotactl_ioctl(sbi, qctl);
 
@@ -1691,7 +1686,6 @@ out_poll:
sizeof(*qctl)))
rc = -EFAULT;
 
-out_quotactl:
kfree(qctl);
return rc;
}
-- 
2.9.3

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: ks7010: Replace three printk() calls by pr_err()

2016-08-13 Thread SF Markus Elfring
> Really now, this is basic fixes and cleanups,

I agree to this view to some degree.


> you have been asked many times in the past to move on beyond these,

It is more useful when more severe bugs or bigger software improvements can be 
found.
Which source code clean-ups are picked better up by other contributors?


> as you often times seem to end up wasting lots of people's times
> as they attempt to help you.

It can take a bit more time occasionally to achieve the desired consensus.


> Personally, I'm long past wishing to help you out here, sorry.

Other contributors will eventually continue the clarification of remaining
open issues in the source file "ks7010_sdio.c".


> I'll take "correct" patches, but that's it.  No discussion of them, no
> arguing over theoreticals, and no telling you what I might, or might
> not, want to see done in the future, sorry.

I became aware about software development possibilities which can also
matter here.
Yesterday Julia Lawall informed me about a presentation on the topic
"Refactor strings – make everyone happy" by Wolfram Sang on 2016-07-14.

Is such a software evolution also interesting and acceptable for you?


> And really, your patch quality stinks, I strongly suggest getting a lot
> more experience with C first before doing more kernel work please.

Can you accept any specific update steps while other software changes
will evolve after a bit of discussion as usual?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver

2016-08-13 Thread SF Markus Elfring
> I added some Acked- and Reviewed-by tags last time.

I noticed this of course.


> Did the patches change

Yes. - The amount of source code which I touched in this software module
is different for the second series.


> or why didn't you add them?

I imagined that your acknowledgements to the previous approach might not
fit to the current software development situation any more.

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: ks7010: Replace three printk() calls by pr_err()

2016-08-13 Thread SF Markus Elfring
> You might have noticed I also wrote in the same reply:
> 
> "All of these pr_fmt uses are redundant as pr_err already does pr_fmt"

I admit that I made another software development mistake there. - It might not 
matter much
when a final fix could be to get rid of the three affected logging calls for 
example.


> It is not just principle.
> It is a fundamental for kernel patch submission.

I hope that this view supports still the reordering for update steps after some 
discussion.


> I am not an upstream path.
> Greg KH generally serves that function here.
> My suggestion would be to resend the entire patchset as V(n+1).

I am curious if it would make sense to reduce the mail traffic a bit by finding 
out
which software changes can be accepted already.

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: ks7010: Replace three printk() calls by pr_err()

2016-08-13 Thread SF Markus Elfring
> I think pr_ is OK if reworking the code
> to support dev_ is not easy.

Thanks for this explanation. - It sounds more constructive than the previous 
short
feedback "Not correct".


>> Would you accept that another update will be appended to the discussed patch 
>> series?
> 
> No.  Patches should not knowingly introduce defects
> that are corrected in follow-on patches.

This view is fine in principle.

I am just curious on the preferred sequence to fix the affected implementation 
details.

1. I imagine that my questionable update suggestion "[PATCH v2 08/10] staging: 
ks7010:
   Replace three printk() calls by pr_err()" can be skipped and the remaining 
logging
   calls will be improved somehow a bit later.

Or:

2. Do you want a resend of this whole patch series?


>>> alloc_etherdev already does a dump_stack so the OOM isn't useful.
>> Does this information indicate that this printk() (or pr_err()) call
>> should be deleted?
> 
> Markus, I don't know if it's your lack of English
> comprehension or not, but it's fairly obvious from
> my reply that this line should be deleted,

I was unsure if this view fits to a consensus also by other developers.

It might be that I can occasionally become picky to check if other contributors
insist on the usage of a specific error message.


> either in this patch or a follow-on.

I would prefer another addition (or source code clean-up) later.
Could it happen that so many error messages are update candidates (for deletion)
so that no places remain where a pr_err() call would make sense in this
software module?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: staging: ks7010: Replace three printk() calls by pr_err()

2016-08-13 Thread SF Markus Elfring
>> Prefer usage of the macro "pr_err" over the interface "printk".
> Not correct

A checkpatch warning like "PREFER_PR_LEVEL" can point additional possibilities 
out
for this use case.
Would you like to introduce any of the higher level logging functions instead?


>> diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
>> b/drivers/staging/ks7010/ks7010_sdio.c
> []
>> @@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,
>>  /* private memory allocate */
>>  netdev = alloc_etherdev(sizeof(*priv));
>>  if (netdev == NULL) {
>> -printk(KERN_ERR "ks7010 : Unable to alloc new net device\n");
>> +pr_err(pr_fmt("Unable to alloc new net device\n"));
> 
> All of these pr_fmt uses are redundant as pr_err already does pr_fmt

Thanks for your reminder.

Would you accept that another update will be appended to the discussed patch 
series?


> alloc_etherdev already does a dump_stack so the OOM isn't useful.

Does this information indicate that this printk() (or pr_err()) call
should be deleted?

Regards,
Markus
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   3   >