mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.de>
To: Oleg Verych <olecom@flower.upol.cz>,
	Pekka J Enberg <penberg@cs.helsinki.fi>,
	lirc@bartelmus.de
Cc: linux-kernel@vger.kernel.org
Subject: Re: lirc: igorplususb error handling cleanup
Date: Fri, 2 Feb 2007 11:58:19 +0100	[thread overview]
Message-ID: <200702021158.19514.oneukum@suse.de> (raw)
In-Reply-To: <slrnes64tk.m64.olecom@flower.upol.cz>


> > -	/* allocate kernel memory */
> > -	mem_failure = 0;
> > -	if (!(ir = kmalloc(sizeof(struct irctl), GFP_KERNEL))) {
> > -		mem_failure = 1;
> > -	} else {
> > -		memset(ir, 0, sizeof(struct irctl));
> > -
> > -		if (!(plugin = kmalloc(sizeof(struct lirc_plugin), GFP_KERNEL))) {
> > -			mem_failure = 2;
> > -		} else if (!(rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL))) {
> > -			mem_failure = 3;
> 
> If size of all structs, allocated here is 3-4 pages (say, 4096 bytes
> one), then, i think something like, allocating all at once may be
> utilized:
> 
> ,-*-
> |struct ir_stuff_t {
> |       struct irctl *ir;
> |       struct lirc_plugin *plugin;
> |       struct lirc_buffer *rbuf;

I guess you mean 
struct lirc_buffer rbuf;
without the "*"

> |} ir_stuff;
> |
> |ir_stuff = kzalloc(...);
> |
> |if(!ir_stuff)
> |       error;
> `-*-       
> 
> then join buffer init, usb init together and final register, after
> it. Thus to have second erroneous path.

If I understand this code correctly the allocated buffers end up as
buffers used in URBs. If that is the case you must allocate each of
them separately with kmalloc() or usb_alloc_buffer() or you violate
DMA constraints on non-coherent architectures (eg. ppc)

	Regards
		Oliver

      reply	other threads:[~2007-02-02 10:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-02  9:15 Pekka J Enberg
2007-02-02 10:25 ` Oleg Verych
2007-02-02 10:58   ` Oliver Neukum [this message]

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=200702021158.19514.oneukum@suse.de \
    --to=oneukum@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirc@bartelmus.de \
    --cc=olecom@flower.upol.cz \
    --cc=penberg@cs.helsinki.fi \
    /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

all inboxes | Powered by JetHome®