@@ -542,6 +542,13 @@ static int lm3532_parse_als(struct lm3532_data *priv)
542542 return ret ;
543543}
544544
545+ static void gpio_set_low_action (void * data )
546+ {
547+ struct lm3532_data * priv = data ;
548+
549+ gpiod_direction_output (priv -> enable_gpio , 0 );
550+ }
551+
545552static int lm3532_parse_node (struct lm3532_data * priv )
546553{
547554 struct fwnode_handle * child = NULL ;
@@ -556,6 +563,12 @@ static int lm3532_parse_node(struct lm3532_data *priv)
556563 if (IS_ERR (priv -> enable_gpio ))
557564 priv -> enable_gpio = NULL ;
558565
566+ if (priv -> enable_gpio ) {
567+ ret = devm_add_action (& priv -> client -> dev , gpio_set_low_action , priv );
568+ if (ret )
569+ return ret ;
570+ }
571+
559572 priv -> regulator = devm_regulator_get (& priv -> client -> dev , "vin" );
560573 if (IS_ERR (priv -> regulator ))
561574 priv -> regulator = NULL ;
@@ -691,7 +704,10 @@ static int lm3532_probe(struct i2c_client *client)
691704 return ret ;
692705 }
693706
694- mutex_init (& drvdata -> lock );
707+ ret = devm_mutex_init (& client -> dev , & drvdata -> lock );
708+ if (ret )
709+ return ret ;
710+
695711 i2c_set_clientdata (client , drvdata );
696712
697713 ret = lm3532_parse_node (drvdata );
@@ -703,16 +719,6 @@ static int lm3532_probe(struct i2c_client *client)
703719 return ret ;
704720}
705721
706- static void lm3532_remove (struct i2c_client * client )
707- {
708- struct lm3532_data * drvdata = i2c_get_clientdata (client );
709-
710- mutex_destroy (& drvdata -> lock );
711-
712- if (drvdata -> enable_gpio )
713- gpiod_direction_output (drvdata -> enable_gpio , 0 );
714- }
715-
716722static const struct of_device_id of_lm3532_leds_match [] = {
717723 { .compatible = "ti,lm3532" , },
718724 {},
@@ -727,7 +733,6 @@ MODULE_DEVICE_TABLE(i2c, lm3532_id);
727733
728734static struct i2c_driver lm3532_i2c_driver = {
729735 .probe = lm3532_probe ,
730- .remove = lm3532_remove ,
731736 .id_table = lm3532_id ,
732737 .driver = {
733738 .name = LM3532_NAME ,
0 commit comments