[Alsa-devel] [RFC 3/8] snd-aoa: add soundbus

Takashi Iwai tiwai at suse.de
Fri Jun 2 23:53:25 EST 2006


At Thu, 01 Jun 2006 13:58:47 +0200,
Johannes Berg wrote:
> 
> --- /dev/null
> +++ b/sound/aoa/soundbus/sysfs.c
> +static ssize_t
> +compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	struct of_device *of;
> +	char *compat;
> +	int cplen;
> +	int length = 0;
> +
> +	of = &to_soundbus_device (dev)->ofdev;
> +	compat = (char *) get_property(of->node, "compatible", &cplen);
> +	if (!compat) {
> +		*buf = '\0';
> +		return 0;
> +	}
> +	while (cplen > 0) {
> +		int l;
> +		length += sprintf (buf, "%s\n", compat);
> +		buf += length;

This seems wrong.  The above should be

	l = sprintf(buf + length, "%s\n", compat);
	length += l;
	buf += l;

> +		l = strlen (compat) + 1;
> +		compat += l;
> +		cplen -= l;
> +	}
> +
> +	return length;
> +}
> +
> +static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
> +			      char *buf)
> +{
> +	struct soundbus_dev *sdev = to_soundbus_device(dev);
> +	struct of_device *of = &sdev->ofdev;
> +	int length;
> +
> +	if (strlen(sdev->modalias)) {
> +		length = snprintf (buf, 34, "%s\n", sdev->modalias);

sizeof(sdev->modalias) + 2?  But still strange if modalias has no
nul-end.

> +	} else {
> +		length = sprintf (buf, "of:N%sT%s\n", of->node->name, of->node->type);
> +	}

Remove braces for single-line if (and too long).


Takashi



More information about the Linuxppc-dev mailing list