Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1731imu; Thu, 8 Nov 2018 12:48:45 -0800 (PST) X-Google-Smtp-Source: AJdET5e9RDyZ/zQkQ3SFLuqy8E84aonvbOH7s/7fTLQt6Dex4dq604MvMxTdIDBsSpU/QvDLUPAh X-Received: by 2002:a17:902:22cc:: with SMTP id o12-v6mr6090230plg.108.1541710125536; Thu, 08 Nov 2018 12:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541710125; cv=none; d=google.com; s=arc-20160816; b=xJ7grq3IcmrPbhDn5XcFeQPusA80Gn9kJOjU2Xy+Ly4IWbn+DlsCiAQMMIS4E6dkE5 UndQ8w19ed448vhvnPTo2Rlzrjj9JOZyq3geIrlpQzJfdpT34GyeoL/kKW1NhPV0O6Ya yBWNh/DLUi4gI34MPp8fdbCvgTswFXhq8rLuEF9i3e4Ld7lB3QzjBFSOFEpnvr6aT3IM R9/HZRGar+NF95jXTbihCM/nt9a8+NAM61w22FR48cAFhSFa9PvmRx4I5mtYDEY9TWxw ijpVA7YEwITS2zDQ11G6crDYRg9shuSm5utdn0NP6mh6aAbRGh+eSMSFJLHglJvAjbJg GQaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=OnbchMLIDcjqSfR1Io6ecYB8sfiy4Kl7kr2DkbMD1g4=; b=fsKSyPOQDfG0eMpQfxnOlCYeyXGBVoqyhTLW+BMhBlVcDdPNUr++HncSEXstKLdBFR 7GsgpwJCD3D4vOIap49pwFM1NCY0k0SCpogJgQPTXPyEjBMcC40foggcw0wSqQ7ZVx0M ZpK0AQ37Xd2wPAziFUrnxiBoZ2bX7c+dLi0XzA7ha3JHTsM9RnWPLUen11G3OWJf7jtM dFXtfPvqMPjR2Q1ChQN8EMB900w/sfeeM9oKoqpM8QBHWoaGbniblVK51U2Y+lSbas4e VbJuBKRVmiL0GJQhDUUmjggUzLATGRpXcssV627KaqvPxEBnAgnjH4id9U6SlW33l5Zh 0zdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LMbE9E4A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17-v6si4878787pgh.56.2018.11.08.12.48.23; Thu, 08 Nov 2018 12:48:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LMbE9E4A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727375AbeKIGY6 (ORCPT + 99 others); Fri, 9 Nov 2018 01:24:58 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39830 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeKIGY5 (ORCPT ); Fri, 9 Nov 2018 01:24:57 -0500 Received: by mail-lj1-f193.google.com with SMTP id t9-v6so16062016ljh.6; Thu, 08 Nov 2018 12:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OnbchMLIDcjqSfR1Io6ecYB8sfiy4Kl7kr2DkbMD1g4=; b=LMbE9E4Aq9J2Kbk9w71wHgX8qb09qT8IShHXfzDWig5hnorVLQsggzFdDivhxYp8H1 zfjYdnP8cakYxmf0W+hE+6egH/iehjGwRKXdf5f99+6AOApKUQSMpLyhwk2PS62s2dC2 SyxnG/ME8F+OvFo9KPSu+a39eZS8Sts/Yo5JBt9JHGx8FRTIsd3jaYJ1VZ48b81Ijqjw 7cYUSh8UQ4gzYNodeZd+iyaONu//GKAYXdzXspxtbXXe+/eQE+rDqZ5XG7x8IPfBIWO7 gZfh5lsJ+NLB0FClGLg0ksbmzpAY7QqqnU5MdzH2kMhymWtZ8TEJZlYMcbacrpn9czFT hCqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OnbchMLIDcjqSfR1Io6ecYB8sfiy4Kl7kr2DkbMD1g4=; b=ULctiiaTCS4dSw/FD6HT9/3jb1XOico6Ure+C5xENzcnkAwYAiIF4dkJxlvYbhPV5k ACE08ej/uC20XkURyJDuQZnzNEsIVcqCw97xxUM/wDofkiAPBuQcDu8tyjAxKPknwFM5 d/H75uj/0X+nPM79wSjhKJssWyq9YxKJNG3bwN54zM+19oOiEAzIzxNt5dESh8z842S2 mvfLLoy7CmbteBq6C49nPpTZwHrDaB0NlZT04OT/coQ0jYBlXOqI/+Dhs6UhrvPyExsM gQ6cG/dNF19W9RWz8w4LgtCN21ZSSbSeu67InJja+/LZVBtJ+SO3sX0isF8IhCCNMurR PtAg== X-Gm-Message-State: AGRZ1gIpOuHftaQwcYXVG8WZoTrT9eW+dDyWPgwE66I5qa8b2r4GttTe UALyfrMdc0rgnLtwjB9efD2BFgOU X-Received: by 2002:a2e:5109:: with SMTP id f9-v6mr4056132ljb.52.1541710062555; Thu, 08 Nov 2018 12:47:42 -0800 (PST) Received: from [192.168.1.18] (dkl219.neoplus.adsl.tpnet.pl. [83.24.15.219]) by smtp.gmail.com with ESMTPSA id r1-v6sm879021ljb.64.2018.11.08.12.47.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 12:47:41 -0800 (PST) Subject: Re: [PATCH 01/24] leds: class: Improve LED and LED flash class registration API To: Dan Murphy , linux-leds@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, pavel@ucw.cz, robh@kernel.org, Baolin Wang , Daniel Mack , Linus Walleij , Oleh Kravchenko , Sakari Ailus , Simon Shields , Xiaotong Lu References: <1541542052-10081-1-git-send-email-jacek.anaszewski@gmail.com> <1541542052-10081-2-git-send-email-jacek.anaszewski@gmail.com> <166969ae-f5db-cb5f-9334-9934e23aa406@ti.com> From: Jacek Anaszewski Message-ID: <81b0ce3f-702f-952b-6f6f-336078a7008f@gmail.com> Date: Thu, 8 Nov 2018 21:47:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <166969ae-f5db-cb5f-9334-9934e23aa406@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dan, Thanks for the review. On 11/08/2018 06:50 PM, Dan Murphy wrote: > Jacek > > On 11/06/2018 04:07 PM, Jacek Anaszewski wrote: [...] >> >> /** >> - * of_led_classdev_register - register a new object of led_classdev class. >> + * led_classdev_register_ext - register a new object of led_classdev class. > > For this should the comment indicate a different between the extended and non-extended calls? > Like the _ext might say register a new object of led_classdev with init_data? > > Same comments for each addition below. Agreed, I will amend it as you propose. > Otherwise with Baolin's comments for 1/24 > > Acked-by: Dan Murphy > > Dan > >> * >> * @parent: parent of LED device >> * @led_cdev: the led_classdev structure for this device. >> - * @np: DT node describing this LED >> + * @init_data: LED class device initialization data >> */ >> -int of_led_classdev_register(struct device *parent, struct device_node *np, >> - struct led_classdev *led_cdev) >> +int led_classdev_register_ext(struct device *parent, >> + struct led_classdev *led_cdev, >> + struct led_init_data *init_data) >> { >> char name[LED_MAX_NAME_SIZE]; >> int ret; >> >> + if (init_data && init_data->name) { >> + led_cdev->name = init_data->name; >> + } else { >> + dev_info(parent, "init_data not available"); >> + } >> + >> ret = led_classdev_next_name(led_cdev->name, name, sizeof(name)); >> if (ret < 0) >> return ret; >> @@ -268,7 +276,8 @@ int of_led_classdev_register(struct device *parent, struct device_node *np, >> mutex_unlock(&led_cdev->led_access); >> return PTR_ERR(led_cdev->dev); >> } >> - led_cdev->dev->of_node = np; >> + if (init_data && init_data->fwnode) >> + led_cdev->dev->of_node = to_of_node(init_data->fwnode); >> >> if (ret) >> dev_warn(parent, "Led %s renamed to %s due to name collision", >> @@ -313,7 +322,7 @@ int of_led_classdev_register(struct device *parent, struct device_node *np, >> >> return 0; >> } >> -EXPORT_SYMBOL_GPL(of_led_classdev_register); >> +EXPORT_SYMBOL_GPL(led_classdev_register_ext); >> >> /** >> * led_classdev_unregister - unregisters a object of led_properties class. >> @@ -358,14 +367,15 @@ static void devm_led_classdev_release(struct device *dev, void *res) >> } >> >> /** >> - * devm_of_led_classdev_register - resource managed led_classdev_register() >> + * devm_led_classdev_register_ext - resource managed led_classdev_register_ext() >> * >> * @parent: parent of LED device >> * @led_cdev: the led_classdev structure for this device. >> + * @init_data: LED class device initialization data >> */ >> -int devm_of_led_classdev_register(struct device *parent, >> - struct device_node *np, >> - struct led_classdev *led_cdev) >> +int devm_led_classdev_register_ext(struct device *parent, >> + struct led_classdev *led_cdev, >> + struct led_init_data *init_data) >> { >> struct led_classdev **dr; >> int rc; >> @@ -374,7 +384,7 @@ int devm_of_led_classdev_register(struct device *parent, >> if (!dr) >> return -ENOMEM; >> >> - rc = of_led_classdev_register(parent, np, led_cdev); >> + rc = led_classdev_register_ext(parent, led_cdev, init_data); >> if (rc) { >> devres_free(dr); >> return rc; >> @@ -385,7 +395,7 @@ int devm_of_led_classdev_register(struct device *parent, >> >> return 0; >> } >> -EXPORT_SYMBOL_GPL(devm_of_led_classdev_register); >> +EXPORT_SYMBOL_GPL(devm_led_classdev_register_ext); >> >> static int devm_led_classdev_match(struct device *dev, void *res, void *data) >> { >> diff --git a/drivers/leds/leds-cr0014114.c b/drivers/leds/leds-cr0014114.c >> index 0e42624..1c82152 100644 >> --- a/drivers/leds/leds-cr0014114.c >> +++ b/drivers/leds/leds-cr0014114.c >> @@ -207,8 +207,7 @@ static int cr0014114_probe_dt(struct cr0014114 *priv) >> led->ldev.max_brightness = CR_MAX_BRIGHTNESS; >> led->ldev.brightness_set_blocking = cr0014114_set_sync; >> >> - ret = devm_of_led_classdev_register(priv->dev, np, >> - &led->ldev); >> + ret = devm_led_classdev_register(priv->dev, &led->ldev); >> if (ret) { >> dev_err(priv->dev, >> "failed to register LED device %s, err %d", >> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c >> index 32fa752..c87fbd3 100644 >> --- a/drivers/leds/leds-gpio.c >> +++ b/drivers/leds/leds-gpio.c >> @@ -112,7 +112,7 @@ static int create_gpio_led(const struct gpio_led *template, >> if (ret < 0) >> return ret; >> >> - return devm_of_led_classdev_register(parent, np, &led_dat->cdev); >> + return devm_led_classdev_register(parent, &led_dat->cdev); >> } >> >> struct gpio_leds_priv { >> diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h >> index 700efaa..28a73d0 100644 >> --- a/include/linux/led-class-flash.h >> +++ b/include/linux/led-class-flash.h >> @@ -90,15 +90,20 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( >> } >> >> /** >> - * led_classdev_flash_register - register a new object of led_classdev class >> - * with support for flash LEDs >> + * fwnode_led_classdev_flash_register - register a new object of led_classdev >> + * class with support for flash LEDs >> * @parent: the flash LED to register >> + * @fwnode: the flash LED fwnode handle >> * @fled_cdev: the led_classdev_flash structure for this device >> * >> * Returns: 0 on success or negative error value on failure >> */ >> -extern int led_classdev_flash_register(struct device *parent, >> - struct led_classdev_flash *fled_cdev); >> +extern int led_classdev_flash_register_ext(struct device *parent, >> + struct led_classdev_flash *fled_cdev, >> + struct led_init_data *init_data); >> + >> +#define led_classdev_flash_register(parent, fled_cdev) \ >> + led_classdev_flash_register_ext(parent, fled_cdev, NULL) >> >> /** >> * led_classdev_flash_unregister - unregisters an object of led_classdev class >> diff --git a/include/linux/leds.h b/include/linux/leds.h >> index 834683d..646c49a 100644 >> --- a/include/linux/leds.h >> +++ b/include/linux/leds.h >> @@ -20,6 +20,7 @@ >> #include >> #include >> #include >> +#include >> >> struct device; >> /* >> @@ -33,6 +34,13 @@ enum led_brightness { >> LED_FULL = 255, >> }; >> >> +struct led_init_data { >> + /* Device fwnode handle */ >> + struct fwnode_handle *fwnode; >> + /* Requested LED class device name */ >> + char name[LED_MAX_NAME_SIZE]; >> +}; >> + >> struct led_classdev { >> const char *name; >> enum led_brightness brightness; >> @@ -73,6 +81,7 @@ struct led_classdev { >> */ >> int (*brightness_set_blocking)(struct led_classdev *led_cdev, >> enum led_brightness brightness); >> + >> /* Get LED brightness level */ >> enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); >> >> @@ -123,16 +132,16 @@ struct led_classdev { >> struct mutex led_access; >> }; >> >> -extern int of_led_classdev_register(struct device *parent, >> - struct device_node *np, >> - struct led_classdev *led_cdev); >> -#define led_classdev_register(parent, led_cdev) \ >> - of_led_classdev_register(parent, NULL, led_cdev) >> -extern int devm_of_led_classdev_register(struct device *parent, >> - struct device_node *np, >> - struct led_classdev *led_cdev); >> -#define devm_led_classdev_register(parent, led_cdev) \ >> - devm_of_led_classdev_register(parent, NULL, led_cdev) >> +extern int led_classdev_register_ext(struct device *parent, >> + struct led_classdev *led_cdev, >> + struct led_init_data *init_data); >> +#define led_classdev_register(parent, led_cdev) \ >> + led_classdev_register_ext(parent, led_cdev, NULL) >> +extern int devm_led_classdev_register_ext(struct device *parent, >> + struct led_classdev *led_cdev, >> + struct led_init_data *init_data); >> +#define devm_led_classdev_register(parent, led_cdev) \ >> + devm_led_classdev_register_ext(parent, led_cdev, NULL) >> extern void led_classdev_unregister(struct led_classdev *led_cdev); >> extern void devm_led_classdev_unregister(struct device *parent, >> struct led_classdev *led_cdev); >> > > -- Best regards, Jacek Anaszewski