Re: [RFC PATCH V2 1/2] introduce ALS sysfs class

From: Greg KH
Date: Thu Aug 06 2009 - 14:58:24 EST


On Thu, Aug 06, 2009 at 04:31:38PM +0800, Zhang Rui wrote:
> +#define PREFIX "ALS: "

This is not used.

> + /* sys I/F */
> + result = device_create_file(&als->device, &dev_attr_illuminance);
> + if (result)
> + goto unregister_device;
> +
> + result = device_create_file(&als->device, &dev_attr_desc);
> + if (result)
> + goto unregister_device;

These should be default attributes for the device, that way they get
created before userspace is told the device is there, removing any race
conditions you will have otherwise.

> +
> + return als;
> +
> +unregister_device:
> + device_unregister(&als->device);
> + return ERR_PTR(result);

And you weren't cleaning up the file if the second one failed.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/