Skip to contentSkip to conversation

media: ir-spi: A few cleanups

PATCH In review Andy Shevchenko 3 participants 17 messages Mar 5, 2024 – Mar 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover media: ir-spi: A few cleanups

While removing of_gpio.h where it's being unused, this driver seems to deserve more love. Hence this series.

Andy Shevchenko (5):
media: ir-spi: Don't use "proxy" headers
media: ir-spi: Make use of device properties
media: ir-spi: Utilise temporary variable for struct device
media: ir-spi: Remove trailing comma in the terminator entry
media: ir-spi: Unify indentation and comment style

 drivers/media/rc/ir-spi.c | 41 +++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 19 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#1 lore raw

PATCH 1/5 media: ir-spi: Don't use "proxy" headers

Update header inclusions to follow IWYU (Include What You Use) principle.

---
 drivers/media/rc/ir-spi.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/media/rc/ir-spi.c +9 -4
index bbc81bed4f90..28437a35b7ba 100644
@@ -4,13 +4,18 @@
 // Copyright (c) 2016 Samsung Electronics Co., Ltd.
 // Copyright (c) Andi Shyti <[email protected]>
 
-#include <linux/delay.h>
-#include <linux/fs.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/math.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/of_gpio.h>
+#include <linux/of.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <linux/string.h>
+#include <linux/types.h>
+
 #include <media/rc-core.h>
 
 #define IR_SPI_DRIVER_NAME		"ir-spi"
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#3 lore raw

PATCH 2/5 media: ir-spi: Make use of device properties

In reply to Andy Shevchenko

Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.

---
 drivers/media/rc/ir-spi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/rc/ir-spi.c +4 -4
index 28437a35b7ba..846d407a1f7e 100644
@@ -10,7 +10,7 @@
 #include <linux/math.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
 #include <linux/string.h>
@@ -116,6 +116,7 @@ static int ir_spi_set_duty_cycle(struct rc_dev *dev, u32 duty_cycle)
 
 static int ir_spi_probe(struct spi_device *spi)
 {
+	struct device *dev = &spi->dev;
 	int ret;
 	u8 dc;
 	struct ir_spi_data *idata;
@@ -140,9 +141,8 @@ static int ir_spi_probe(struct spi_device *spi)
 	idata->rc->priv            = idata;
 	idata->spi                 = spi;
 
-	idata->negated = of_property_read_bool(spi->dev.of_node,
-							"led-active-low");
-	ret = of_property_read_u8(spi->dev.of_node, "duty-cycle", &dc);
+	idata->negated = device_property_read_bool(dev, "led-active-low");
+	ret = device_property_read_u8(dev, "duty-cycle", &dc);
 	if (ret)
 		dc = 50;
 
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#5 lore raw

PATCH 3/5 media: ir-spi: Utilise temporary variable for struct device

In reply to Andy Shevchenko

We have a temporary variable to keep pointer to struct device. Utilise it inside the ->probe() implementation.

---
 drivers/media/rc/ir-spi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/rc/ir-spi.c +3 -3
index 846d407a1f7e..19102bdcfd6f 100644
@@ -121,11 +121,11 @@ static int ir_spi_probe(struct spi_device *spi)
 	u8 dc;
 	struct ir_spi_data *idata;
 
-	idata = devm_kzalloc(&spi->dev, sizeof(*idata), GFP_KERNEL);
+	idata = devm_kzalloc(dev, sizeof(*idata), GFP_KERNEL);
 	if (!idata)
 		return -ENOMEM;
 
-	idata->regulator = devm_regulator_get(&spi->dev, "irda_regulator");
+	idata->regulator = devm_regulator_get(dev, "irda_regulator");
 	if (IS_ERR(idata->regulator))
 		return PTR_ERR(idata->regulator);
 
@@ -154,7 +154,7 @@ static int ir_spi_probe(struct spi_device *spi)
 
 	idata->freq = IR_SPI_DEFAULT_FREQUENCY;
 
-	return devm_rc_register_device(&spi->dev, idata->rc);
+	return devm_rc_register_device(dev, idata->rc);
 }
 
 static const struct of_device_id ir_spi_of_match[] = {
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#7 lore raw

PATCH 4/5 media: ir-spi: Remove trailing comma in the terminator entry

In reply to Andy Shevchenko

Remove trailing comma in the terminator entry in ID table(s).

---
 drivers/media/rc/ir-spi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/rc/ir-spi.c +2 -2
index 19102bdcfd6f..801de3d108cc 100644
@@ -159,13 +159,13 @@ static int ir_spi_probe(struct spi_device *spi)
 
 static const struct of_device_id ir_spi_of_match[] = {
 	{ .compatible = "ir-spi-led" },
-	{},
+	{}
 };
 MODULE_DEVICE_TABLE(of, ir_spi_of_match);
 
 static const struct spi_device_id ir_spi_ids[] = {
 	{ "ir-spi-led" },
-	{},
+	{}
 };
 MODULE_DEVICE_TABLE(spi, ir_spi_ids);
 
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#9 lore raw

PATCH 5/5 media: ir-spi: Unify indentation and comment style

In reply to Andy Shevchenko

Unify the indentation and multi-line comment style.

---
 drivers/media/rc/ir-spi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/media/rc/ir-spi.c +5 -7
index 801de3d108cc..8fc8e496e6aa 100644
@@ -36,8 +36,7 @@ struct ir_spi_data {
 	struct regulator *regulator;
 };
 
-static int ir_spi_tx(struct rc_dev *dev,
-		     unsigned int *buffer, unsigned int count)
+static int ir_spi_tx(struct rc_dev *dev, unsigned int *buffer, unsigned int count)
 {
 	int i;
 	int ret;
@@ -57,7 +56,7 @@ static int ir_spi_tx(struct rc_dev *dev,
 			return -EINVAL;
 
 		/*
-		 * the first value in buffer is a pulse, so that 0, 2, 4, ...
+		 * The first value in buffer is a pulse, so that 0, 2, 4, ...
 		 * contain a pulse duration. On the contrary, 1, 3, 5, ...
 		 * contain a space duration.
 		 */
@@ -146,9 +145,9 @@ static int ir_spi_probe(struct spi_device *spi)
 	if (ret)
 		dc = 50;
 
-	/* ir_spi_set_duty_cycle cannot fail,
-	 * it returns int to be compatible with the
-	 * rc->s_tx_duty_cycle function
+	/*
+	 * ir_spi_set_duty_cycle() cannot fail, it returns int
+	 * to be compatible with the rc->s_tx_duty_cycle function.
 	 */
 	ir_spi_set_duty_cycle(idata->rc, dc);
 
@@ -177,7 +176,6 @@ static struct spi_driver ir_spi_driver = {
 		.of_match_table = ir_spi_of_match,
 	},
 };
-
 module_spi_driver(ir_spi_driver);
 
 MODULE_AUTHOR("Andi Shyti <[email protected]>");
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Reviewed-by on v1 5/5
#10 lore raw

Re: [SPAM] [PATCH v1 5/5] media: ir-spi: Unify indentation and comment style

Hi Andy,

Quoted 12 lines · Andy Shevchenko

Unify the indentation and multi-line comment style.

---
 drivers/media/rc/ir-spi.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/media/rc/ir-spi.c +0 -0
index 801de3d108cc..8fc8e496e6aa 100644

drivers/media/rc/ir-spi.c struct ir_spi_data { · line 39

Quoted 6 lines
drivers/media/rc/ir-spi.c +1 -2
@@ -36,8 +36,7 @@ struct ir_spi_data {
 	struct regulator *regulator;
 };
 
-static int ir_spi_tx(struct rc_dev *dev,
-		     unsigned int *buffer, unsigned int count)
+static int ir_spi_tx(struct rc_dev *dev, unsigned int *buffer, unsigned int count)

this goes over 80 characters, though. Not an error, but not worth a change either.

I'm not going block the patch as the rest is OK.

Andi

Quoted 36 lines
drivers/media/rc/ir-spi.c +4 -5
 {
 	int i;
 	int ret;
@@ -57,7 +56,7 @@ static int ir_spi_tx(struct rc_dev *dev,
 			return -EINVAL;
 
 		/*
-		 * the first value in buffer is a pulse, so that 0, 2, 4, ...
+		 * The first value in buffer is a pulse, so that 0, 2, 4, ...
 		 * contain a pulse duration. On the contrary, 1, 3, 5, ...
 		 * contain a space duration.
 		 */
@@ -146,9 +145,9 @@ static int ir_spi_probe(struct spi_device *spi)
 	if (ret)
 		dc = 50;
 
-	/* ir_spi_set_duty_cycle cannot fail,
-	 * it returns int to be compatible with the
-	 * rc->s_tx_duty_cycle function
+	/*
+	 * ir_spi_set_duty_cycle() cannot fail, it returns int
+	 * to be compatible with the rc->s_tx_duty_cycle function.
 	 */
 	ir_spi_set_duty_cycle(idata->rc, dc);
 
@@ -177,7 +176,6 @@ static struct spi_driver ir_spi_driver = {
 		.of_match_table = ir_spi_of_match,
 	},
 };
-
 module_spi_driver(ir_spi_driver);
 
 MODULE_AUTHOR("Andi Shyti <[email protected]>");
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#11 lore raw

Re: [SPAM] [PATCH v1 5/5] media: ir-spi: Unify indentation and comment style

Quoted 1 line · Andi Shyti

On Tue, Mar 05, 2024 at 07:48:30PM +0200, Andy Shevchenko wrote:

...

Quoted 4 lines
Quoted 1 line

+static int ir_spi_tx(struct rc_dev *dev, unsigned int *buffer, unsigned int count)

this goes over 80 characters, though. Not an error, but not worth a change either.

It's only 82 characters and I consider this as an improvement in readability. It's quite pity that some of the subsystems are too conservative, hope this one is not an obstacle for them.

Quoted 3 lines

I'm not going block the patch as the rest is OK.

Thank you!

Btw, don't you want to either add your entry into .mailcap and/or update your email address in this source file (and maybe others)? I Cc'ed you only after I looked closer to the sources...

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH v1 5/5] media: ir-spi: Unify indentation and comment style

Quoted 16 lines · Andy Shevchenko
Quoted 1 line · Andi Shyti

On Tue, Mar 05, 2024 at 07:48:30PM +0200, Andy Shevchenko wrote:

...

Quoted 4 lines
Quoted 1 line

+static int ir_spi_tx(struct rc_dev *dev, unsigned int *buffer, unsigned int count)

this goes over 80 characters, though. Not an error, but not worth a change either.

It's only 82 characters and I consider this as an improvement in readability. It's quite pity that some of the subsystems are too conservative, hope this one is not an obstacle for them.

Quoted 2 lines

I'm not going block the patch as the rest is OK.

Quoted 7 lines
Quoted 1 line

Thank you!

Btw, don't you want to either add your entry into .mailcap and/or update your email address in this source file (and maybe others)? I Cc'ed you only after I looked closer to the sources...

yes, will do... I also noticed that lots of updates are missing...

I've been far from all this for too long, so that I have still a lot of catch up to do :-)

Thanks, Andy!
Andi

#13 lore raw
In reply to Andy Shevchenko

Hi Andy,

Quoted 2 lines · Andy Shevchenko

While removing of_gpio.h where it's being unused, this driver seems to deserve more love. Hence this series.

ehehe... thanks for the cleanup!

Andi

#14 lore raw
In reply to Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

While removing of_gpio.h where it's being unused, this driver seems to deserve more love. Hence this series.

Sean, any comments on this series?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#15 lore raw
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

While removing of_gpio.h where it's being unused, this driver seems to deserve more love. Hence this series.

Sean, any comments on this series?

Looks great, I've applied it to my branch.

Sean

#16 lore raw
In reply to Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko

While removing of_gpio.h where it's being unused, this driver seems to deserve more love. Hence this series.

Sean, any comments on this series?

Since previous reply, I found an answer in your repository :-) Thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko