[Alsa-devel] [RFC 05/12] snd-aoa: add i2sbus

Takashi Iwai tiwai at suse.de
Thu Jun 8 04:44:05 EST 2006


At Wed, 07 Jun 2006 15:09:14 +0200,
Johannes Berg wrote:
> 
> --- /dev/null
> +++ b/sound/aoa/soundbus/i2sbus/i2sbus-pcm.c
> +static int clock_and_divisors(int mclk, int sclk, int rate, int *out)
> +{
> +	/* sclk must be derived from mclk! */
> +	if (mclk % sclk)
> +		return -1;
> +	/* derive sclk register value */
> +	if (i2s_sf_sclkdiv(mclk / sclk, out))
> +		return -1;
> +
> +	if (I2S_CLOCK_SPEED_18MHz % (rate * mclk) == 0) {
> +		if (!i2s_sf_mclkdiv(I2S_CLOCK_SPEED_18MHz / rate / mclk, out)) {

I'd use "I2S_CLOCK_SPEED_18MHZ / (rate * mclk)"


> --- /dev/null
> +++ b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
> +static void i2sbus_release_dev(struct device *dev)
> +{
> +	struct i2sbus_dev *i2sdev;
> +	int i;
> +
> +	i2sdev = container_of(dev, struct i2sbus_dev, sound.ofdev.dev);
> +
> + 	if (i2sdev->intfregs) iounmap(i2sdev->intfregs);
> + 	if (i2sdev->out.dbdma) iounmap(i2sdev->out.dbdma);
> + 	if (i2sdev->in.dbdma) iounmap(i2sdev->in.dbdma);
> +	for (i=0;i<3;i++)
> +		if (i2sdev->allocated_resource[i])
> +			release_resource(i2sdev->allocated_resource[i]);

release_resource() doesn't kfree the record returned from
request_mem_region().  ALSA has a helper function
release_and_free_resource() that also does NULL check and kfree:

	for (i = 0; i < 3; i++)
		release_and_free_resource(i2sdev->allocated_resource[i]);

> +/* FIXME: look at device node refcounting */
> +static int i2sbus_add_dev(struct macio_dev *macio,
> +			  struct i2sbus_control *control,
> +			  struct device_node *np)
> +{
(snip)
> +	for (i=0;i<3;i++)
> +		if (dev->allocated_resource[i])
> +			release_resource(dev->allocated_resource[i]);

Ditto.


Takashi



More information about the Linuxppc-dev mailing list