All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Bryan Wu <cooloney@gmail.com>
Cc: Andreas Werner <andreas.werner@men.de>,
	lkml <linux-kernel@vger.kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	wim@iguana.be, linux-watchdog@vger.kernel.org,
	"rpurdie@rpsys.net" <rpurdie@rpsys.net>,
	Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Jean Delvare <jdelvare@suse.de>,
	lm-sensors@lm-sensors.org
Subject: Re: [PATCH v4 3/4] drivers/leds/leds-menf21bmc: introduce MEN 14F021P00 BMC LED driver
Date: Mon, 25 Aug 2014 12:05:59 -0700	[thread overview]
Message-ID: <20140825190559.GA29112@roeck-us.net> (raw)
In-Reply-To: <CAK5ve-KCv=kfkJK-x5m1sFiSBVH9FMUys_tLw5Cup=3rHLZxYQ@mail.gmail.com>

On Mon, Aug 25, 2014 at 11:53:32AM -0700, Bryan Wu wrote:
> On Wed, Aug 13, 2014 at 1:40 AM, Andreas Werner <andreas.werner@men.de> wrote:
> > Added driver to support the 14F021P00 BMC LEDs.
> > The BMC is a Board Management Controller including four LEDs which
> > can be switched on and off.
> >
> > Signed-off-by: Andreas Werner <andreas.werner@men.de>
> > ---
> >  drivers/leds/Kconfig          |   6 ++
> >  drivers/leds/Makefile         |   1 +
> >  drivers/leds/leds-menf21bmc.c | 131 ++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 138 insertions(+)
> >  create mode 100644 drivers/leds/leds-menf21bmc.c
> >
> > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> > index 27cf0cd..d38ff3f 100644
> > --- a/drivers/leds/Kconfig
> > +++ b/drivers/leds/Kconfig
> > @@ -458,6 +458,12 @@ config LEDS_OT200
> >           This option enables support for the LEDs on the Bachmann OT200.
> >           Say Y to enable LEDs on the Bachmann OT200.
> >
> > +config LEDS_MENF21BMC
> > +       tristate "LED support for the MEN 14F021P00 BMC"
> > +       depends on LEDS_CLASS && MFD_MENF21BMC
> > +       help
> > +         Say Y here to include support for the MEN 14F021P00 BMC LEDs.
> > +
> >  comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)"
> >
> >  config LEDS_BLINKM
> > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> > index 3c03666..cadc433 100644
> > --- a/drivers/leds/Makefile
> > +++ b/drivers/leds/Makefile
> > @@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_MAX8997)            += leds-max8997.o
> >  obj-$(CONFIG_LEDS_LM355x)              += leds-lm355x.o
> >  obj-$(CONFIG_LEDS_BLINKM)              += leds-blinkm.o
> >  obj-$(CONFIG_LEDS_VERSATILE)           += leds-versatile.o
> > +obj-$(CONFIG_LEDS_MENF21BMC)           += leds-menf21bmc.o
> >
> >  # LED SPI Drivers
> >  obj-$(CONFIG_LEDS_DAC124S085)          += leds-dac124s085.o
> > diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-menf21bmc.c
> > new file mode 100644
> > index 0000000..4621f72
> > --- /dev/null
> > +++ b/drivers/leds/leds-menf21bmc.c
> > @@ -0,0 +1,131 @@
> > +/*
> > + *  MEN 14F021P00 Board Management Controller (BMC) LEDs Driver.
> > + *
> > + *  This is the core LED driver of the MEN 14F021P00 BMC.
> > + *  There are four LEDs available which can be switched on and off.
> > + *  STATUS LED, HOT SWAP LED, USER LED 1, USER LED 2
> > + *
> > + *  Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH
> > + *
> > + *  This program is free software; you can redistribute  it and/or modify it
> > + *  under  the terms of  the GNU General  Public License as published by the
> > + *  Free Software Foundation;  either version 2 of the  License, or (at your
> > + *  option) any later version.
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/kernel.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/leds.h>
> > +#include <linux/i2c.h>
> > +
> > +#define BMC_CMD_LED_GET_SET    0xA0
> > +#define BMC_BIT_LED_STATUS     BIT(0)
> > +#define BMC_BIT_LED_HOTSWAP    BIT(1)
> > +#define BMC_BIT_LED_USER1      BIT(2)
> > +#define BMC_BIT_LED_USER2      BIT(3)
> > +
> > +struct menf21bmc_led {
> > +       struct led_classdev cdev;
> > +       u8 led_bit;
> > +       const char *name;
> > +       struct i2c_client *i2c_client;
> > +};
> > +
> > +static struct menf21bmc_led leds[] = {
> > +       {
> > +               .name = "menf21bmc:led_status",
> > +               .led_bit = BMC_BIT_LED_STATUS,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_hotswap",
> > +               .led_bit = BMC_BIT_LED_HOTSWAP,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_user1",
> > +               .led_bit = BMC_BIT_LED_USER1,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_user2",
> > +               .led_bit = BMC_BIT_LED_USER2,
> > +       }
> > +};
> > +
> > +static DEFINE_MUTEX(led_lock);
> > +
> > +static void
> > +menf21bmc_led_set(struct led_classdev *led_cdev, enum led_brightness value)
> > +{
> > +       int led_val;
> > +       struct menf21bmc_led *led = container_of(led_cdev,
> > +                                       struct menf21bmc_led, cdev);
> > +
> > +       mutex_lock(&led_lock);
> > +       led_val = i2c_smbus_read_byte_data(led->i2c_client,
> > +                                               BMC_CMD_LED_GET_SET);
> > +       if (led_val < 0)
> > +               goto err_out;
> > +
> > +       if (value == LED_OFF)
> > +               led_val &= ~led->led_bit;
> > +       else
> > +               led_val |= led->led_bit;
> > +
> > +       i2c_smbus_write_byte_data(led->i2c_client,
> > +                                       BMC_CMD_LED_GET_SET, led_val);
> > +err_out:
> > +       mutex_unlock(&led_lock);
> > +}
> > +
> > +static int menf21bmc_led_probe(struct platform_device *pdev)
> > +{
> > +       int i;
> > +       int ret;
> > +       struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent);
> > +
> > +       for (i = 0; i < ARRAY_SIZE(leds); i++) {
> > +               leds[i].cdev.name = leds[i].name;
> > +               leds[i].cdev.brightness_set = menf21bmc_led_set;
> > +               leds[i].i2c_client = i2c_client;
> > +               ret = led_classdev_register(&pdev->dev, &leds[i].cdev);
> > +               if (ret < 0)
> > +                       goto err_free_leds;
> > +       }
> > +       dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enabled\n");
> > +
> > +       return 0;
> > +
> > +err_free_leds:
> > +       dev_err(&pdev->dev, "failed to register LED device\n");
> > +
> > +       for (i = i - 1; i >= 0; i--)
> > +               led_classdev_unregister(&leds[i].cdev);
> > +
> > +       return ret;
> > +}
> > +
> > +static int menf21bmc_led_remove(struct platform_device *pdev)
> > +{
> > +       int i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(leds); i++)
> > +               led_classdev_unregister(&leds[i].cdev);
> > +
> > +       return 0;
> > +}
> > +
> > +static struct platform_driver menf21bmc_led = {
> > +       .probe          = menf21bmc_led_probe,
> > +       .remove         = menf21bmc_led_remove,
> > +       .driver         = {
> > +               .name           = "menf21bmc_led",
> > +               .owner          = THIS_MODULE,
> > +       },
> > +};
> > +
> 
> I still think this driver should be an I2C driver which is simply than
> a platform driver.
> Did I miss some discussion about this in our email?
> 
It is not possible to instantiate multiple drivers (watchdog, hwmon, led
in this case) with a single i2c chip.

Thanks,
Guenter

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Bryan Wu <cooloney@gmail.com>
Cc: Andreas Werner <andreas.werner@men.de>,
	lkml <linux-kernel@vger.kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	wim@iguana.be, linux-watchdog@vger.kernel.org,
	"rpurdie@rpsys.net" <rpurdie@rpsys.net>,
	Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Jean Delvare <jdelvare@suse.de>,
	lm-sensors@lm-sensors.org
Subject: Re: [lm-sensors] [PATCH v4 3/4] drivers/leds/leds-menf21bmc: introduce MEN 14F021P00 BMC LED driver
Date: Mon, 25 Aug 2014 19:05:59 +0000	[thread overview]
Message-ID: <20140825190559.GA29112@roeck-us.net> (raw)
In-Reply-To: <CAK5ve-KCv=kfkJK-x5m1sFiSBVH9FMUys_tLw5Cup=3rHLZxYQ@mail.gmail.com>

On Mon, Aug 25, 2014 at 11:53:32AM -0700, Bryan Wu wrote:
> On Wed, Aug 13, 2014 at 1:40 AM, Andreas Werner <andreas.werner@men.de> wrote:
> > Added driver to support the 14F021P00 BMC LEDs.
> > The BMC is a Board Management Controller including four LEDs which
> > can be switched on and off.
> >
> > Signed-off-by: Andreas Werner <andreas.werner@men.de>
> > ---
> >  drivers/leds/Kconfig          |   6 ++
> >  drivers/leds/Makefile         |   1 +
> >  drivers/leds/leds-menf21bmc.c | 131 ++++++++++++++++++++++++++++++++++++++++++
> >  3 files changed, 138 insertions(+)
> >  create mode 100644 drivers/leds/leds-menf21bmc.c
> >
> > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> > index 27cf0cd..d38ff3f 100644
> > --- a/drivers/leds/Kconfig
> > +++ b/drivers/leds/Kconfig
> > @@ -458,6 +458,12 @@ config LEDS_OT200
> >           This option enables support for the LEDs on the Bachmann OT200.
> >           Say Y to enable LEDs on the Bachmann OT200.
> >
> > +config LEDS_MENF21BMC
> > +       tristate "LED support for the MEN 14F021P00 BMC"
> > +       depends on LEDS_CLASS && MFD_MENF21BMC
> > +       help
> > +         Say Y here to include support for the MEN 14F021P00 BMC LEDs.
> > +
> >  comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)"
> >
> >  config LEDS_BLINKM
> > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> > index 3c03666..cadc433 100644
> > --- a/drivers/leds/Makefile
> > +++ b/drivers/leds/Makefile
> > @@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_MAX8997)            += leds-max8997.o
> >  obj-$(CONFIG_LEDS_LM355x)              += leds-lm355x.o
> >  obj-$(CONFIG_LEDS_BLINKM)              += leds-blinkm.o
> >  obj-$(CONFIG_LEDS_VERSATILE)           += leds-versatile.o
> > +obj-$(CONFIG_LEDS_MENF21BMC)           += leds-menf21bmc.o
> >
> >  # LED SPI Drivers
> >  obj-$(CONFIG_LEDS_DAC124S085)          += leds-dac124s085.o
> > diff --git a/drivers/leds/leds-menf21bmc.c b/drivers/leds/leds-menf21bmc.c
> > new file mode 100644
> > index 0000000..4621f72
> > --- /dev/null
> > +++ b/drivers/leds/leds-menf21bmc.c
> > @@ -0,0 +1,131 @@
> > +/*
> > + *  MEN 14F021P00 Board Management Controller (BMC) LEDs Driver.
> > + *
> > + *  This is the core LED driver of the MEN 14F021P00 BMC.
> > + *  There are four LEDs available which can be switched on and off.
> > + *  STATUS LED, HOT SWAP LED, USER LED 1, USER LED 2
> > + *
> > + *  Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH
> > + *
> > + *  This program is free software; you can redistribute  it and/or modify it
> > + *  under  the terms of  the GNU General  Public License as published by the
> > + *  Free Software Foundation;  either version 2 of the  License, or (at your
> > + *  option) any later version.
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/kernel.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/leds.h>
> > +#include <linux/i2c.h>
> > +
> > +#define BMC_CMD_LED_GET_SET    0xA0
> > +#define BMC_BIT_LED_STATUS     BIT(0)
> > +#define BMC_BIT_LED_HOTSWAP    BIT(1)
> > +#define BMC_BIT_LED_USER1      BIT(2)
> > +#define BMC_BIT_LED_USER2      BIT(3)
> > +
> > +struct menf21bmc_led {
> > +       struct led_classdev cdev;
> > +       u8 led_bit;
> > +       const char *name;
> > +       struct i2c_client *i2c_client;
> > +};
> > +
> > +static struct menf21bmc_led leds[] = {
> > +       {
> > +               .name = "menf21bmc:led_status",
> > +               .led_bit = BMC_BIT_LED_STATUS,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_hotswap",
> > +               .led_bit = BMC_BIT_LED_HOTSWAP,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_user1",
> > +               .led_bit = BMC_BIT_LED_USER1,
> > +       },
> > +       {
> > +               .name = "menf21bmc:led_user2",
> > +               .led_bit = BMC_BIT_LED_USER2,
> > +       }
> > +};
> > +
> > +static DEFINE_MUTEX(led_lock);
> > +
> > +static void
> > +menf21bmc_led_set(struct led_classdev *led_cdev, enum led_brightness value)
> > +{
> > +       int led_val;
> > +       struct menf21bmc_led *led = container_of(led_cdev,
> > +                                       struct menf21bmc_led, cdev);
> > +
> > +       mutex_lock(&led_lock);
> > +       led_val = i2c_smbus_read_byte_data(led->i2c_client,
> > +                                               BMC_CMD_LED_GET_SET);
> > +       if (led_val < 0)
> > +               goto err_out;
> > +
> > +       if (value = LED_OFF)
> > +               led_val &= ~led->led_bit;
> > +       else
> > +               led_val |= led->led_bit;
> > +
> > +       i2c_smbus_write_byte_data(led->i2c_client,
> > +                                       BMC_CMD_LED_GET_SET, led_val);
> > +err_out:
> > +       mutex_unlock(&led_lock);
> > +}
> > +
> > +static int menf21bmc_led_probe(struct platform_device *pdev)
> > +{
> > +       int i;
> > +       int ret;
> > +       struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent);
> > +
> > +       for (i = 0; i < ARRAY_SIZE(leds); i++) {
> > +               leds[i].cdev.name = leds[i].name;
> > +               leds[i].cdev.brightness_set = menf21bmc_led_set;
> > +               leds[i].i2c_client = i2c_client;
> > +               ret = led_classdev_register(&pdev->dev, &leds[i].cdev);
> > +               if (ret < 0)
> > +                       goto err_free_leds;
> > +       }
> > +       dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enabled\n");
> > +
> > +       return 0;
> > +
> > +err_free_leds:
> > +       dev_err(&pdev->dev, "failed to register LED device\n");
> > +
> > +       for (i = i - 1; i >= 0; i--)
> > +               led_classdev_unregister(&leds[i].cdev);
> > +
> > +       return ret;
> > +}
> > +
> > +static int menf21bmc_led_remove(struct platform_device *pdev)
> > +{
> > +       int i;
> > +
> > +       for (i = 0; i < ARRAY_SIZE(leds); i++)
> > +               led_classdev_unregister(&leds[i].cdev);
> > +
> > +       return 0;
> > +}
> > +
> > +static struct platform_driver menf21bmc_led = {
> > +       .probe          = menf21bmc_led_probe,
> > +       .remove         = menf21bmc_led_remove,
> > +       .driver         = {
> > +               .name           = "menf21bmc_led",
> > +               .owner          = THIS_MODULE,
> > +       },
> > +};
> > +
> 
> I still think this driver should be an I2C driver which is simply than
> a platform driver.
> Did I miss some discussion about this in our email?
> 
It is not possible to instantiate multiple drivers (watchdog, hwmon, led
in this case) with a single i2c chip.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  reply	other threads:[~2014-08-25 19:06 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13  8:38 [PATCH v4 0/4] Introduce MEN 14F021P BMC driver series Andreas Werner
2014-08-13  8:38 ` [lm-sensors] " Andreas Werner
2014-08-13  8:38 ` Andreas Werner
2014-08-13  8:39 ` [PATCH v4 1/4] drivers/mfd/menf21bmc: introduce MEN 14F021P00 BMC MFD Core driver Andreas Werner
2014-08-13  8:39   ` [lm-sensors] " Andreas Werner
2014-08-13  8:39   ` Andreas Werner
2014-08-21 11:30   ` Lee Jones
2014-08-21 11:30     ` [lm-sensors] " Lee Jones
2014-08-21 11:30     ` Lee Jones
2014-08-21 13:57     ` Andreas Werner
2014-08-21 13:57       ` Andreas Werner
2014-08-21 13:57       ` [lm-sensors] " Andreas Werner
2014-08-21 13:57       ` Andreas Werner
2014-08-21 13:25       ` Lee Jones
2014-08-21 13:25         ` [lm-sensors] " Lee Jones
2014-08-21 13:25         ` Lee Jones
2014-08-13  8:39 ` [PATCH v4 2/4] drivers/watchdog/menf21bmc_wdt: introduce MEN 14F021P00 BMC Watchdog driver Andreas Werner
2014-08-13  8:39   ` [lm-sensors] [PATCH v4 2/4] drivers/watchdog/menf21bmc_wdt: introduce MEN 14F021P00 BMC Watchdog dri Andreas Werner
2014-08-13  8:39   ` [PATCH v4 2/4] drivers/watchdog/menf21bmc_wdt: introduce MEN 14F021P00 BMC Watchdog driver Andreas Werner
2014-08-21 18:42   ` Guenter Roeck
2014-08-21 18:42     ` [lm-sensors] [PATCH v4 2/4] drivers/watchdog/menf21bmc_wdt: introduce MEN 14F021P00 BMC Watchdog Guenter Roeck
2014-08-13  8:40 ` [PATCH v4 3/4] drivers/leds/leds-menf21bmc: introduce MEN 14F021P00 BMC LED driver Andreas Werner
2014-08-13  8:40   ` [lm-sensors] " Andreas Werner
2014-08-13  8:40   ` Andreas Werner
2014-08-25 18:53   ` Bryan Wu
2014-08-25 18:53     ` [lm-sensors] " Bryan Wu
2014-08-25 19:05     ` Guenter Roeck [this message]
2014-08-25 19:05       ` Guenter Roeck
2014-08-13  8:40 ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Andreas Werner
2014-08-13  8:40   ` [lm-sensors] " Andreas Werner
2014-08-13  8:40   ` Andreas Werner
2014-08-21 18:37   ` Guenter Roeck
2014-08-21 18:37     ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Guenter Roeck
2014-08-22  8:38     ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Andreas Werner
2014-08-22  8:38       ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Andreas Werner
2014-08-22  8:38       ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Andreas Werner
2014-08-22  9:02       ` Guenter Roeck
2014-08-22  9:02         ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Guenter Roeck
2014-08-21 18:45   ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Guenter Roeck
2014-08-21 18:45     ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Guenter Roeck
2014-08-22  8:39     ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Andreas Werner
2014-08-22  8:39       ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Andreas Werner
2014-08-22  8:39       ` [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driver Andreas Werner
2014-08-22  9:04       ` Guenter Roeck
2014-08-22  9:04         ` [lm-sensors] [PATCH v4 4/4] drivers/hwmon/menf21bmc_hwmon: introduce MEN14F021P00 BMC HWMON driv Guenter Roeck

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=20140825190559.GA29112@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andreas.werner@men.de \
    --cc=cooloney@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=rpurdie@rpsys.net \
    --cc=sameo@linux.intel.com \
    --cc=wim@iguana.be \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.