linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emil Lenngren <emil.lenngren@gmail.com>
To: linux-pwm@vger.kernel.org
Subject: Atomic update of period and duty_cycle in sysfs
Date: Mon, 7 Jun 2021 15:47:36 +0200	[thread overview]
Message-ID: <CAO1O6seyi+1amAY5YLz0K1dkNd7ewAvot4K1eZMpAAQquz0-9g@mail.gmail.com> (raw)

Hi everyone,

I don't know if this has been proposed before, but I propose a
period_and_duty_cycle attribute in sysfs, beyond period and
duty_cycle, that could be used if both period and duty cycle should be
updated at the same time.

When we programmatically want to update these values, it can currently
be a bit tricky to get this correct, since if we write the two
attributes in the "wrong" order we could end up in a situation where a
write gets EINVAL as result, depending on the current values, since it
must always be the case that duty_cycle <= period. We also have the
issue that writing one file at the time doesn't result in an atomic
update, so potentially the user can observe a strange behaviour from
the pwm between the two writes, because for example the old period is
used but the new duty_cycle is used for a short amount of time.

A period_and_duty_cycle attribute would fix this, where the two values
are space-separated.

/Emil

                 reply	other threads:[~2021-06-07 13:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAO1O6seyi+1amAY5YLz0K1dkNd7ewAvot4K1eZMpAAQquz0-9g@mail.gmail.com \
    --to=emil.lenngren@gmail.com \
    --cc=linux-pwm@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).