* [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc()
@ 2021-09-29 11:17 Andy Shevchenko
2021-09-29 11:17 ` [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided Andy Shevchenko
2021-09-30 11:24 ` [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Ulf Hansson
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2021-09-29 11:17 UTC (permalink / raw)
To: Andy Shevchenko, linux-mmc, linux-kernel; +Cc: Ulf Hansson
Refactor mmc_gpio_alloc() to drop unneeded indentation level
and double condition. This increases readability of the code.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mmc/core/slot-gpio.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 05e907451df9..e365d328f43c 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -39,24 +39,24 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
int mmc_gpio_alloc(struct mmc_host *host)
{
- struct mmc_gpio *ctx = devm_kzalloc(host->parent,
- sizeof(*ctx), GFP_KERNEL);
-
- if (ctx) {
- ctx->cd_debounce_delay_ms = 200;
- ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL,
- "%s cd", dev_name(host->parent));
- if (!ctx->cd_label)
- return -ENOMEM;
- ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL,
- "%s ro", dev_name(host->parent));
- if (!ctx->ro_label)
- return -ENOMEM;
- host->slot.handler_priv = ctx;
- host->slot.cd_irq = -EINVAL;
- }
+ const char *devname = dev_name(host->parent);
+ struct mmc_gpio *ctx;
+
+ ctx = devm_kzalloc(host->parent, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->cd_debounce_delay_ms = 200;
+ ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s cd", devname);
+ if (!ctx->cd_label)
+ return -ENOMEM;
+ ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s ro", devname);
+ if (!ctx->ro_label)
+ return -ENOMEM;
+ host->slot.handler_priv = ctx;
+ host->slot.cd_irq = -EINVAL;
- return ctx ? 0 : -ENOMEM;
+ return 0;
}
int mmc_gpio_get_ro(struct mmc_host *host)
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided
2021-09-29 11:17 [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Andy Shevchenko
@ 2021-09-29 11:17 ` Andy Shevchenko
2021-09-30 11:24 ` Ulf Hansson
2021-09-30 11:24 ` [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Ulf Hansson
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-09-29 11:17 UTC (permalink / raw)
To: Andy Shevchenko, linux-mmc, linux-kernel; +Cc: Ulf Hansson
Currently default label of GPIO is assigned to the device name,
when no con_id provided. Instead, let's update it to reflect
what it's about (use already prepared template).
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/mmc/core/slot-gpio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index e365d328f43c..dd2a4b6ab6ad 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -178,6 +178,10 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
if (IS_ERR(desc))
return PTR_ERR(desc);
+ /* Update default label if no con_id provided */
+ if (!con_id)
+ gpiod_set_consumer_name(desc, ctx->cd_label);
+
if (debounce) {
ret = gpiod_set_debounce(desc, debounce);
if (ret < 0)
@@ -226,6 +230,10 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
if (IS_ERR(desc))
return PTR_ERR(desc);
+ /* Update default label if no con_id provided */
+ if (!con_id)
+ gpiod_set_consumer_name(desc, ctx->ro_label);
+
if (debounce) {
ret = gpiod_set_debounce(desc, debounce);
if (ret < 0)
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc()
2021-09-29 11:17 [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Andy Shevchenko
2021-09-29 11:17 ` [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided Andy Shevchenko
@ 2021-09-30 11:24 ` Ulf Hansson
1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-09-30 11:24 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-mmc, Linux Kernel Mailing List
On Wed, 29 Sept 2021 at 13:17, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Refactor mmc_gpio_alloc() to drop unneeded indentation level
> and double condition. This increases readability of the code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/core/slot-gpio.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
> index 05e907451df9..e365d328f43c 100644
> --- a/drivers/mmc/core/slot-gpio.c
> +++ b/drivers/mmc/core/slot-gpio.c
> @@ -39,24 +39,24 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
>
> int mmc_gpio_alloc(struct mmc_host *host)
> {
> - struct mmc_gpio *ctx = devm_kzalloc(host->parent,
> - sizeof(*ctx), GFP_KERNEL);
> -
> - if (ctx) {
> - ctx->cd_debounce_delay_ms = 200;
> - ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL,
> - "%s cd", dev_name(host->parent));
> - if (!ctx->cd_label)
> - return -ENOMEM;
> - ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL,
> - "%s ro", dev_name(host->parent));
> - if (!ctx->ro_label)
> - return -ENOMEM;
> - host->slot.handler_priv = ctx;
> - host->slot.cd_irq = -EINVAL;
> - }
> + const char *devname = dev_name(host->parent);
> + struct mmc_gpio *ctx;
> +
> + ctx = devm_kzalloc(host->parent, sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> + return -ENOMEM;
> +
> + ctx->cd_debounce_delay_ms = 200;
> + ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s cd", devname);
> + if (!ctx->cd_label)
> + return -ENOMEM;
> + ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, "%s ro", devname);
> + if (!ctx->ro_label)
> + return -ENOMEM;
> + host->slot.handler_priv = ctx;
> + host->slot.cd_irq = -EINVAL;
>
> - return ctx ? 0 : -ENOMEM;
> + return 0;
> }
>
> int mmc_gpio_get_ro(struct mmc_host *host)
> --
> 2.33.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided
2021-09-29 11:17 ` [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided Andy Shevchenko
@ 2021-09-30 11:24 ` Ulf Hansson
0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2021-09-30 11:24 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-mmc, Linux Kernel Mailing List
On Wed, 29 Sept 2021 at 13:17, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Currently default label of GPIO is assigned to the device name,
> when no con_id provided. Instead, let's update it to reflect
> what it's about (use already prepared template).
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/core/slot-gpio.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
> index e365d328f43c..dd2a4b6ab6ad 100644
> --- a/drivers/mmc/core/slot-gpio.c
> +++ b/drivers/mmc/core/slot-gpio.c
> @@ -178,6 +178,10 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
> if (IS_ERR(desc))
> return PTR_ERR(desc);
>
> + /* Update default label if no con_id provided */
> + if (!con_id)
> + gpiod_set_consumer_name(desc, ctx->cd_label);
> +
> if (debounce) {
> ret = gpiod_set_debounce(desc, debounce);
> if (ret < 0)
> @@ -226,6 +230,10 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
> if (IS_ERR(desc))
> return PTR_ERR(desc);
>
> + /* Update default label if no con_id provided */
> + if (!con_id)
> + gpiod_set_consumer_name(desc, ctx->ro_label);
> +
> if (debounce) {
> ret = gpiod_set_debounce(desc, debounce);
> if (ret < 0)
> --
> 2.33.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-30 11:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 11:17 [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Andy Shevchenko
2021-09-29 11:17 ` [PATCH v1 2/2] mmc: slot-gpio: Update default label when no con_id provided Andy Shevchenko
2021-09-30 11:24 ` Ulf Hansson
2021-09-30 11:24 ` [PATCH v1 1/2] mmc: slot-gpio: Refactor mmc_gpio_alloc() Ulf Hansson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.