* [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc
@ 2014-10-14 16:40 Fabian Frederick
2014-10-14 17:15 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Fabian Frederick @ 2014-10-14 16:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Fabian Frederick, John W. Linville, linux-wireless, netdev
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
drivers/net/wireless/zd1201.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 6f5c793..4630b26 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -525,7 +525,7 @@ static int zd1201_setconfig(struct zd1201 *zd, int rid, void *buf, int len, int
zd->rxdatas = 0;
zd->rxlen = 0;
for (seq=0; len > 0; seq++) {
- request = kmalloc(16, gfp_mask);
+ request = kzalloc(16, gfp_mask);
if (!request)
return -ENOMEM;
urb = usb_alloc_urb(0, gfp_mask);
@@ -533,7 +533,6 @@ static int zd1201_setconfig(struct zd1201 *zd, int rid, void *buf, int len, int
kfree(request);
return -ENOMEM;
}
- memset(request, 0, 16);
reqlen = len>12 ? 12 : len;
request[0] = ZD1201_USB_RESREQ;
request[1] = seq;
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc
2014-10-14 16:40 [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc Fabian Frederick
@ 2014-10-14 17:15 ` Joe Perches
2014-10-14 18:08 ` Bjørn Mork
0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2014-10-14 17:15 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-kernel, John W. Linville, linux-wireless, netdev
On Tue, 2014-10-14 at 18:40 +0200, Fabian Frederick wrote:
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
It might be clearer to use a structure for this 16 byte thing.
There's a comment bit in the code:
/* cmdreq message:
u32 type
u16 cmd
u16 parm0
u16 parm1
u16 parm2
u8 pad[4]
total: 4 + 2 + 2 + 2 + 2 + 4 = 16
*/
It seems thought that this first u32 is actually
a series of u8s.
Maybe:
struct zd1201_cmdreq {
u8 type;
u8 seq;
u8 a;
u8 b;
__le16 cmd;
__le16 parm0;
__le16 parm1;
__le16 parm2;
u8 pad[4];
};
And does this really need to be alloc'd?
maybe
struct zd1202_cmdreq request = {};
etc...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc
2014-10-14 17:15 ` Joe Perches
@ 2014-10-14 18:08 ` Bjørn Mork
2014-10-16 8:08 ` Fabian Frederick
0 siblings, 1 reply; 5+ messages in thread
From: Bjørn Mork @ 2014-10-14 18:08 UTC (permalink / raw)
To: Joe Perches
Cc: Fabian Frederick, linux-kernel, John W. Linville, linux-wireless, netdev
Joe Perches <joe@perches.com> writes:
> And does this really need to be alloc'd?
Yes, it does. It is used as a transfer_buffer in usb_fill_bulk_urb() and
must be "suitable for DMA". From include/linux/usb.h:
/**
* struct urb - USB Request Block
..
* @transfer_buffer: This identifies the buffer to (or from) which the I/O
* request will be performed unless URB_NO_TRANSFER_DMA_MAP is set
* (however, do not leave garbage in transfer_buffer even then).
* This buffer must be suitable for DMA; allocate it with
* kmalloc() or equivalent. For transfers to "in" endpoints, contents
* of this buffer will be modified. This buffer is used for the data
* stage of control transfers.
Bjørn
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc
2014-10-14 18:08 ` Bjørn Mork
@ 2014-10-16 8:08 ` Fabian Frederick
2014-10-16 8:50 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Fabian Frederick @ 2014-10-16 8:08 UTC (permalink / raw)
To: Joe Perches, Bjørn Mork
Cc: linux-wireless, netdev, linux-kernel, John W. Linville
> On 14 October 2014 at 20:08 Bjørn Mork <bjorn@mork.no> wrote:
>
>
> Joe Perches <joe@perches.com> writes:
>
> > And does this really need to be alloc'd?
>
> Yes, it does. It is used as a transfer_buffer in usb_fill_bulk_urb() and
> must be "suitable for DMA". From include/linux/usb.h:
>
> /**
> * struct urb - USB Request Block
> ..
> * @transfer_buffer: This identifies the buffer to (or from) which the I/O
> * request will be performed unless URB_NO_TRANSFER_DMA_MAP is set
> * (however, do not leave garbage in transfer_buffer even then).
> * This buffer must be suitable for DMA; allocate it with
> * kmalloc() or equivalent. For transfers to "in" endpoints, contents
> * of this buffer will be modified. This buffer is used for the data
> * stage of control transfers.
>
>
Adding a structure would be a nice design update indeed but this would require
some testing...Separate patch maybe ?
Fabian
>
> Bjørn
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc
2014-10-16 8:08 ` Fabian Frederick
@ 2014-10-16 8:50 ` Joe Perches
0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-10-16 8:50 UTC (permalink / raw)
To: Fabian Frederick
Cc: Bjørn Mork, linux-wireless, netdev, linux-kernel, John W. Linville
On Thu, 2014-10-16 at 10:08 +0200, Fabian Frederick wrote:
> Adding a structure would be a nice design update indeed but this would require
> some testing...Separate patch maybe ?
Of course that'd be fine.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-16 8:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-14 16:40 [PATCH 1/1 linux-next] zd1201: replace kmalloc/memset by kzalloc Fabian Frederick
2014-10-14 17:15 ` Joe Perches
2014-10-14 18:08 ` Bjørn Mork
2014-10-16 8:08 ` Fabian Frederick
2014-10-16 8:50 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).