From: Ingi Kim <ingi2.kim@samsung.com>
To: Varka Bhadram <varkabhadram@gmail.com>
Cc: cooloney@gmail.com, rpurdie@rpsys.net, robh+dt@kernel.org,
pawel.moll@arm.com, mark.rutland@arm.com,
ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
sakari.ailus@iki.fi, j.anaszewski@samsung.com,
sw0312.kim@samsung.com, cw00.choi@samsung.com,
jh80.chung@samsung.com, ideal.song@samsung.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-leds@vger.kernel.org
Subject: Re: [PATCH v4 3/3] leds: Add ktd2692 flash LED driver
Date: Thu, 26 Mar 2015 10:43:20 +0900 [thread overview]
Message-ID: <55136438.9060303@samsung.com> (raw)
In-Reply-To: <55122B59.7050404@gmail.com>
Hi Varka,
On 2015년 03월 25일 12:28, Varka Bhadram wrote:
> On 03/25/2015 07:00 AM, Ingi Kim wrote:
>
>> This patch adds a driver to support the ktd2692 flash LEDs.
>> ktd2692 can control flash current by ExpressWire interface.
>>
>> Signed-off-by: Ingi Kim <ingi2.kim@samsung.com>
>> ---
>> drivers/leds/Kconfig | 9 +
>> drivers/leds/Makefile | 1 +
>> drivers/leds/leds-ktd2692.c | 412 ++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 422 insertions(+)
>> create mode 100644 drivers/leds/leds-ktd2692.c
>>
> (...)
>
>> +static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
>> + u32 *flash_timeout_us)
>> +{
>> + struct device_node *np = dev->of_node;
>> +
>
> Unnecessary one line space..
>
Oh, I missed it! Thanks
>> + int ret;
>> +
>> + led->ctrl_gpio = of_get_named_gpio(np, "ctrl-gpio", 0);
>> + if (!gpio_is_valid(led->ctrl_gpio)) {
>> + dev_err(dev, "no ctrl-gpio property found\n");
>> + return -EINVAL;
>> + }
>> +
>> + led->aux_gpio = of_get_named_gpio(np, "aux-gpio", 0);
>> + if (!gpio_is_valid(led->aux_gpio)) {
>> + dev_err(dev, "no aux-gpio property found\n");
>> + return -EINVAL;
>> + }
>> +
>> + ret = devm_gpio_request_one(dev, led->ctrl_gpio,
>> + GPIOF_OPEN_SOURCE, "ctrl-gpio");
>> + if (ret) {
>> + dev_err(dev, "failed to request ctrl-gpio %d error %d\n",
>> + led->ctrl_gpio, ret);
>> + return ret;
>> + }
>> +
>> + ret = devm_gpio_request_one(dev, led->aux_gpio,
>> + GPIOF_OPEN_SOURCE, "aux-gpio");
>> + if (ret) {
>> + dev_err(dev, "failed to request aux-gpio %d error %d\n",
>> + led->aux_gpio, ret);
>> + return ret;
>> + }
>> +
>> + ret = of_property_read_u32(np, "flash-timeout-us", flash_timeout_us);
>> + /* default setting */
>> + if (ret)
>> + *flash_timeout_us = KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US;
>> +
>> + return 0;
>> +}
>> +
>> +static const struct led_flash_ops flash_ops = {
>> + .strobe_set = ktd2692_led_flash_strobe_set,
>> + .timeout_set = ktd2692_led_flash_timeout_set,
>> +};
>> +
>> +static int ktd2692_probe(struct platform_device *pdev)
>> +{
>> + struct ktd2692_context *led;
>> + struct led_classdev *led_cdev;
>> + struct led_classdev_flash *fled_cdev;
>> + struct led_flash_setting flash_timeout;
>> + u32 flash_timeout_us;
>> + int ret;
>> +
>> + led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
>> + if (!led)
>> + return -ENOMEM;
>> +
>> + if (!pdev->dev.of_node)
>> + return -ENXIO;
>> +
>
> Above operation dt related. So if you do that in ktd2692_parse_dt(), it will be good
>
Good point!
I'll do that
>> + fled_cdev = &led->fled_cdev;
>> + led_cdev = &fled_cdev->led_cdev;
>> +
>> + ret = ktd2692_parse_dt(led, &pdev->dev, &flash_timeout_us);
>> + if (ret)
>> + return ret;
>> +
>> + led->regulator = devm_regulator_get(&pdev->dev, "vin");
>> + if (IS_ERR(led->regulator)) {
>> + dev_err(&pdev->dev, "regulator get failed\n");
>> + return PTR_ERR(led->regulator);
>> + }
>> +
>> + ktd2692_init_flash_timeout(flash_timeout_us, &flash_timeout);
>> +
>> + fled_cdev->timeout = flash_timeout;
>> + fled_cdev->ops = &flash_ops;
>> +
>> + led_cdev->name = KTD2692_DEFAULT_NAME;
>> + led_cdev->brightness_set = ktd2692_led_brightness_set;
>> + led_cdev->brightness_set_sync = ktd2692_led_brightness_set_sync;
>> + led_cdev->flags |= LED_CORE_SUSPENDRESUME;
>> + led_cdev->flags |= LED_DEV_CAP_FLASH;
>> +
>> + mutex_init(&led->lock);
>> + INIT_WORK(&led->work_brightness_set, ktd2692_brightness_set_work);
>> +
>> + platform_set_drvdata(pdev, led);
>> +
>> + ret = led_classdev_flash_register(&pdev->dev, fled_cdev);
>> + if (ret) {
>> + dev_err(&pdev->dev, "can't register LED %s\n", led_cdev->name);
>> + cancel_work_sync(&led->work_brightness_set);
>
> Is the above API is correct to use in this place.?
>
> cancel_work_sync — cancel a work and wait for it to finish...
>
> Work is not yet scheduled..?
>
> What about mutex destroy..?
>
Right, I should remove this API.
It seems to be useless in this place
And mutex_destroy() will be added, Thank you!
>> + return ret;
>> + }
>> +
>> + ktd2692_setup(led);
>> + ktd2692_led_regulator_enable(led);
>> +
>> + return 0;
>> +}
>> +
>> +static int ktd2692_remove(struct platform_device *pdev)
>> +{
>> + struct ktd2692_context *led = platform_get_drvdata(pdev);
>> +
>> + ktd2692_led_regulator_disable(led);
>> + 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 ktd2692_match[] = {
>> + { .compatible = "kinetic,ktd2692", },
>> + { /* sentinel */ },
>> +};
>> +
>> +static struct platform_driver ktd2692_driver = {
>> + .driver = {
>> + .name = "leds-ktd2692",
>> + .of_match_table = ktd2692_match,
>> + },
>> + .probe = ktd2692_probe,
>> + .remove = ktd2692_remove,
>> +};
>> +
>> +module_platform_driver(ktd2692_driver);
>> +
>> +MODULE_AUTHOR("Ingi Kim <ingi2.kim@samsung.com>");
>> +MODULE_DESCRIPTION("Kinetic KTD2692 LED driver");
>> +MODULE_LICENSE("GPL v2");
>
>
next prev parent reply other threads:[~2015-03-26 1:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 1:30 [PATCH v4 0/3] Add ktd2692 Flash LED driver using LED Flash class Ingi Kim
2015-03-25 1:30 ` [PATCH v4 1/3] of: Add vendor prefix for Kinetic technologies Ingi Kim
2015-03-25 1:30 ` [PATCH v4 2/3] leds: ktd2692: add device tree bindings for ktd2692 Ingi Kim
2015-03-25 3:31 ` Varka Bhadram
2015-03-26 1:43 ` Ingi Kim
2015-03-25 1:30 ` [PATCH v4 3/3] leds: Add ktd2692 flash LED driver Ingi Kim
2015-03-25 3:28 ` Varka Bhadram
2015-03-26 1:43 ` Ingi Kim [this message]
2015-03-25 13:53 ` Sakari Ailus
2015-03-26 4:56 ` Ingi Kim
2015-03-26 9:54 ` Sakari Ailus
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=55136438.9060303@samsung.com \
--to=ingi2.kim@samsung.com \
--cc=cooloney@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=ideal.song@samsung.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=j.anaszewski@samsung.com \
--cc=jh80.chung@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=rpurdie@rpsys.net \
--cc=sakari.ailus@iki.fi \
--cc=sw0312.kim@samsung.com \
--cc=varkabhadram@gmail.com \
/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