[PATCH v2 10/12] gpib: ni_usb: Unify *allocate_private

Dominik Karol Piątkowski posted 12 patches 3 weeks, 3 days ago
There is a newer version of this series
[PATCH v2 10/12] gpib: ni_usb: Unify *allocate_private
Posted by Dominik Karol Piątkowski 3 weeks, 3 days ago
Return values for *allocate_private functions as well as calling code in
gpib driver are all over the place. Unify them by returning -errno if
something fails, zero otherwise. Use the returned value as early return
value in case of error. Replace kmalloc/memset pairs to kzalloc.

Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com>
---

v2: Replace kmalloc/memset pairs to kzalloc.

 drivers/gpib/ni_usb/ni_usb_gpib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpib/ni_usb/ni_usb_gpib.c b/drivers/gpib/ni_usb/ni_usb_gpib.c
index 1f8412de9fa3..1fc3ccdebff1 100644
--- a/drivers/gpib/ni_usb/ni_usb_gpib.c
+++ b/drivers/gpib/ni_usb/ni_usb_gpib.c
@@ -1659,11 +1659,10 @@ static int ni_usb_allocate_private(struct gpib_board *board)
 {
 	struct ni_usb_priv *ni_priv;
 
-	board->private_data = kmalloc(sizeof(struct ni_usb_priv), GFP_KERNEL);
+	board->private_data = kzalloc(sizeof(struct ni_usb_priv), GFP_KERNEL);
 	if (!board->private_data)
 		return -ENOMEM;
 	ni_priv = board->private_data;
-	memset(ni_priv, 0, sizeof(struct ni_usb_priv));
 	mutex_init(&ni_priv->bulk_transfer_lock);
 	mutex_init(&ni_priv->control_transfer_lock);
 	mutex_init(&ni_priv->interrupt_transfer_lock);
-- 
2.43.0