2024-03-05 17:50:00

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/5] 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(-)

--
2.43.0.rc1.1.gbec44491f096



2024-03-05 17:50:28

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 4/5] media: ir-spi: Remove trailing comma in the terminator entry

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/media/rc/ir-spi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 19102bdcfd6f..801de3d108cc 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -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);

--
2.43.0.rc1.1.gbec44491f096


2024-03-05 17:50:43

by Andy Shevchenko

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

Unify the indentation and multi-line comment style.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/media/rc/ir-spi.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 801de3d108cc..8fc8e496e6aa 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -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]>");
--
2.43.0.rc1.1.gbec44491f096


2024-03-05 19:06:24

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/5] media: ir-spi: Don't use "proxy" headers

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/media/rc/ir-spi.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index bbc81bed4f90..28437a35b7ba 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -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"
--
2.43.0.rc1.1.gbec44491f096


2024-03-05 20:18:28

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 3/5] media: ir-spi: Utilise temporary variable for struct device

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/media/rc/ir-spi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 846d407a1f7e..19102bdcfd6f 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -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[] = {
--
2.43.0.rc1.1.gbec44491f096


2024-03-05 22:44:30

by Andi Shyti

[permalink] [raw]
Subject: Re: [SPAM] [PATCH v1 1/5] media: ir-spi: Don't use "proxy" headers

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:26PM +0200, Andy Shevchenko wrote:
> Update header inclusions to follow IWYU (Include What You Use)
> principle.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Andi Shyti <[email protected]>

Thanks,
Andi

2024-03-05 22:48:54

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v1 4/5] media: ir-spi: Remove trailing comma in the terminator entry

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:29PM +0200, Andy Shevchenko wrote:
> Remove trailing comma in the terminator entry in ID table(s).
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Andi Shyti <[email protected]>

Thanks,
Andi

2024-03-05 22:49:20

by Andi Shyti

[permalink] [raw]
Subject: Re: [SPAM] [PATCH v1 3/5] media: ir-spi: Utilise temporary variable for struct device

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:28PM +0200, Andy Shevchenko wrote:
> We have a temporary variable to keep pointer to struct device.
> Utilise it inside the ->probe() implementation.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Andi Shyti <[email protected]>

Thanks,
Andi

2024-03-05 22:52:28

by Andi Shyti

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

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:30PM +0200, Andy Shevchenko wrote:
> Unify the indentation and multi-line comment style.
>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> drivers/media/rc/ir-spi.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
> index 801de3d108cc..8fc8e496e6aa 100644
> --- a/drivers/media/rc/ir-spi.c
> +++ b/drivers/media/rc/ir-spi.c
> @@ -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.

Reviewed-by: Andi Shyti <[email protected]>

Andi

> {
> 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]>");
> --
> 2.43.0.rc1.1.gbec44491f096
>

2024-03-05 23:02:13

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 2/5] media: ir-spi: Make use of device properties

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/media/rc/ir-spi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/rc/ir-spi.c b/drivers/media/rc/ir-spi.c
index 28437a35b7ba..846d407a1f7e 100644
--- a/drivers/media/rc/ir-spi.c
+++ b/drivers/media/rc/ir-spi.c
@@ -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;

--
2.43.0.rc1.1.gbec44491f096


2024-03-05 23:18:48

by Andi Shyti

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] media: ir-spi: A few cleanups

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:25PM +0200, Andy Shevchenko wrote:
> 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

2024-03-05 23:20:28

by Andi Shyti

[permalink] [raw]
Subject: Re: [SPAM] [PATCH v1 2/5] media: ir-spi: Make use of device properties

Hi Andy,

On Tue, Mar 05, 2024 at 07:48:27PM +0200, Andy Shevchenko wrote:
> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Andi Shyti <[email protected]>

Thanks,
Andi

2024-03-06 13:36:13

by Andy Shevchenko

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

On Tue, Mar 05, 2024 at 11:52:15PM +0100, Andi Shyti wrote:
> On Tue, Mar 05, 2024 at 07:48:30PM +0200, Andy Shevchenko wrote:

..

> > +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.

> I'm not going block the patch as the rest is OK.
>
> Reviewed-by: Andi Shyti <[email protected]>

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...

--
With Best Regards,
Andy Shevchenko



2024-03-08 12:37:14

by Andi Shyti

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

On Wed, Mar 06, 2024 at 03:35:56PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 05, 2024 at 11:52:15PM +0100, Andi Shyti wrote:
> > On Tue, Mar 05, 2024 at 07:48:30PM +0200, Andy Shevchenko wrote:
>
> ...
>
> > > +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.
>
> > I'm not going block the patch as the rest is OK.
> >
> > Reviewed-by: Andi Shyti <[email protected]>
>
> 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

2024-03-11 14:51:14

by Sean Young

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] media: ir-spi: A few cleanups

On Mon, Mar 11, 2024 at 04:25:19PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 05, 2024 at 07:48:25PM +0200, Andy Shevchenko wrote:
> > 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

2024-03-11 17:02:34

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] media: ir-spi: A few cleanups

On Tue, Mar 05, 2024 at 07:48:25PM +0200, Andy Shevchenko wrote:
> 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?

--
With Best Regards,
Andy Shevchenko



2024-03-11 17:41:28

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] media: ir-spi: A few cleanups

On Mon, Mar 11, 2024 at 04:25:19PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 05, 2024 at 07:48:25PM +0200, Andy Shevchenko wrote:
> > 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!

--
With Best Regards,
Andy Shevchenko