Re: [PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-07 Thread Grant Feng

Thanks for the review, I will rewrit it.

Grant

On 2020-08-06 23:00, Dan Murphy wrote:

Grant

On 8/6/20 1:21 AM, Grant Feng wrote:

generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
  drivers/leds/leds-is31fl319x.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c 
b/drivers/leds/leds-is31fl319x.c

index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
    /* register numbers */
  #define IS31FL319X_SHUTDOWN    0x00
@@ -61,6 +63,7 @@
  struct is31fl319x_chip {
  const struct is31fl319x_chipdef *cdef;
  struct i2c_client   *client;
+    struct gpio_desc    *sdb_pin;
  struct regmap   *regmap;
  struct mutex    lock;
  u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
  is31->audio_gain_db = min(is31->audio_gain_db,
    IS31FL319X_AUDIO_GAIN_DB_MAX);
  +    is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);


Since this is optional maybe use devm_gpiod_get_optional.

If this is required for stability then if the GPIO is not present then 
the parse_dt should return the error.


And use the devm_gpiod_get call.  Otherwise you are missing the 
gpiod_put when exiting or removing the driver.


Dan





Re: [PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-06 Thread Pavel Machek
Hi!
> On 8/6/20 1:21 AM, Grant Feng wrote:
> > generate a 5ms low pulse on sdb pin when startup, then the chip
> > becomes more stable in the complex EM environment.
> > 
> > Signed-off-by: Grant Feng 
> > ---
> >   drivers/leds/leds-is31fl319x.c | 12 
> >   1 file changed, 12 insertions(+)
> > 
> > diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
> > index ca6634b8683c..b4f70002cec9 100644
> > --- a/drivers/leds/leds-is31fl319x.c
> > +++ b/drivers/leds/leds-is31fl319x.c
> > @@ -16,6 +16,8 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> > +#include 
> >   /* register numbers */
> >   #define IS31FL319X_SHUTDOWN   0x00
> > @@ -61,6 +63,7 @@
> >   struct is31fl319x_chip {
> > const struct is31fl319x_chipdef *cdef;
> > struct i2c_client   *client;
> > +   struct gpio_desc*sdb_pin;
> > struct regmap   *regmap;
> > struct mutexlock;
> > u32 audio_gain_db;
> > @@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
> > is31->audio_gain_db = min(is31->audio_gain_db,
> >   IS31FL319X_AUDIO_GAIN_DB_MAX);
> > +   is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);
> 
> Since this is optional maybe use devm_gpiod_get_optional.
> 
> If this is required for stability then if the GPIO is not present then the
> parse_dt should return the error.
> 
> And use the devm_gpiod_get call.  Otherwise you are missing the gpiod_put
> when exiting or removing the driver.

Yep, thanks for the review, I dropped it from for-next.

And yes, this should be in series with device tree change, and we need
Rob 's ack.

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: PGP signature


Re: [PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-06 Thread Dan Murphy

Grant

On 8/6/20 1:21 AM, Grant Feng wrote:

generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
  drivers/leds/leds-is31fl319x.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  
  /* register numbers */

  #define IS31FL319X_SHUTDOWN   0x00
@@ -61,6 +63,7 @@
  struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*sdb_pin;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
is31->audio_gain_db = min(is31->audio_gain_db,
  IS31FL319X_AUDIO_GAIN_DB_MAX);
  
+	is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);


Since this is optional maybe use devm_gpiod_get_optional.

If this is required for stability then if the GPIO is not present then 
the parse_dt should return the error.


And use the devm_gpiod_get call.  Otherwise you are missing the 
gpiod_put when exiting or removing the driver.


Dan




[PATCH 1/2] leds: is31fl319x: Add sdb pin and generate a 5ms low pulse when startup

2020-08-06 Thread Grant Feng
generate a 5ms low pulse on sdb pin when startup, then the chip
becomes more stable in the complex EM environment.

Signed-off-by: Grant Feng 
---
 drivers/leds/leds-is31fl319x.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ca6634b8683c..b4f70002cec9 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -16,6 +16,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* register numbers */
 #define IS31FL319X_SHUTDOWN0x00
@@ -61,6 +63,7 @@
 struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client   *client;
+   struct gpio_desc*sdb_pin;
struct regmap   *regmap;
struct mutexlock;
u32 audio_gain_db;
@@ -265,6 +268,15 @@ static int is31fl319x_parse_dt(struct device *dev,
is31->audio_gain_db = min(is31->audio_gain_db,
  IS31FL319X_AUDIO_GAIN_DB_MAX);
 
+   is31->sdb_pin = gpiod_get(dev, "sdb", GPIOD_ASIS);
+   if (IS_ERR(is31->sdb_pin)) {
+   dev_warn(dev, "failed to get gpio_sdb, try default\r\n");
+   } else {
+   gpiod_direction_output(is31->sdb_pin, 0);
+   mdelay(5);
+   gpiod_direction_output(is31->sdb_pin, 1);
+   }
+
return 0;
 
 put_child_node:
-- 
2.17.1