All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luka Kovacic <luka.kovacic@sartura.hr>
To: Pavel Machek <pavel@ucw.cz>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-hwmon@vger.kernel.org,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Lee Jones <lee.jones@linaro.org>, Dan Murphy <dmurphy@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>, Andrew Lunn <andrew@lunn.ch>,
	Jason Cooper <jason@lakedaemon.net>,
	Gregory Clement <gregory.clement@bootlin.com>,
	Marek Behun <marek.behun@nic.cz>,
	Luka Perkov <luka.perkov@sartura.hr>,
	Robert Marko <robert.marko@sartura.hr>
Subject: Re: [PATCH v3 4/7] drivers: leds: Add the iEi WT61P803 PUZZLE LED driver
Date: Wed, 7 Oct 2020 03:10:37 +0200	[thread overview]
Message-ID: <CADZsf3bYHMAkbwSN657+EnpDTxgRr8qHiHDrM68UD7rJXQHDCQ@mail.gmail.com> (raw)
In-Reply-To: <CADZsf3ZL712nZh5nQxh5RQ=YCbM0fEK8dp-uHyOW+2FSMv+UpA@mail.gmail.com>

On Tue, Oct 6, 2020 at 8:41 AM Luka Kovacic <luka.kovacic@sartura.hr> wrote:
>
> On Wed, Sep 30, 2020 at 9:48 PM Pavel Machek <pavel@ucw.cz> wrote:
> >
> > Hi!
> >
> > > +static int iei_wt61p803_puzzle_led_brightness_set_blocking(struct led_classdev *cdev,
> > > +             enum led_brightness brightness)
> > > +{
> > > +     struct iei_wt61p803_puzzle_led *priv = cdev_to_iei_wt61p803_puzzle_led(cdev);
> > > +     unsigned char *resp_buf = priv->response_buffer;
> > > +     unsigned char led_power_cmd[5] = {
> > > +             IEI_WT61P803_PUZZLE_CMD_HEADER_START,
> > > +             IEI_WT61P803_PUZZLE_CMD_LED,
> > > +             IEI_WT61P803_PUZZLE_CMD_LED_POWER,
> > > +             (char)IEI_LED_OFF
> > > +     };
> > > +     size_t reply_size;
> > > +
> > > +     mutex_lock(&priv->lock);
> > > +     if (brightness == LED_OFF) {
> > > +             led_power_cmd[3] = (char)IEI_LED_OFF;
> > > +             priv->led_power_state = LED_OFF;
> > > +     } else {
> > > +             led_power_cmd[3] = (char)IEI_LED_ON;
> > > +             priv->led_power_state = LED_ON;
> > > +     }
> > > +     mutex_unlock(&priv->lock);
> > > +
> > > +     return iei_wt61p803_puzzle_write_command(priv->mcu, led_power_cmd,
> > > +                     sizeof(led_power_cmd), resp_buf, &reply_size);
> > > +}
> >
> > Is the mutex needed? If so, should it include the
> > iei_wt61p803_puzzle_write_command()? Does
> > iei_wt61p803_puzzle_write_command() have internal locking to prevent
> > two messages from being mingled?
> >
> > Best regards,
> >                                                                         Pavel
> >
> > --
> > (english) http://www.livejournal.com/~pavelmachek
> > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>
> Hello Pavel,
>
> The mutex isn't needed and can be removed.
> The function iei_wt61p803_puzzle_write_command() already handles its own
> mutex locking, so a separate mutex isn't required.
>
> Does brightness_set_blocking only block a single caller (each caller separately)
> or does it block all callers until the previous caller is finished?
>
> Kind regards,
> Luka

Hello Pavel,

I've sent out a new patchset, but I kept the mutex in use.
It's used to make sure only one read or write request is done at once,
when writing
to the LED driver private structure.

I have also added this description to the struct comment.

Kind regards,
Luka

WARNING: multiple messages have this Message-ID (diff)
From: Luka Kovacic <luka.kovacic@sartura.hr>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-hwmon@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Jean Delvare <jdelvare@suse.com>,
	Luka Perkov <luka.perkov@sartura.hr>,
	Jason Cooper <jason@lakedaemon.net>,
	Gregory Clement <gregory.clement@bootlin.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Marek Behun <marek.behun@nic.cz>,
	Rob Herring <robh+dt@kernel.org>,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	Robert Marko <robert.marko@sartura.hr>,
	Lee Jones <lee.jones@linaro.org>,
	Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Dan Murphy <dmurphy@ti.com>
Subject: Re: [PATCH v3 4/7] drivers: leds: Add the iEi WT61P803 PUZZLE LED driver
Date: Wed, 7 Oct 2020 03:10:37 +0200	[thread overview]
Message-ID: <CADZsf3bYHMAkbwSN657+EnpDTxgRr8qHiHDrM68UD7rJXQHDCQ@mail.gmail.com> (raw)
In-Reply-To: <CADZsf3ZL712nZh5nQxh5RQ=YCbM0fEK8dp-uHyOW+2FSMv+UpA@mail.gmail.com>

On Tue, Oct 6, 2020 at 8:41 AM Luka Kovacic <luka.kovacic@sartura.hr> wrote:
>
> On Wed, Sep 30, 2020 at 9:48 PM Pavel Machek <pavel@ucw.cz> wrote:
> >
> > Hi!
> >
> > > +static int iei_wt61p803_puzzle_led_brightness_set_blocking(struct led_classdev *cdev,
> > > +             enum led_brightness brightness)
> > > +{
> > > +     struct iei_wt61p803_puzzle_led *priv = cdev_to_iei_wt61p803_puzzle_led(cdev);
> > > +     unsigned char *resp_buf = priv->response_buffer;
> > > +     unsigned char led_power_cmd[5] = {
> > > +             IEI_WT61P803_PUZZLE_CMD_HEADER_START,
> > > +             IEI_WT61P803_PUZZLE_CMD_LED,
> > > +             IEI_WT61P803_PUZZLE_CMD_LED_POWER,
> > > +             (char)IEI_LED_OFF
> > > +     };
> > > +     size_t reply_size;
> > > +
> > > +     mutex_lock(&priv->lock);
> > > +     if (brightness == LED_OFF) {
> > > +             led_power_cmd[3] = (char)IEI_LED_OFF;
> > > +             priv->led_power_state = LED_OFF;
> > > +     } else {
> > > +             led_power_cmd[3] = (char)IEI_LED_ON;
> > > +             priv->led_power_state = LED_ON;
> > > +     }
> > > +     mutex_unlock(&priv->lock);
> > > +
> > > +     return iei_wt61p803_puzzle_write_command(priv->mcu, led_power_cmd,
> > > +                     sizeof(led_power_cmd), resp_buf, &reply_size);
> > > +}
> >
> > Is the mutex needed? If so, should it include the
> > iei_wt61p803_puzzle_write_command()? Does
> > iei_wt61p803_puzzle_write_command() have internal locking to prevent
> > two messages from being mingled?
> >
> > Best regards,
> >                                                                         Pavel
> >
> > --
> > (english) http://www.livejournal.com/~pavelmachek
> > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>
> Hello Pavel,
>
> The mutex isn't needed and can be removed.
> The function iei_wt61p803_puzzle_write_command() already handles its own
> mutex locking, so a separate mutex isn't required.
>
> Does brightness_set_blocking only block a single caller (each caller separately)
> or does it block all callers until the previous caller is finished?
>
> Kind regards,
> Luka

Hello Pavel,

I've sent out a new patchset, but I kept the mutex in use.
It's used to make sure only one read or write request is done at once,
when writing
to the LED driver private structure.

I have also added this description to the struct comment.

Kind regards,
Luka

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-10-07  1:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30  1:40 [PATCH v3 0/7] Add support for the iEi Puzzle-M801 board Luka Kovacic
2020-09-30  1:40 ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 1/7] dt-bindings: Add iEi vendor prefix and iEi WT61P803 PUZZLE driver bindings Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 2/7] drivers: mfd: Add a driver for iEi WT61P803 PUZZLE MCU Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30  8:40   ` kernel test robot
2020-09-30  8:40     ` kernel test robot
2020-09-30  8:40     ` kernel test robot
2020-09-30  1:40 ` [PATCH v3 3/7] drivers: hwmon: Add the iEi WT61P803 PUZZLE HWMON driver Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 4/7] drivers: leds: Add the iEi WT61P803 PUZZLE LED driver Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30 19:48   ` Pavel Machek
2020-09-30 19:48     ` Pavel Machek
2020-10-06  6:41     ` Luka Kovacic
2020-10-06  6:41       ` Luka Kovacic
2020-10-07  1:10       ` Luka Kovacic [this message]
2020-10-07  1:10         ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 5/7] Documentation/ABI: Add iei-wt61p803-puzzle driver sysfs interface documentation Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 6/7] MAINTAINERS: Add an entry for the iEi WT61P803 PUZZLE driver Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic
2020-09-30  1:40 ` [PATCH v3 7/7] arm64: dts: marvell: Add a device tree for the iEi Puzzle-M801 board Luka Kovacic
2020-09-30  1:40   ` Luka Kovacic

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=CADZsf3bYHMAkbwSN657+EnpDTxgRr8qHiHDrM68UD7rJXQHDCQ@mail.gmail.com \
    --to=luka.kovacic@sartura.hr \
    --cc=andrew@lunn.ch \
    --cc=dmurphy@ti.com \
    --cc=gregory.clement@bootlin.com \
    --cc=jason@lakedaemon.net \
    --cc=jdelvare@suse.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=luka.perkov@sartura.hr \
    --cc=marek.behun@nic.cz \
    --cc=pavel@ucw.cz \
    --cc=robert.marko@sartura.hr \
    --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.