public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@gmail.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Andrew Morton <akpm@osdl.org>, Jens Axboe <jens.axboe@oracle.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: New Mitsumi legacy CD-ROM driver
Date: Tue, 08 May 2007 16:17:06 +0200	[thread overview]
Message-ID: <46408662.5070003@gmail.com> (raw)
In-Reply-To: <84144f020705080653i16d324c8pbd2925d844f400fc@mail.gmail.com>

On 05/08/2007 03:53 PM, Pekka Enberg wrote:

>> +static int __mitsumi_read_toc(struct mitsumi_cdrom *mcd)
>> +{
>> +       int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 + 1;
>> +       int retries;
>> +       int err = 0;
>> +
>> +       kfree(mcd->toc);
>> +
>> +       mcd->toc = kzalloc(tracks * sizeof *mcd->toc, GFP_KERNEL);
> 
> Perhaps we should use krealloc() + memset() here?

Earlier I had a patch lined up that checked the previous number of tracks 
against the current number and only freed the TOC array when they were not 
the same. The majority case is a data CD with one TOC entry meaning we just 
reuse the entry. You then have to keep the previous number of tracks though 
and it seemed a little pointless so I dropped it.

Another option is using a linked list for the TOC and reusing or allocating 
nodes upon reading the actual entry from the Q channel and freeing the rest 
when we got them all. Also seemed overly complex and the CDROMREADTOCENTRY 
gets slower ;-)

I admit my DOS inspired dislike of realloc() is largely pointless these days 
but, err... "E426: tag not found: krealloc". Would you perhaps like the 
list? Or the if (tracks != mcd->tracks) thing?

Rene.


  parent reply	other threads:[~2007-05-08 14:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-08  9:42 New Mitsumi legacy CD-ROM driver Rene Herman
2007-05-08  9:44 ` Rene Herman
2007-05-08 10:35 ` Jens Axboe
2007-05-08 13:39   ` Rene Herman
2007-05-08 13:49     ` Jens Axboe
2007-05-08 13:57       ` Pekka J Enberg
2007-05-08 14:04         ` Jens Axboe
2007-05-08 14:20           ` Rene Herman
2007-05-10 15:54       ` Rene Herman
2007-05-08 13:53 ` Pekka Enberg
2007-05-08 13:53   ` Jens Axboe
2007-05-08 14:17   ` Rene Herman [this message]
2007-05-08 14:34     ` Pekka J Enberg
2007-05-08 14:27   ` Pekka Enberg
2007-05-08 20:13 ` Ondrej Zary
2007-05-08 21:12   ` Bob Tracy
2007-05-10 16:03     ` Rene Herman
2007-05-10 15:59   ` Rene Herman

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=46408662.5070003@gmail.com \
    --to=rene.herman@gmail.com \
    --cc=akpm@osdl.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --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