linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Match data improvements for bq2515x driver
@ 2023-09-02 20:05 Biju Das
  2023-09-02 20:05 ` [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe() Biju Das
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Biju Das @ 2023-09-02 20:05 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Biju Das, linux-pm, linux-kernel, Biju Das, Andy Shevchenko

This patch series aims to add match data improvements for bq2515x driver.

This patch series is only compile tested.

Biju Das (2):
  power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
  power: supply: bq2515x: Some cleanups

 drivers/power/supply/bq2515x_charger.c | 65 ++++++++++++--------------
 1 file changed, 31 insertions(+), 34 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
  2023-09-02 20:05 [PATCH 0/2] Match data improvements for bq2515x driver Biju Das
@ 2023-09-02 20:05 ` Biju Das
  2023-09-04 10:12   ` Andy Shevchenko
  2023-09-02 20:05 ` [PATCH 2/2] power: supply: bq2515x: Some cleanups Biju Das
  2023-09-12 21:45 ` [PATCH 0/2] Match data improvements for bq2515x driver Sebastian Reichel
  2 siblings, 1 reply; 8+ messages in thread
From: Biju Das @ 2023-09-02 20:05 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Biju Das, linux-pm, linux-kernel, Biju Das, Andy Shevchenko

Add struct bq2515x_info and replace device_id->info in struct
bq2515x_device.

Simpilfy bq2515x_read_properties() and probe() by adding struct
bq2425x_chip_info as match data for OF/ID tables and use
i2c_get_match_data for retrieving match data instead of ID lookup.

Drop enum bq2515x_id as there is no user.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/power/supply/bq2515x_charger.c | 61 ++++++++++++--------------
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c
index 1dbacc9b015d..ada4532fda45 100644
--- a/drivers/power/supply/bq2515x_charger.c
+++ b/drivers/power/supply/bq2515x_charger.c
@@ -147,9 +147,14 @@ struct bq2515x_init_data {
 	int iprechg;
 };
 
-enum bq2515x_id {
-	BQ25150,
-	BQ25155,
+/**
+ * struct bq2515x_info -
+ * @regmap_config: register map config
+ * @ilim: input current limit
+ */
+struct bq2515x_info {
+	const struct regmap_config *regmap_config;
+	int ilim;
 };
 
 /**
@@ -164,8 +169,8 @@ enum bq2515x_id {
  * @ac_detect_gpio: power good (PG) pin
  * @ce_gpio: charge enable (CE) pin
  *
+ * @info: device info
  * @model_name: string value describing device model
- * @device_id: value of device_id
  * @mains_online: boolean value indicating power supply online
  *
  * @init_data: charger initialization data structure
@@ -181,8 +186,8 @@ struct bq2515x_device {
 	struct gpio_desc *ac_detect_gpio;
 	struct gpio_desc *ce_gpio;
 
+	const struct bq2515x_info *info;
 	char model_name[I2C_NAME_SIZE];
-	int device_id;
 	bool mains_online;
 
 	struct bq2515x_init_data init_data;
@@ -998,16 +1003,8 @@ static int bq2515x_read_properties(struct bq2515x_device *bq2515x)
 	ret = device_property_read_u32(bq2515x->dev,
 				      "input-current-limit-microamp",
 				      &bq2515x->init_data.ilim);
-	if (ret) {
-		switch (bq2515x->device_id) {
-		case BQ25150:
-			bq2515x->init_data.ilim = BQ25150_DEFAULT_ILIM_UA;
-			break;
-		case BQ25155:
-			bq2515x->init_data.ilim = BQ25155_DEFAULT_ILIM_UA;
-			break;
-		}
-	}
+	if (ret)
+		bq2515x->init_data.ilim = bq2515x->info->ilim;
 
 	bq2515x->ac_detect_gpio = devm_gpiod_get_optional(bq2515x->dev,
 						   "ac-detect", GPIOD_IN);
@@ -1094,19 +1091,9 @@ static int bq2515x_probe(struct i2c_client *client)
 
 	strncpy(bq2515x->model_name, id->name, I2C_NAME_SIZE);
 
-	bq2515x->device_id = id->driver_data;
-
-	switch (bq2515x->device_id) {
-	case BQ25150:
-		bq2515x->regmap = devm_regmap_init_i2c(client,
-						&bq25150_regmap_config);
-		break;
-	case BQ25155:
-		bq2515x->regmap = devm_regmap_init_i2c(client,
-						&bq25155_regmap_config);
-		break;
-	}
-
+	bq2515x->info = i2c_get_match_data(client);
+	bq2515x->regmap = devm_regmap_init_i2c(client,
+					       bq2515x->info->regmap_config);
 	if (IS_ERR(bq2515x->regmap)) {
 		dev_err(dev, "failed to allocate register map\n");
 		return PTR_ERR(bq2515x->regmap);
@@ -1139,16 +1126,26 @@ static int bq2515x_probe(struct i2c_client *client)
 	return 0;
 }
 
+static const struct bq2515x_info bq25150 = {
+	.regmap_config = &bq25150_regmap_config,
+	.ilim = BQ25150_DEFAULT_ILIM_UA,
+};
+
+static const struct bq2515x_info bq25155 = {
+	.regmap_config = &bq25155_regmap_config,
+	.ilim = BQ25155_DEFAULT_ILIM_UA,
+};
+
 static const struct i2c_device_id bq2515x_i2c_ids[] = {
-	{ "bq25150", BQ25150, },
-	{ "bq25155", BQ25155, },
+	{ "bq25150", (kernel_ulong_t)&bq25150 },
+	{ "bq25155", (kernel_ulong_t)&bq25155 },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, bq2515x_i2c_ids);
 
 static const struct of_device_id bq2515x_of_match[] = {
-	{ .compatible = "ti,bq25150", },
-	{ .compatible = "ti,bq25155", },
+	{ .compatible = "ti,bq25150", .data = &bq25150 },
+	{ .compatible = "ti,bq25155", .data = &bq25155 },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, bq2515x_of_match);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] power: supply: bq2515x: Some cleanups
  2023-09-02 20:05 [PATCH 0/2] Match data improvements for bq2515x driver Biju Das
  2023-09-02 20:05 ` [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe() Biju Das
@ 2023-09-02 20:05 ` Biju Das
  2023-09-04 10:10   ` Andy Shevchenko
  2023-09-12 21:45 ` [PATCH 0/2] Match data improvements for bq2515x driver Sebastian Reichel
  2 siblings, 1 reply; 8+ messages in thread
From: Biju Das @ 2023-09-02 20:05 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Biju Das, linux-pm, linux-kernel, Biju Das, Andy Shevchenko

Some cleanups:
 * Remove trailing comma in the terminator entry for OF/ID table.
 * Drop a space from terminator entry for OF table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/power/supply/bq2515x_charger.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/bq2515x_charger.c b/drivers/power/supply/bq2515x_charger.c
index ada4532fda45..49fa6386a509 100644
--- a/drivers/power/supply/bq2515x_charger.c
+++ b/drivers/power/supply/bq2515x_charger.c
@@ -1139,14 +1139,14 @@ static const struct bq2515x_info bq25155 = {
 static const struct i2c_device_id bq2515x_i2c_ids[] = {
 	{ "bq25150", (kernel_ulong_t)&bq25150 },
 	{ "bq25155", (kernel_ulong_t)&bq25155 },
-	{},
+	{}
 };
 MODULE_DEVICE_TABLE(i2c, bq2515x_i2c_ids);
 
 static const struct of_device_id bq2515x_of_match[] = {
 	{ .compatible = "ti,bq25150", .data = &bq25150 },
 	{ .compatible = "ti,bq25155", .data = &bq25155 },
-	{ },
+	{}
 };
 MODULE_DEVICE_TABLE(of, bq2515x_of_match);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] power: supply: bq2515x: Some cleanups
  2023-09-02 20:05 ` [PATCH 2/2] power: supply: bq2515x: Some cleanups Biju Das
@ 2023-09-04 10:10   ` Andy Shevchenko
  2023-09-04 10:11     ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2023-09-04 10:10 UTC (permalink / raw)
  To: Biju Das; +Cc: Sebastian Reichel, linux-pm, linux-kernel, Biju Das

On Sat, Sep 02, 2023 at 09:05:18PM +0100, Biju Das wrote:
> Some cleanups:
>  * Remove trailing comma in the terminator entry for OF/ID table.
>  * Drop a space from terminator entry for OF table.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Btw, in all similar patches you may add the reason(s) why you are doing that:

1/ unification;
2/ making code robust against (theoretical) misrebases or other similar things
   where the new entry goes _after_ the termination without compiler noticing.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] power: supply: bq2515x: Some cleanups
  2023-09-04 10:10   ` Andy Shevchenko
@ 2023-09-04 10:11     ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2023-09-04 10:11 UTC (permalink / raw)
  To: Biju Das; +Cc: Sebastian Reichel, linux-pm, linux-kernel, Biju Das

On Mon, Sep 04, 2023 at 01:10:04PM +0300, Andy Shevchenko wrote:
> On Sat, Sep 02, 2023 at 09:05:18PM +0100, Biju Das wrote:
> > Some cleanups:
> >  * Remove trailing comma in the terminator entry for OF/ID table.
> >  * Drop a space from terminator entry for OF table.
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Btw, in all similar patches you may add the reason(s) why you are doing that:
> 
> 1/ unification;
> 2/ making code robust against (theoretical) misrebases or other similar things
>    where the new entry goes _after_ the termination without compiler noticing.

I.o.w. "terminator" has to "terminate" at run-time _and_ at compile-time.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
  2023-09-02 20:05 ` [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe() Biju Das
@ 2023-09-04 10:12   ` Andy Shevchenko
  2023-09-10  7:03     ` Biju Das
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2023-09-04 10:12 UTC (permalink / raw)
  To: Biju Das; +Cc: Sebastian Reichel, linux-pm, linux-kernel, Biju Das

On Sat, Sep 02, 2023 at 09:05:17PM +0100, Biju Das wrote:
> Add struct bq2515x_info and replace device_id->info in struct
> bq2515x_device.
> 
> Simpilfy bq2515x_read_properties() and probe() by adding struct
> bq2425x_chip_info as match data for OF/ID tables and use
> i2c_get_match_data for retrieving match data instead of ID lookup.
> 
> Drop enum bq2515x_id as there is no user.

...

> +/**
> + * struct bq2515x_info -

Missing description.

> + * @regmap_config: register map config
> + * @ilim: input current limit
> + */
> +struct bq2515x_info {
> +	const struct regmap_config *regmap_config;
> +	int ilim;
>  };

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
  2023-09-04 10:12   ` Andy Shevchenko
@ 2023-09-10  7:03     ` Biju Das
  0 siblings, 0 replies; 8+ messages in thread
From: Biju Das @ 2023-09-10  7:03 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Sebastian Reichel, linux-pm, linux-kernel, Biju Das

Hi Andy Shevchenko,

> Subject: Re: [PATCH 1/2] power: supply: bq2515x: Simpilfy
> bq2515x_read_properties() and probe()
> 
> On Sat, Sep 02, 2023 at 09:05:17PM +0100, Biju Das wrote:
> > Add struct bq2515x_info and replace device_id->info in struct
> > bq2515x_device.
> >
> > Simpilfy bq2515x_read_properties() and probe() by adding struct
> > bq2425x_chip_info as match data for OF/ID tables and use
> > i2c_get_match_data for retrieving match data instead of ID lookup.
> >
> > Drop enum bq2515x_id as there is no user.
> 
> ...
> 
> > +/**
> > + * struct bq2515x_info -
> 
> Missing description.
I checked this and unfortunately other structures
in this driver are not adding description. So, for consistency, I am not doing it here.

Cheers,
Biju

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] Match data improvements for bq2515x driver
  2023-09-02 20:05 [PATCH 0/2] Match data improvements for bq2515x driver Biju Das
  2023-09-02 20:05 ` [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe() Biju Das
  2023-09-02 20:05 ` [PATCH 2/2] power: supply: bq2515x: Some cleanups Biju Das
@ 2023-09-12 21:45 ` Sebastian Reichel
  2 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2023-09-12 21:45 UTC (permalink / raw)
  To: Sebastian Reichel, Biju Das
  Cc: linux-pm, linux-kernel, Biju Das, Andy Shevchenko


On Sat, 02 Sep 2023 21:05:16 +0100, Biju Das wrote:
> This patch series aims to add match data improvements for bq2515x driver.
> 
> This patch series is only compile tested.
> 
> Biju Das (2):
>   power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
>   power: supply: bq2515x: Some cleanups
> 
> [...]

Applied, thanks!

[1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe()
      commit: ef2730fb8122ff90747ee79261c2a9fd35032e17
[2/2] power: supply: bq2515x: Some cleanups
      commit: ab907d99d5d4e40ba638b6a27940d59fcb2ad24d

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-12 21:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-02 20:05 [PATCH 0/2] Match data improvements for bq2515x driver Biju Das
2023-09-02 20:05 ` [PATCH 1/2] power: supply: bq2515x: Simpilfy bq2515x_read_properties() and probe() Biju Das
2023-09-04 10:12   ` Andy Shevchenko
2023-09-10  7:03     ` Biju Das
2023-09-02 20:05 ` [PATCH 2/2] power: supply: bq2515x: Some cleanups Biju Das
2023-09-04 10:10   ` Andy Shevchenko
2023-09-04 10:11     ` Andy Shevchenko
2023-09-12 21:45 ` [PATCH 0/2] Match data improvements for bq2515x driver Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).