while working on an extension for the pwm framework, I noticed that some
drivers and even the core only nearly consistently named all variables
and struct members holding a pointer to a struct pwm_chip "chip":
$ git grep -Pho 'struct pwm_chip \**[a-z0-9_]+(*nla:[\(a-z0-9_])' v6.5-rc1 | sort | uniq -c | sort -n
1 struct pwm_chip *pwm
1 struct pwm_chip pwm
1 struct pwm_chip pwm_chip
2 struct pwm_chip *_chip
4 struct pwm_chip *c
8 struct pwm_chip *pc
57 struct pwm_chip chip
358 struct pwm_chip *chip
With this series applied these are all called "chip" with one exception:
The led driver drivers/leds/rgb/leds-qcom-lpg.c uses "pwm". Maybe
"pwmchip" would be a better name, but I'm not sure that using "chip" was
an improvement there as this isn't a pure pwm driver. I'm not touching
that one.
The first offenders I found were the core and the atmel-hlcdc driver.
After I found these I optimistically assumed these were the only ones
with the unusual names and send patches for these out individually
before checking systematically.
The atmel-hlcdc patch is included here unchanged, the core patch now
also adapted the declaration of the changed functions in <linux/pwm.h>.
I marked these two as "superseded" in patchwork already.
All patches in this series are pairwise independent of each other. I
don't know if the staging patch should better go in via the greybus tree
or via pwm. Both is possible without needing coordination.
Best regards
Uwe
Uwe Kleine-König (10):
pwm: Use a consistent name for pwm_chip pointers in the core
pwm: atmel-hlcdc: Use consistent variable naming
pwm: bcm-kona: Consistenly name pwm_chip variables "chip"
pwm: crc: Consistenly name pwm_chip variables "chip"
pwm: cros-ec: Consistenly name pwm_chip variables "chip"
pwm: lp3943: Consistenly name pwm_chip variables "chip"
pwm: rockchip: Consistenly name pwm_chip variables "chip"
pwm: sifive: Consistenly name pwm_chip variables "chip"
pwm: sl28cpld: Consistenly name pwm_chip variables "chip"
staging: greybus: pwm: Consistenly name pwm_chip variables "chip"
drivers/pwm/core.c | 28 +++++++--------
drivers/pwm/pwm-atmel-hlcdc.c | 64 +++++++++++++++++------------------
drivers/pwm/pwm-bcm-kona.c | 4 +--
drivers/pwm/pwm-crc.c | 4 +--
drivers/pwm/pwm-cros-ec.c | 10 +++---
drivers/pwm/pwm-lp3943.c | 4 +--
drivers/pwm/pwm-rockchip.c | 4 +--
drivers/pwm/pwm-sifive.c | 4 +--
drivers/pwm/pwm-sl28cpld.c | 10 +++---
drivers/staging/greybus/pwm.c | 12 +++----
include/linux/pwm.h | 6 ++--
11 files changed, 75 insertions(+), 75 deletions(-)
base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5
--
2.39.2
Hello everyone. This is my first patch to linux kernel. Once I get the
hang of this process, I will be sending patches form GSoC 2023 greybus
driver. Feel free to tell me if I am doing something wrong here
Ayush Singh (1):
Remove extra newline
drivers/greybus/es2.c | 1 -
1 file changed, 1 deletion(-)
--
2.41.0
A few ALSA control API helpers like snd_ctl_rename(), snd_ctl_remove()
and snd_ctl_find_*() suppose the callers taking card->controls_rwsem.
But it's error-prone and fragile. This patch set tries to change
those API functions to take the card->controls>rwsem internally by
themselves, so that the drivers don't need to take care of lockings.
After applying this patch set, only a couple of places still touch
card->controls_rwsem (which are OK-ish as they need for traversing the
control linked list).
Takashi
===
Takashi Iwai (11):
ALSA: control: Take card->controls_rwsem in snd_ctl_rename()
staging: greybus: audio_helper: Use snd_ctl_remove_id()
ASoC: atmel: mchp-pdmc: Use snd_ctl_remove_id()
ALSA: control: Take controls_rwsem lock in snd_ctl_remove()
ALSA: control: Add lockdep warning to internal functions
ASoC: sigmadsp: Simplify with snd_ctl_activate_id()
staging: greybus: Avoid abusing controls_rwsem
ALSA: control: Make snd_ctl_find_id() argument const
ALSA: control: Introduce unlocked version for snd_ctl_find_*() helpers
ALSA: control: Take lock in snd_ctl_find_id() and snd_ctl_find_numid()
ALSA: emu10k1: Go back and simplify with snd_ctl_find_id()
drivers/staging/greybus/audio_codec.c | 18 ++--
drivers/staging/greybus/audio_codec.h | 1 +
drivers/staging/greybus/audio_helper.c | 20 +---
include/sound/control.h | 6 +-
sound/core/control.c | 126 ++++++++++++++++++++-----
sound/core/control_compat.c | 2 +-
sound/core/control_led.c | 2 +-
sound/core/jack.c | 2 -
sound/core/oss/mixer_oss.c | 10 +-
sound/core/pcm.c | 2 -
sound/isa/sb/emu8000.c | 2 -
sound/isa/sb/sb16_csp.c | 2 -
sound/pci/emu10k1/emufx.c | 5 -
sound/pci/hda/hda_codec.c | 2 -
sound/soc/atmel/mchp-pdmc.c | 12 +--
sound/soc/codecs/sigmadsp.c | 25 +----
sound/soc/soc-topology.c | 3 -
17 files changed, 129 insertions(+), 111 deletions(-)
--
2.35.3
The variables gb_tty->port.close_delay and gb_tty->port.closing_wait are
ofter accessed together while holding the lock gb_tty->port.mutex. Here is
an example in set_serial_info():
mutex_lock(&gb_tty->port.mutex);
...
gb_tty->port.close_delay = close_delay;
gb_tty->port.closing_wait = closing_wait;
...
mutex_unlock(&gb_tty->port.mutex);
However, they are accessed without holding the lock gb_tty->port.mutex when
are accessed in get_serial_info():
ss->close_delay = jiffies_to_msecs(gb_tty->port.close_delay) / 10;
ss->closing_wait =
gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE :
jiffies_to_msecs(gb_tty->port.closing_wait) / 10;
In my opinion, this may be a harmful race, because ss->close_delay can be
inconsistent with ss->closing_wait if gb_tty->port.close_delay and
gb_tty->port.closing_wait are updated by another thread after the
assignment to ss->close_delay.
Besides, the select operator may return wrong value if
gb_tty->port.closing_wait is updated right after the condition is
calculated.
To fix this possible data-inconsistency caused by data race, a lock and
unlock pair is added when accessing different fields of gb_tty->port.
Reported-by: BassCheck <bass(a)buaa.edu.cn>
Signed-off-by: Tuo Li <islituo(a)gmail.com>
---
drivers/staging/greybus/uart.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 20a34599859f..b8875517ea6a 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -596,12 +596,14 @@ static int get_serial_info(struct tty_struct *tty,
{
struct gb_tty *gb_tty = tty->driver_data;
+ mutex_lock(&gb_tty->port.mutex);
ss->line = gb_tty->minor;
ss->close_delay = jiffies_to_msecs(gb_tty->port.close_delay) / 10;
ss->closing_wait =
gb_tty->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
ASYNC_CLOSING_WAIT_NONE :
jiffies_to_msecs(gb_tty->port.closing_wait) / 10;
+ mutex_unlock(&gb_tty->port.mutex);
return 0;
}
--
2.34.1