[{"id":1757143,"web_url":"http://patchwork.ozlabs.org/comment/1757143/","msgid":"<1503646994.32695.3.camel@aj.id.au>","list_archive_url":null,"date":"2017-08-25T07:43:14","subject":"Re: [PATCH linux dev-4.10 2/5] leds: gpio: Allow LED to retain\n\tstate at shutdown","submitter":{"id":68332,"url":"http://patchwork.ozlabs.org/api/people/68332/","name":"Andrew Jeffery","email":"andrew@aj.id.au"},"content":"On Fri, 2017-08-25 at 09:40 +0200, Cédric Le Goater wrote:\n> On 08/25/2017 08:52 AM, Andrew Jeffery wrote:\n> > In some systems, such as BMCs, we want to retain the state of LEDs\n> > across a reboot of the BMC whilst the host remains up.\n> > \n> > > > Signed-off-by: Andrew Jeffery <andrew@aj.id.au>\n> > ---\n> >  drivers/leds/leds-gpio.c | 7 ++++++-\n> >  include/linux/leds.h     | 3 +++\n> >  2 files changed, 9 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c\n> > index d400dcaf4d29..061ab9220048 100644\n> > --- a/drivers/leds/leds-gpio.c\n> > +++ b/drivers/leds/leds-gpio.c\n> > @@ -134,6 +134,8 @@ static int create_gpio_led(const struct gpio_led *template,\n> > > >  \t\tled_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;\n> > > >  \tif (template->panic_indicator)\n> > > >  \t\tled_dat->cdev.flags |= LED_PANIC_INDICATOR;\n> > > > +\tif (template->retain_state_shutdown)\n> > > > +\t\tled_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN;\n> >  \n> > > >  \tret = gpiod_direction_output(led_dat->gpiod, state);\n> > > >  \tif (ret < 0)\n> > @@ -203,6 +205,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)\n> >  \n> > > >  \t\tif (fwnode_property_present(child, \"retain-state-suspended\"))\n> > > >  \t\t\tled.retain_state_suspended = 1;\n> > > > +\t\tif (fwnode_property_present(child, \"retain-state-shutdown\"))\n> > > > +\t\t\tled.retain_state_shutdown = 1;\n> > > >  \t\tif (fwnode_property_present(child, \"panic-indicator\"))\n> > > >  \t\t\tled.panic_indicator = 1;\n> >  \n> > @@ -265,7 +269,8 @@ static void gpio_led_shutdown(struct platform_device *pdev)\n> > > >  \tfor (i = 0; i < priv->num_leds; i++) {\n> > > >  \t\tstruct gpio_led_data *led = &priv->leds[i];\n> >  \n> > > > -\t\tgpio_led_set(&led->cdev, LED_OFF);\n> > > > +\t\tif (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN))\n> > > > +\t\t\tgpio_led_set(&led->cdev, LED_OFF);\n> > > >  \t}\n> >  }\n> >  \n> > diff --git a/include/linux/leds.h b/include/linux/leds.h\n> > index 569cb531094c..4d39f767f34a 100644\n> > --- a/include/linux/leds.h\n> > +++ b/include/linux/leds.h\n> > @@ -46,6 +46,8 @@ struct led_classdev {\n> > > >  #define LED_DEV_CAP_FLASH\t(1 << 18)\n> > > >  #define LED_HW_PLUGGABLE\t(1 << 19)\n> > > >  #define LED_PANIC_INDICATOR\t(1 << 20)\n> > +#define LED_BRIGHT_HW_CHANGED\t(1 << 21)\n> \n> where does this come from ? is it used ?\n\nAh, forgot to comment about that. It comes from upstream. I backported\nthe changes from on top of v4.13-rc6.\n\nI kept it from the conflict to justify using (1 << 22) below, to remain\ncompatible with upstream.\n\nAndrew\n\n> \n> Thanks,\n> \n> C.\n> \n> > > > +#define LED_RETAIN_AT_SHUTDOWN\t(1 << 22)\n> >  \n> > > >  \t/* set_brightness_work / blink_timer flags, atomic, private. */\n> > > > > >  \tunsigned long\t\twork_flags;\n> > @@ -378,6 +380,7 @@ struct gpio_led {\n> > > > > >  \tunsigned\tretain_state_suspended : 1;\n> > > > > >  \tunsigned\tpanic_indicator : 1;\n> > > > > >  \tunsigned\tdefault_state : 2;\n> > > > > > +\tunsigned\tretain_state_shutdown : 1;\n> > > >  \t/* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */\n> > > >  \tstruct gpio_desc *gpiod;\n> >  };\n> > \n> \n>","headers":{"Return-Path":"<openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","openbmc@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","openbmc@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xdtSp5Wynz9sRm\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 25 Aug 2017 17:43:38 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xdtSp2b6LzDrVt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 25 Aug 2017 17:43:38 +1000 (AEST)","from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com\n\t[66.111.4.26])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xdtSc5ts3zDqYR\n\tfor <openbmc@lists.ozlabs.org>; Fri, 25 Aug 2017 17:43:27 +1000 (AEST)","from compute4.internal (compute4.nyi.internal [10.202.2.44])\n\tby mailout.nyi.internal (Postfix) with ESMTP id 5A5B920C1B;\n\tFri, 25 Aug 2017 03:43:23 -0400 (EDT)","from frontend2 ([10.202.2.161])\n\tby compute4.internal (MEProxy); Fri, 25 Aug 2017 03:43:23 -0400","from keelia (ppp118-210-176-216.bras2.adl6.internode.on.net\n\t[118.210.176.216])\n\tby mail.messagingengine.com (Postfix) with ESMTPA id 759BF24767;\n\tFri, 25 Aug 2017 03:43:20 -0400 (EDT)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=aj.id.au header.i=@aj.id.au header.b=\"HU0QAAgM\";\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=messagingengine.com\n\theader.i=@messagingengine.com header.b=\"kOO+yMZK\"; \n\tdkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=aj.id.au header.i=@aj.id.au header.b=\"HU0QAAgM\";\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=messagingengine.com\n\theader.i=@messagingengine.com header.b=\"kOO+yMZK\"; \n\tdkim-atps=neutral","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=aj.id.au header.i=@aj.id.au header.b=\"HU0QAAgM\";\n\tdkim=pass (2048-bit key;\n\tunprotected) header.d=messagingengine.com\n\theader.i=@messagingengine.com\n\theader.b=\"kOO+yMZK\"; dkim-atps=neutral"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=cc\n\t:content-type:date:from:in-reply-to:message-id:mime-version\n\t:references:subject:to:x-me-sender:x-me-sender:x-sasl-enc\n\t:x-sasl-enc; s=fm1; bh=L+YSE2AIyS7H65tzDVl22iti3DwG7vynSQGVNdaYk\n\tok=; b=HU0QAAgMCK4KgTUmDLXwgYxEbeLDEgpEjCvYEB2ZME9jtQLr0QIIKLw7R\n\t5hP5bTGJeZyZSgrffayyb+1gZi30YHeTPGuNU8PZlSgyLL6foKvc2FFVZ2+Agpfb\n\tokggbFu3nXWiblWJ4sNDihTaiV6+sUksdnbZ16peHg1Yk0QbKpcIaavmmgck0TEB\n\t7mq8WUpLQKiQCxH0U0V2jujUkSy7DKpFrrENNpcvSRavJNNsYZYMmcTHbrRVuT70\n\tPHj1aSnoTmRTgTkC4L9GAh0kWBdn0mLV+6Li1yLJTElmi4camnX1Xs93+6xyxLkd\n\tWzlb535sS7sm3v1/lDRACjWEUh+6A==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=\n\tmessagingengine.com; h=cc:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to:x-me-sender\n\t:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=L+YSE2AIyS7H65tzDV\n\tl22iti3DwG7vynSQGVNdaYkok=; b=kOO+yMZK/DA8bnkeWm+YXrnQ5uC2QavNjo\n\teyz0TMExRSZK/jZms2pmY9/AXxeoiEeY4PGfpErLVG9wgdIGSh9qD4QQ5IPKIfoc\n\tPF+cvwJNglQhg7EI1TsS62qGB+8SkLVDrX9ZR1xSEjm4CJ7sS7MIsvIyZavIp6vW\n\t6owFkmJ7cXORcee1AP7iEY71lPL6be8zahoPoCP1rG6Mpo4LAaBJUWGZ6nGmmFfM\n\t1/eFDK+XGsk9Bg8Bi5nwuocNMo2JFy/Uyt2iJtjcLs+HwOQ/6dl/787SQbIE3JKH\n\ti7h6nd45DLWfQinvh2uu4HC7gbWyUzhtzhrx8RExPwSuQ02/0/Yw=="],"X-ME-Sender":"<xms:G9WfWcrvz4v8KuWT-1EDR95ze4c5w9QiGzaUHo48lGn0GzID7qRo9Q>","X-Sasl-enc":"BrvEgWaJ/W0HL45WOxzvJS0qUUtpc3nKIX9JvU3NnD6Q 1503647002","Message-ID":"<1503646994.32695.3.camel@aj.id.au>","Subject":"Re: [PATCH linux dev-4.10 2/5] leds: gpio: Allow LED to retain\n\tstate at shutdown","From":"Andrew Jeffery <andrew@aj.id.au>","To":"=?ISO-8859-1?Q?C=E9dric?= Le Goater <clg@kaod.org>, joel@jms.id.au","Date":"Fri, 25 Aug 2017 17:13:14 +0930","In-Reply-To":"<38dac127-c8ac-739b-82ba-806d36355cb9@kaod.org>","References":"<20170825065244.488-1-andrew@aj.id.au>\n\t<20170825065244.488-3-andrew@aj.id.au>\n\t<38dac127-c8ac-739b-82ba-806d36355cb9@kaod.org>","Content-Type":"multipart/signed; micalg=\"pgp-sha512\";\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"=-QcpWQbhAJNTyaugGqD3h\"","X-Mailer":"Evolution 3.22.6-1ubuntu1 ","Mime-Version":"1.0","X-BeenThere":"openbmc@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Development list for OpenBMC <openbmc.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/openbmc>,\n\t<mailto:openbmc-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/openbmc/>","List-Post":"<mailto:openbmc@lists.ozlabs.org>","List-Help":"<mailto:openbmc-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/openbmc>,\n\t<mailto:openbmc-request@lists.ozlabs.org?subject=subscribe>","Cc":"openbmc@lists.ozlabs.org, bjwyman@gmail.com, eajames@linux.vnet.ibm.com","Errors-To":"openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"openbmc\"\n\t<openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"}},{"id":1757163,"web_url":"http://patchwork.ozlabs.org/comment/1757163/","msgid":"<38dac127-c8ac-739b-82ba-806d36355cb9@kaod.org>","list_archive_url":null,"date":"2017-08-25T07:40:32","subject":"Re: [PATCH linux dev-4.10 2/5] leds: gpio: Allow LED to retain state\n\tat shutdown","submitter":{"id":68548,"url":"http://patchwork.ozlabs.org/api/people/68548/","name":"Cédric Le Goater","email":"clg@kaod.org"},"content":"On 08/25/2017 08:52 AM, Andrew Jeffery wrote:\n> In some systems, such as BMCs, we want to retain the state of LEDs\n> across a reboot of the BMC whilst the host remains up.\n> \n> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>\n> ---\n>  drivers/leds/leds-gpio.c | 7 ++++++-\n>  include/linux/leds.h     | 3 +++\n>  2 files changed, 9 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c\n> index d400dcaf4d29..061ab9220048 100644\n> --- a/drivers/leds/leds-gpio.c\n> +++ b/drivers/leds/leds-gpio.c\n> @@ -134,6 +134,8 @@ static int create_gpio_led(const struct gpio_led *template,\n>  \t\tled_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;\n>  \tif (template->panic_indicator)\n>  \t\tled_dat->cdev.flags |= LED_PANIC_INDICATOR;\n> +\tif (template->retain_state_shutdown)\n> +\t\tled_dat->cdev.flags |= LED_RETAIN_AT_SHUTDOWN;\n>  \n>  \tret = gpiod_direction_output(led_dat->gpiod, state);\n>  \tif (ret < 0)\n> @@ -203,6 +205,8 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)\n>  \n>  \t\tif (fwnode_property_present(child, \"retain-state-suspended\"))\n>  \t\t\tled.retain_state_suspended = 1;\n> +\t\tif (fwnode_property_present(child, \"retain-state-shutdown\"))\n> +\t\t\tled.retain_state_shutdown = 1;\n>  \t\tif (fwnode_property_present(child, \"panic-indicator\"))\n>  \t\t\tled.panic_indicator = 1;\n>  \n> @@ -265,7 +269,8 @@ static void gpio_led_shutdown(struct platform_device *pdev)\n>  \tfor (i = 0; i < priv->num_leds; i++) {\n>  \t\tstruct gpio_led_data *led = &priv->leds[i];\n>  \n> -\t\tgpio_led_set(&led->cdev, LED_OFF);\n> +\t\tif (!(led->cdev.flags & LED_RETAIN_AT_SHUTDOWN))\n> +\t\t\tgpio_led_set(&led->cdev, LED_OFF);\n>  \t}\n>  }\n>  \n> diff --git a/include/linux/leds.h b/include/linux/leds.h\n> index 569cb531094c..4d39f767f34a 100644\n> --- a/include/linux/leds.h\n> +++ b/include/linux/leds.h\n> @@ -46,6 +46,8 @@ struct led_classdev {\n>  #define LED_DEV_CAP_FLASH\t(1 << 18)\n>  #define LED_HW_PLUGGABLE\t(1 << 19)\n>  #define LED_PANIC_INDICATOR\t(1 << 20)\n> +#define LED_BRIGHT_HW_CHANGED\t(1 << 21)\n\nwhere does this come from ? is it used ?\n\nThanks,\n\nC.\n\n> +#define LED_RETAIN_AT_SHUTDOWN\t(1 << 22)\n>  \n>  \t/* set_brightness_work / blink_timer flags, atomic, private. */\n>  \tunsigned long\t\twork_flags;\n> @@ -378,6 +380,7 @@ struct gpio_led {\n>  \tunsigned\tretain_state_suspended : 1;\n>  \tunsigned\tpanic_indicator : 1;\n>  \tunsigned\tdefault_state : 2;\n> +\tunsigned\tretain_state_shutdown : 1;\n>  \t/* default_state should be one of LEDS_GPIO_DEFSTATE_(ON|OFF|KEEP) */\n>  \tstruct gpio_desc *gpiod;\n>  };\n>","headers":{"Return-Path":"<openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","openbmc@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","openbmc@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xdvBv0Xgjz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 25 Aug 2017 18:16:39 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xdvBt6Gs8zDrVy\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 25 Aug 2017 18:16:38 +1000 (AEST)","from 1.mo178.mail-out.ovh.net (1.mo178.mail-out.ovh.net\n\t[178.33.251.53])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xdvBl3Y8xzDrTh\n\tfor <openbmc@lists.ozlabs.org>; Fri, 25 Aug 2017 18:16:30 +1000 (AEST)","from player715.ha.ovh.net (b9.ovh.net [213.186.33.59])\n\tby mo178.mail-out.ovh.net (Postfix) with ESMTP id 8CE2B510EE\n\tfor <openbmc@lists.ozlabs.org>; Fri, 25 Aug 2017 09:40:40 +0200 (CEST)","from zorba.kaod.org (i15-les03-th2-31-37-69-229.sfr.lns.abo.bbox.fr\n\t[31.37.69.229]) (Authenticated sender: postmaster@kaod.org)\n\tby player715.ha.ovh.net (Postfix) with ESMTPSA id 15F951C009F;\n\tFri, 25 Aug 2017 09:40:32 +0200 (CEST)"],"Subject":"Re: [PATCH linux dev-4.10 2/5] leds: gpio: Allow LED to retain state\n\tat shutdown","To":"Andrew Jeffery <andrew@aj.id.au>, joel@jms.id.au","References":"<20170825065244.488-1-andrew@aj.id.au>\n\t<20170825065244.488-3-andrew@aj.id.au>","From":"=?UTF-8?Q?C=c3=a9dric_Le_Goater?= <clg@kaod.org>","Message-ID":"<38dac127-c8ac-739b-82ba-806d36355cb9@kaod.org>","Date":"Fri, 25 Aug 2017 09:40:32 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170825065244.488-3-andrew@aj.id.au>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Ovh-Tracer-Id":"15309705459661114114","X-VR-SPAMSTATE":"OK","X-VR-SPAMSCORE":"-100","X-VR-SPAMCAUSE":"gggruggvucftvghtrhhoucdtuddrfeelledrtdehgddufedvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm","X-BeenThere":"openbmc@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Development list for OpenBMC <openbmc.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/openbmc>,\n\t<mailto:openbmc-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/openbmc/>","List-Post":"<mailto:openbmc@lists.ozlabs.org>","List-Help":"<mailto:openbmc-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/openbmc>,\n\t<mailto:openbmc-request@lists.ozlabs.org?subject=subscribe>","Cc":"openbmc@lists.ozlabs.org, bjwyman@gmail.com, eajames@linux.vnet.ibm.com","Errors-To":"openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"openbmc\"\n\t<openbmc-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"}}]