2023-03-24 07:24:33

by Sumitra Sharma

[permalink] [raw]
Subject: [PATCH v2 0/3] Staging: greybus: Use inline functions

Convert macros to a static inline function, to make the relevant
types apparent in the definition and to benefit from the type
checking performed by the compiler at call sites.

CHanges in v2: Change patch subjects, noted by Alison Schofield
<[email protected]>

Sumitra Sharma (3):
Staging: greybus: Use inline function for macro
gpio_chip_to_gb_gpio_controller
Staging: greybus: Use inline function for gb_audio_manager_module
Staging: greybus: Use inline function for pwm_chip_to_gb_pwm_chip

drivers/staging/greybus/audio_manager_module.c | 7 +++++--
drivers/staging/greybus/gpio.c | 7 +++++--
drivers/staging/greybus/pwm.c | 6 ++++--
3 files changed, 14 insertions(+), 6 deletions(-)

--
2.25.1


2023-03-24 07:37:32

by Sumitra Sharma

[permalink] [raw]
Subject: [PATCH v2 1/3] Staging: greybus: Use inline function for macro gpio_chip_to_gb_gpio_controller

Convert 'gpio_chip_to_gb_gpio_controller' from a macro to a static
inline function, to make the relevant types apparent in the
definition and to benefit from the type checking performed by
the compiler at call sites.

Signed-off-by: Sumitra Sharma <[email protected]>
---
v2: Change patch subject, noted by Alison Schofield
<[email protected]>

drivers/staging/greybus/gpio.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
index d729b922a750..2a115a8fc263 100644
--- a/drivers/staging/greybus/gpio.c
+++ b/drivers/staging/greybus/gpio.c
@@ -41,8 +41,11 @@ struct gb_gpio_controller {
struct irq_chip irqc;
struct mutex irq_lock;
};
-#define gpio_chip_to_gb_gpio_controller(chip) \
- container_of(chip, struct gb_gpio_controller, chip)
+
+static inline struct gb_gpio_controller *gpio_chip_to_gb_gpio_controller(struct gpio_chip *chip)
+{
+ return container_of(chip, struct gb_gpio_controller, chip);
+}

static struct gpio_chip *irq_data_to_gpio_chip(struct irq_data *d)
{
--
2.25.1

2023-03-24 07:40:47

by Sumitra Sharma

[permalink] [raw]
Subject: [PATCH v2 2/3] Staging: greybus: Use inline function for gb_audio_manager_module

Convert 'gb_audio_manager_module' from a macro to a static
inline function, to make the relevant types apparent in the
definition and to benefit from the type checking performed by
the compiler at call sites.

Signed-off-by: Sumitra Sharma <[email protected]>
---
v2: Change patch subject, noted by Alison Schofield
<[email protected]>

drivers/staging/greybus/audio_manager_module.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
index 81b4ba607a0e..5f9dcbdbc191 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -12,8 +12,11 @@

#define to_gb_audio_module_attr(x) \
container_of(x, struct gb_audio_manager_module_attribute, attr)
-#define to_gb_audio_module(x) \
- container_of(x, struct gb_audio_manager_module, kobj)
+
+static inline struct gb_audio_manager_module *to_gb_audio_module(struct kobject *kobj)
+{
+ return container_of(kobj, struct gb_audio_manager_module, kobj);
+}

struct gb_audio_manager_module_attribute {
struct attribute attr;
--
2.25.1

2023-03-24 07:41:03

by Sumitra Sharma

[permalink] [raw]
Subject: [PATCH v2 3/3] Staging: greybus: Use inline function for pwm_chip_to_gb_pwm_chip

Convert 'pwm_chip_to_gb_pwm_chip' from a macro to a static
inline function, to make the relevant types apparent in the
definition and to benefit from the type checking performed by
the compiler at call sites.

Signed-off-by: Sumitra Sharma <[email protected]>
---
v2: Change patch subject, noted by Alison Schofield
<[email protected]>

drivers/staging/greybus/pwm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/pwm.c b/drivers/staging/greybus/pwm.c
index 3fda172239d2..88da1d796f13 100644
--- a/drivers/staging/greybus/pwm.c
+++ b/drivers/staging/greybus/pwm.c
@@ -21,9 +21,11 @@ struct gb_pwm_chip {
struct pwm_chip chip;
struct pwm_chip *pwm;
};
-#define pwm_chip_to_gb_pwm_chip(chip) \
- container_of(chip, struct gb_pwm_chip, chip)

+static inline struct gb_pwm_chip *pwm_chip_to_gb_pwm_chip(struct pwm_chip *chip)
+{
+ return container_of(chip, struct gb_pwm_chip, chip);
+}

static int gb_pwm_count_operation(struct gb_pwm_chip *pwmc)
{
--
2.25.1

2023-03-24 15:38:02

by Alison Schofield

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Staging: greybus: Use inline functions

On Fri, Mar 24, 2023 at 12:20:30AM -0700, Sumitra Sharma wrote:
> Convert macros to a static inline function, to make the relevant
> types apparent in the definition and to benefit from the type
> checking performed by the compiler at call sites.
>
> CHanges in v2: Change patch subjects, noted by Alison Schofield


Please review: https://kernelnewbies.org/Outreachyfirstpatch
Section on 'Following the driver commit style'.

To follow the commit style of the greybus driver, update these
commit messages to be under 80 chars, and use "staging", not
"Staging"

Like this:
drivers/staging/greybus$ git log --oneline | head -3
1498054921e2 staging: greybus: Inline pwm_chip_to_gb_pwm_chip()
a7d2a41b7453 staging: greybus: Inline gb_audio_manager_module()
f7d3ece211be staging: greybus: Inline macro gpio_chip_to_gb_gpio_controller()

BTW - I wasn't instantly sure about using 'Inline' as a verb in this
case, so I did this (git log --oneline | grep inline) and found it's
a common use.

We're building a habit here for when you submit across subsystems
in the future.

Alison

>
> Sumitra Sharma (3):
> Staging: greybus: Use inline function for macro
> gpio_chip_to_gb_gpio_controller
> Staging: greybus: Use inline function for gb_audio_manager_module
> Staging: greybus: Use inline function for pwm_chip_to_gb_pwm_chip
>
> drivers/staging/greybus/audio_manager_module.c | 7 +++++--
> drivers/staging/greybus/gpio.c | 7 +++++--
> drivers/staging/greybus/pwm.c | 6 ++++--
> 3 files changed, 14 insertions(+), 6 deletions(-)
>
> --
> 2.25.1
>
>

2023-03-24 16:26:00

by Sumitra Sharma

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Staging: greybus: Use inline functions

On Fri, Mar 24, 2023 at 08:28:50AM -0700, Alison Schofield wrote:
> On Fri, Mar 24, 2023 at 12:20:30AM -0700, Sumitra Sharma wrote:
> > Convert macros to a static inline function, to make the relevant
> > types apparent in the definition and to benefit from the type
> > checking performed by the compiler at call sites.
> >
> > CHanges in v2: Change patch subjects, noted by Alison Schofield
>
>
> Please review: https://kernelnewbies.org/Outreachyfirstpatch
> Section on 'Following the driver commit style'.
>
> To follow the commit style of the greybus driver, update these
> commit messages to be under 80 chars, and use "staging", not
> "Staging"
>
> Like this:
> drivers/staging/greybus$ git log --oneline | head -3
> 1498054921e2 staging: greybus: Inline pwm_chip_to_gb_pwm_chip()
> a7d2a41b7453 staging: greybus: Inline gb_audio_manager_module()
> f7d3ece211be staging: greybus: Inline macro gpio_chip_to_gb_gpio_controller()
>
> BTW - I wasn't instantly sure about using 'Inline' as a verb in this
> case, so I did this (git log --oneline | grep inline) and found it's
> a common use.
>
> We're building a habit here for when you submit across subsystems
> in the future.
>

Hi Alison,

Thank you for helping me out with this patch subject.

PS: I am focusing on writing good patch subjects and descriptions.

Regards,
Sumitra

> Alison
>
> >
> > Sumitra Sharma (3):
> > Staging: greybus: Use inline function for macro
> > gpio_chip_to_gb_gpio_controller
> > Staging: greybus: Use inline function for gb_audio_manager_module
> > Staging: greybus: Use inline function for pwm_chip_to_gb_pwm_chip
> >
> > drivers/staging/greybus/audio_manager_module.c | 7 +++++--
> > drivers/staging/greybus/gpio.c | 7 +++++--
> > drivers/staging/greybus/pwm.c | 6 ++++--
> > 3 files changed, 14 insertions(+), 6 deletions(-)
> >
> > --
> > 2.25.1
> >
> >