[RFC][PATCH 1/1] staging:vt6655: Remove checks around dev_kfree_skb

2015-06-23 Thread Maninder Singh
dev_kfree_skb checks for NULL pointer itself.

Signed-off-by: Maninder Singh 
Reviewed-by: Akhilesh Kumar 
---
 drivers/staging/vt6655/device_main.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index ca578d6..0c4b0de 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -767,8 +767,7 @@ static void device_free_td0_ring(struct vnt_private 
*pDevice)
dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
 pTDInfo->skb->len, DMA_TO_DEVICE);
 
-   if (pTDInfo->skb)
-   dev_kfree_skb(pTDInfo->skb);
+   dev_kfree_skb(pTDInfo->skb);
 
kfree(pDesc->pTDInfo);
}
@@ -786,8 +785,7 @@ static void device_free_td1_ring(struct vnt_private 
*pDevice)
dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
 pTDInfo->skb->len, DMA_TO_DEVICE);
 
-   if (pTDInfo->skb)
-   dev_kfree_skb(pTDInfo->skb);
+   dev_kfree_skb(pTDInfo->skb);
 
kfree(pDesc->pTDInfo);
}
-- 
1.7.9.5

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


[PATCH 1/1] staging/comedi: remove unnecessary check around pci_dev_put

2015-06-25 Thread Maninder Singh
pci_dev_put cehcks for NULL pointer itself,
reported by coccinelle

Signed-off-by: Maninder Singh 
Reviewed-by: Yogesh Gaur 
---
 drivers/staging/comedi/drivers/adl_pci9118.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index fb3043d..19b5806 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)
pci9118_reset(dev);
comedi_pci_detach(dev);
pci9118_free_dma(dev);
-   if (pcidev)
-   pci_dev_put(pcidev);
+   pci_dev_put(pcidev);
 }
 
 static struct comedi_driver adl_pci9118_driver = {
-- 
1.7.9.5

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


Re: [PATCH 1/1] staging/comedi: remove unnecessary check around pci_dev_put

2015-06-25 Thread Maninder Singh
>> pci_dev_put cehcks for NULL pointer itself,
>did you mean checks?
Yes did some typo, send v2 of the patch.

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


[PATCH v2] staging/comedi: remove unnecessary check around pci_dev_put

2015-06-25 Thread Maninder Singh
pci_dev_put checks for NULL pointer itself,
reported by coccinelle

Signed-off-by: Maninder Singh 
Reviewed-by: Yogesh Gaur 
---
v2: changelog typo cehcks -> checks

 drivers/staging/comedi/drivers/adl_pci9118.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index fb3043d..19b5806 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -1717,8 +1717,7 @@ static void pci9118_detach(struct comedi_device *dev)
pci9118_reset(dev);
comedi_pci_detach(dev);
pci9118_free_dma(dev);
-   if (pcidev)
-   pci_dev_put(pcidev);
+   pci_dev_put(pcidev);
 }
 
 static struct comedi_driver adl_pci9118_driver = {
-- 
1.7.9.5

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


Re: [PATCH 1/1] staging/comedi: remove unnecessary check around pci_dev_put

2015-06-25 Thread Maninder Singh
Hi,

>This patch is correct but the motivation is wrong.
>
>The check in pci_dev_put() is like a sanity check.  There are many
>functions which have a sanity check and many which do not, it is
>impossible for a human to remember the complete list of each.  When we
>remove explicit checks for NULL and instead rely on the sanity checks
>it sometimes makes the code more subtle and difficult to read.
>
>In this case, "pcidev" can never be NULL so the check is misleading and
>makes the code more complicated.  Removing it is a good thing.  Also
>the attach function does not have a NULL check so when we remove this
>check we make the code more consistent.
>
>But in other cases, if "pcidev" could be NULL then we should keep the
>check so that the code is easier to read.

Yes agree, I also sent this patch because there is only one call for pci_dev_put
in adl_pci9118.c, and i thoguht its good to remove check around that one.

Thanks for your feedback.

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


[PATCH 1/1] drivers: hv: hv_utils_transport: Fixing validation of correct pointer

2015-07-02 Thread Maninder Singh
cn_msg should be validated instead of msg after memory allocation.

Signed-off-by: Maninder Singh 
Reviewed-by: Akhilesh Kumar 
---
 drivers/hv/hv_utils_transport.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index ea7ba5e..6a9d80a 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -186,7 +186,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, 
void *msg, int len)
return -EINVAL;
} else if (hvt->mode == HVUTIL_TRANSPORT_NETLINK) {
cn_msg = kzalloc(sizeof(*cn_msg) + len, GFP_ATOMIC);
-   if (!msg)
+   if (!cn_msg)
return -ENOMEM;
cn_msg->id.idx = hvt->cn_id.idx;
cn_msg->id.val = hvt->cn_id.val;
-- 
1.7.9.5

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


[RESEND PATCH 1/1] staging:vt6655: remove checks around dev_kfree_skb

2015-07-14 Thread Maninder Singh
dev_kfree_skb checks for NULL pointer itself,
Thus no need of explicit NULL check.

Signed-off-by: Maninder Singh 
---
 drivers/staging/vt6655/device_main.c |8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index ed040fb..1a50ea6 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -758,9 +758,7 @@ static void device_free_td0_ring(struct vnt_private 
*pDevice)
dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
 pTDInfo->skb->len, DMA_TO_DEVICE);
 
-   if (pTDInfo->skb)
-   dev_kfree_skb(pTDInfo->skb);
-
+   dev_kfree_skb(pTDInfo->skb);
kfree(pDesc->pTDInfo);
}
 }
@@ -777,9 +775,7 @@ static void device_free_td1_ring(struct vnt_private 
*pDevice)
dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
 pTDInfo->skb->len, DMA_TO_DEVICE);
 
-   if (pTDInfo->skb)
-   dev_kfree_skb(pTDInfo->skb);
-
+   dev_kfree_skb(pTDInfo->skb);
kfree(pDesc->pTDInfo);
}
 }
-- 
1.7.9.5

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


Re: [RESEND PATCH 1/1] staging:vt6655: remove checks around dev_kfree_skb

2015-07-16 Thread Maninder Singh
Hi Dan,

>I hate these patches.  I have told Markus to stop sending them but he
>has issues so now I only complain when they introduce a bug.  There was
>one bug I have missed because it was a benchmark regression and I knew
>it was theoretically possible but I didn't know the code well enough to
>say which were fast paths...

>My main objection is that relying on the sanity check inside the
>function call makes the code more subtle to understand.  We know we need
>a NULL check but it is hidden away in another file.  The motivation for
>this patch you are sending is "There is a sanity check in dev_kfree_skb()
>so let's do an insane thing and save some lines of code."

>For this particular patch we assume throughout the whole driver that
>"pTDInfo->skb" can be NULL so making it inconsistent in this one place
>is wrong

Agreed,
But these changes are suggested because:-

where we are checking for (pTDInfo->skb), we are using it  in above line.
and it does not look good, thats why we should remove thse checks and i have 
suggested
changes.

code snippet:-
---

if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
 pTDInfo->skb->len, DMA_TO_DEVICE);

> In this we did not check for pTDInfo->skb

if (pTDInfo->skb)
dev_kfree_skb(pTDInfo->skb);

But if am wrong, sorry for the patch.

Thanks,
Maninder

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


[PATCH] Staging: xgifb: Fix NULL pointer comparison warning

2016-10-20 Thread Maninder Singh
Replace direct comparisons to NULL i.e.
'x == NULL' with '!x'.
This problem was detected by checkpatch.

Signed-off-by: Maninder Singh 
---
 drivers/staging/xgifb/XGI_main_26.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/xgifb/XGI_main_26.c 
b/drivers/staging/xgifb/XGI_main_26.c
index 0c78491..89bd4dd 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -518,7 +518,7 @@ static void XGIfb_search_crt2type(const char *name)
 {
int i = 0;
 
-   if (name == NULL)
+   if (!name)
return;
 
while (XGI_crt2type[i].type_no != -1) {
@@ -589,7 +589,7 @@ static void XGIfb_search_tvstd(const char *name)
 {
int i = 0;
 
-   if (name == NULL)
+   if (!name)
return;
 
while (XGI_tvtype[i].type_no != -1) {
-- 
1.7.9.5

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


[PATCH] staging: st-cec: add parentheses around complex macros

2016-11-04 Thread Maninder Singh
This patch fixes the following checkpatch.pl error:
ERROR: Macros with complex values should be enclosed in parentheses

Signed-off-by: Maninder Singh 
---
 drivers/staging/media/st-cec/stih-cec.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/st-cec/stih-cec.c 
b/drivers/staging/media/st-cec/stih-cec.c
index 2143448..b22394a 100644
--- a/drivers/staging/media/st-cec/stih-cec.c
+++ b/drivers/staging/media/st-cec/stih-cec.c
@@ -108,11 +108,11 @@
 
 /* Constants for CEC_BIT_TOUT_THRESH register */
 #define CEC_SBIT_TOUT_47MS BIT(1)
-#define CEC_SBIT_TOUT_48MS BIT(0) | BIT(1)
+#define CEC_SBIT_TOUT_48MS (BIT(0) | BIT(1))
 #define CEC_SBIT_TOUT_50MS BIT(2)
 #define CEC_DBIT_TOUT_27MS BIT(0)
 #define CEC_DBIT_TOUT_28MS BIT(1)
-#define CEC_DBIT_TOUT_29MS BIT(0) | BIT(1)
+#define CEC_DBIT_TOUT_29MS (BIT(0) | BIT(1))
 
 /* Constants for CEC_BIT_PULSE_THRESH register */
 #define CEC_BIT_LPULSE_03MS BIT(1)
-- 
1.7.9.5

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


[PATCH] staging: vc04_services: Remove explicit NULL pointer

2016-11-11 Thread Maninder Singh
Replace direct comparisons to NULL i.e.
'x == NULL' with '!x'
'x != NULL' with 'x'

Signed-off-by: Maninder Singh 
---
 .../vc04_services/interface/vchiq_arm/vchiq_arm.c  |   32 ++--
 .../vc04_services/interface/vchiq_arm/vchiq_core.c |4 +--
 .../vc04_services/interface/vchiq_arm/vchiq_shim.c |4 +--
 .../vc04_services/interface/vchiq_arm/vchiq_util.c |4 +--
 4 files changed, 22 insertions(+), 22 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 8fcd940..0068a1c 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 @@ struct vchiq_io_copy_callback_context {
/* 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 @@ struct vchiq_io_copy_callback_context {
&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 @@ struct vchiq_io_copy_callback_context {
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 @@ struct vchiq_io_copy_callback_context {
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 @@ struct vchiq_io_copy_callback_context {
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 @@ struct vchiq_io_copy_callback_context {
 
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,7 +1063,7 @@ struct vchiq_io_copy_callback_context {
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 */
@@ -1161,7 +1161,7 @@ struct vchiq_io_copy_callback_context {
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_delivered(user_service);
@@ -1305,7 +1305,7 @@ struct vchiq_io_copy_callback_context {
/* Mark all services for termination... */
i = 0;
while ((service = next_service_by_instance(state, instance,
-   &i)) != NULL) {
+   &i))) {
USER_SERVICE_T *user_service = service->base.userdata;
 
/* Wake the slot handler if the