All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Kiran Gunda <kgunda@codeaurora.org>
Cc: jingoohan1@gmail.com, lee.jones@linaro.org,
	b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org,
	daniel.thompson@linaro.org, jacek.anaszewski@gmail.com,
	pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH V5 8/8] backlight: qcom-wled: Add auto string detection logic
Date: Mon, 27 Aug 2018 07:54:20 -0700	[thread overview]
Message-ID: <20180827145420.GL3048@tuxbook-pro> (raw)
In-Reply-To: <1535106467-17843-9-git-send-email-kgunda@codeaurora.org>

On Fri 24 Aug 03:27 PDT 2018, Kiran Gunda wrote:
> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
[..]
>  struct wled {
> @@ -135,16 +146,22 @@ struct wled {
>  	struct regmap *regmap;
>  	struct mutex lock;	/* Lock to avoid race from thread irq handler */
>  	ktime_t last_short_event;
> +	ktime_t start_ovp_fault_time;
>  	u16 ctrl_addr;
>  	u16 sink_addr;
>  	u16 max_string_count;
> +	u16 auto_detection_ovp_count;
>  	u32 brightness;
>  	u32 max_brightness;
>  	u32 short_count;
> +	u32 auto_detect_count;
>  	bool disabled_by_short;
>  	bool has_short_detect;
> +	int ovp_irq;
> +	bool ovp_irq_disabled;

ovp_irq_disabled is now only assigned, never read. So you should be able
to drop it.

[..]
> @@ -200,7 +226,18 @@ static int wled_module_enable(struct wled *wled, int val)
>  				WLED_CTRL_REG_MOD_EN,
>  				WLED_CTRL_REG_MOD_EN_MASK,
>  				val << WLED_CTRL_REG_MOD_EN_SHIFT);
> -	return rc;
> +	if (rc < 0)
> +		return rc;
> +
> +	if (val) {
> +		schedule_delayed_work(&wled->ovp_work, HZ / 100);

wled_ovp_work() is a nop when ovp_irq == 0, so wrap the entire if/else
in a check for ovp_irq > 0 (rather than include it in the else) and drop
it from the worker.

> +	} else {
> +		if (!cancel_delayed_work_sync(&wled->ovp_work) &&
> +		    wled->ovp_irq > 0)
> +			disable_irq(wled->ovp_irq);
> +	}
> +
> +	return 0;

Also, if a user calls rmmod within 10ms of enabling module we will
schedule work of code that's no longer available in the kernel. So you
need to also cancel_delayed_work_sync() in the remove function of the
driver.


Apart from this I think this patch looks good now!

Regards,
Bjorn

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Kiran Gunda <kgunda@codeaurora.org>
Cc: jingoohan1@gmail.com, lee.jones@linaro.org,
	b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org,
	daniel.thompson@linaro.org, jacek.anaszewski@gmail.com,
	pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH V5 8/8] backlight: qcom-wled: Add auto string detection logic
Date: Mon, 27 Aug 2018 14:54:20 +0000	[thread overview]
Message-ID: <20180827145420.GL3048@tuxbook-pro> (raw)
In-Reply-To: <1535106467-17843-9-git-send-email-kgunda@codeaurora.org>

On Fri 24 Aug 03:27 PDT 2018, Kiran Gunda wrote:
> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
[..]
>  struct wled {
> @@ -135,16 +146,22 @@ struct wled {
>  	struct regmap *regmap;
>  	struct mutex lock;	/* Lock to avoid race from thread irq handler */
>  	ktime_t last_short_event;
> +	ktime_t start_ovp_fault_time;
>  	u16 ctrl_addr;
>  	u16 sink_addr;
>  	u16 max_string_count;
> +	u16 auto_detection_ovp_count;
>  	u32 brightness;
>  	u32 max_brightness;
>  	u32 short_count;
> +	u32 auto_detect_count;
>  	bool disabled_by_short;
>  	bool has_short_detect;
> +	int ovp_irq;
> +	bool ovp_irq_disabled;

ovp_irq_disabled is now only assigned, never read. So you should be able
to drop it.

[..]
> @@ -200,7 +226,18 @@ static int wled_module_enable(struct wled *wled, int val)
>  				WLED_CTRL_REG_MOD_EN,
>  				WLED_CTRL_REG_MOD_EN_MASK,
>  				val << WLED_CTRL_REG_MOD_EN_SHIFT);
> -	return rc;
> +	if (rc < 0)
> +		return rc;
> +
> +	if (val) {
> +		schedule_delayed_work(&wled->ovp_work, HZ / 100);

wled_ovp_work() is a nop when ovp_irq = 0, so wrap the entire if/else
in a check for ovp_irq > 0 (rather than include it in the else) and drop
it from the worker.

> +	} else {
> +		if (!cancel_delayed_work_sync(&wled->ovp_work) &&
> +		    wled->ovp_irq > 0)
> +			disable_irq(wled->ovp_irq);
> +	}
> +
> +	return 0;

Also, if a user calls rmmod within 10ms of enabling module we will
schedule work of code that's no longer available in the kernel. So you
need to also cancel_delayed_work_sync() in the remove function of the
driver.


Apart from this I think this patch looks good now!

Regards,
Bjorn

  reply	other threads:[~2018-08-27 14:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24 10:27 [PATCH V5 0/8] backlight: qcom-wled: Support for QCOM wled driver Kiran Gunda
2018-08-24 10:27 ` [PATCH V5 1/8] backlight: qcom-wled: Rename pm8941-wled.c to qcom-wled.c Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-27  9:49   ` Pavel Machek
2018-08-27  9:49     ` Pavel Machek
2018-08-24 10:27 ` [PATCH V5 2/8] backlight: qcom-wled: restructure the qcom-wled bindings Kiran Gunda
2018-08-27  9:52   ` Pavel Machek
2018-08-24 10:27 ` [PATCH V5 3/8] backlight: qcom-wled: Add new properties for PMI8998 Kiran Gunda
2018-08-27 10:01   ` Pavel Machek
2018-08-27 10:01     ` Pavel Machek
2018-08-29  5:52     ` kgunda
2018-08-24 10:27 ` [PATCH V5 4/8] backlight: qcom-wled: Rename PM8941* to WLED3 Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-27 10:04   ` Pavel Machek
2018-08-27 10:04     ` Pavel Machek
2018-08-27 10:04     ` Pavel Machek
2018-08-27 15:04     ` Bjorn Andersson
2018-08-27 15:04       ` Bjorn Andersson
2018-08-24 10:27 ` [PATCH V5 5/8] backlight: qcom-wled: Restructure the driver for WLED3 Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-27 10:09   ` Pavel Machek
2018-08-27 10:09     ` Pavel Machek
2018-08-27 10:09     ` Pavel Machek
2018-08-29  7:10     ` kgunda
2018-08-29  7:22       ` kgunda
2018-08-24 10:27 ` [PATCH V5 6/8] backlight: qcom-wled: Add support for WLED4 peripheral Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-24 10:27 ` [PATCH V5 7/8] backlight: qcom-wled: add support for short circuit handling Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-24 10:27 ` [PATCH V5 8/8] backlight: qcom-wled: Add auto string detection logic Kiran Gunda
2018-08-24 10:39   ` Kiran Gunda
2018-08-27 14:54   ` Bjorn Andersson [this message]
2018-08-27 14:54     ` Bjorn Andersson
2018-08-29  7:13     ` kgunda
2018-08-29  7:25       ` kgunda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180827145420.GL3048@tuxbook-pro \
    --to=bjorn.andersson@linaro.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=jingoohan1@gmail.com \
    --cc=kgunda@codeaurora.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.