Re: [PATCH v1 03/11] leds: Add driver for AAT1290 current regulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jacek,

On Fri, Mar 20, 2015 at 04:03:23PM +0100, Jacek Anaszewski wrote:
...
> +static int aat1290_led_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct aat1290_led *led;
> +	struct led_classdev *led_cdev;
> +	struct led_classdev_flash *fled_cdev;
> +	struct aat1290_led_settings settings;
> +	int ret;
> +
> +	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
> +	if (!led)
> +		return -ENOMEM;
> +
> +	led->pdev = pdev;
> +	platform_set_drvdata(pdev, led);
> +
> +	fled_cdev = &led->fled_cdev;
> +	led_cdev = &fled_cdev->led_cdev;
> +
> +	ret = aat1290_led_parse_dt(led);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (!led_cdev->name)
> +		led_cdev->name = AAT1290_NAME;
> +
> +	/* Init flash settings */
> +	aat1290_init_flash_settings(led, &settings);
> +
> +	fled_cdev->timeout = settings.flash_timeout;
> +	fled_cdev->ops = &flash_ops;
> +
> +	/* Init LED class */
> +	led_cdev->brightness_set = aat1290_led_brightness_set;
> +	led_cdev->brightness_set_sync = aat1290_led_brightness_set_sync;
> +	led_cdev->max_brightness = AAT1290_MM_CURRENT_SCALE_SIZE;
> +	led_cdev->flags |= LED_DEV_CAP_FLASH;
> +
> +	INIT_WORK(&led->work_brightness_set, aat1290_brightness_set_work);
> +
> +	/* Register in the LED subsystem. */
> +	ret = led_classdev_flash_register(&pdev->dev, fled_cdev);
> +	if (ret < 0)
> +		return ret;
> +
> +	mutex_init(&led->lock);

I think you must initialise the mutex before led_classdev_flash_register(),
as this exposes the device to the user. Remember mutex_destroy() in error
handling.

> +	return 0;
> +}
> +
> +static int aat1290_led_remove(struct platform_device *pdev)
> +{
> +	struct aat1290_led *led = platform_get_drvdata(pdev);
> +
> +	led_classdev_flash_unregister(&led->fled_cdev);
> +	cancel_work_sync(&led->work_brightness_set);
> +
> +	mutex_destroy(&led->lock);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id aat1290_led_dt_match[] = {
> +	{.compatible = "skyworks,aat1290"},

{ .compatible ... 1290" },

With the two issues fixed,

Acked-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>

> +	{},
> +};
> +
> +static struct platform_driver aat1290_led_driver = {
> +	.probe		= aat1290_led_probe,
> +	.remove		= aat1290_led_remove,
> +	.driver		= {
> +		.name	= "aat1290",
> +		.owner	= THIS_MODULE,
> +		.of_match_table = aat1290_led_dt_match,
> +	},
> +};
> +
> +module_platform_driver(aat1290_led_driver);
> +
> +MODULE_AUTHOR("Jacek Anaszewski <j.anaszewski@xxxxxxxxxxx>");
> +MODULE_DESCRIPTION("Skyworks Current Regulator for Flash LEDs");
> +MODULE_LICENSE("GPL v2");

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@xxxxxx	XMPP: sailus@xxxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux