linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch.de>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Daniel Drake <dsd@gentoo.org>,
	Ulrich Kunitz <kune@deine-taler.de>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] zd1211rw: Use DMA-aware buffer for usb transfer
Date: Thu, 15 May 2008 17:42:35 +0200	[thread overview]
Message-ID: <200805151742.35366.mb@bu3sch.de> (raw)
In-Reply-To: <20080516.001215.39152691.anemo@mba.ocn.ne.jp>

On Thursday 15 May 2008 17:12:15 Atsushi Nemoto wrote:
> @@ -312,22 +313,29 @@ int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len)
>  {
>  	int r;
>  	struct usb_device *udev = zd_usb_to_usbdev(usb);
> +	u8 *buf = kmalloc(len, GFP_KERNEL);
>  
> +	if (!buf)
> +		return -ENOMEM;

Not that my opinion counts here, but I don't like the coding style of
doing work in the variable definition block.
Pointer assignments in there are OK (like the zd_usb_to_usbdev, which just
fetches a pointer), but a kmalloc() call is IMO very confusing.

But the decision whether this is OK or not is not up to me.

>  	r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
>  		USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0,
> -		data, len, 5000);
> +		buf, len, 5000);
>  	if (r < 0) {
>  		dev_err(&udev->dev,
>  			"read over firmware interface failed: %d\n", r);
> -		return r;
> +		goto exit;
>  	} else if (r != len) {
>  		dev_err(&udev->dev,
>  			"incomplete read over firmware interface: %d/%d\n",
>  			r, len);
> -		return -EIO;
> +		r = -EIO;
> +		goto exit;
>  	}
> -
> -	return 0;
> +	r = 0;
> +	memcpy(data, buf, len);
> +exit:
> +	kfree(buf);
> +	return r;
>  }


-- 
Greetings Michael.

  reply	other threads:[~2008-05-15 15:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 15:12 [PATCH] zd1211rw: Use DMA-aware buffer for usb transfer Atsushi Nemoto
2008-05-15 15:42 ` Michael Buesch [this message]
2008-05-15 19:16 ` John W. Linville
2008-05-16  8:27   ` Atsushi Nemoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200805151742.35366.mb@bu3sch.de \
    --to=mb@bu3sch.de \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=dsd@gentoo.org \
    --cc=kune@deine-taler.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).