Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: ohci: fix error path to detect initiated reset in TI TSB41BA3D phy

A commit 404957c1e207 ("firewire: ohci: use guard macro to serialize
accesses to phy registers") refactored initiated_reset() helper function,
while the error path was changed wrongly.

This commit fixes the bug.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 80f3401dfeb2 ("firewire: ohci: use guard macro to serialize accesses to phy registers")
Link: https://lore.kernel.org/r/20240817091128.180303-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+10 -5
+10 -5
drivers/firewire/ohci.c
··· 1919 1919 return i; 1920 1920 } 1921 1921 1922 - static bool initiated_reset(struct fw_ohci *ohci) 1922 + static int detect_initiated_reset(struct fw_ohci *ohci, bool *is_initiated_reset) 1923 1923 { 1924 1924 int reg; 1925 1925 ··· 1946 1946 return reg; 1947 1947 1948 1948 // bit 3 indicates "initiated reset" 1949 - return !!((reg & 0x08) == 0x08); 1949 + *is_initiated_reset = !!((reg & 0x08) == 0x08); 1950 + 1951 + return 0; 1950 1952 } 1951 1953 1952 1954 /* ··· 1958 1956 */ 1959 1957 static int find_and_insert_self_id(struct fw_ohci *ohci, int self_id_count) 1960 1958 { 1961 - int reg, i, pos; 1959 + int reg, i, pos, err; 1960 + bool is_initiated_reset; 1962 1961 u32 self_id = 0; 1963 1962 1964 1963 // link active 1, speed 3, bridge 0, contender 1, more packets 0. ··· 1988 1985 1989 1986 for (i = 0; i < 3; i++) { 1990 1987 enum phy_packet_self_id_port_status status; 1991 - int err; 1992 1988 1993 1989 err = get_status_for_port(ohci, i, &status); 1994 1990 if (err < 0) ··· 1996 1994 self_id_sequence_set_port_status(&self_id, 1, i, status); 1997 1995 } 1998 1996 1999 - phy_packet_self_id_zero_set_initiated_reset(&self_id, initiated_reset(ohci)); 1997 + err = detect_initiated_reset(ohci, &is_initiated_reset); 1998 + if (err < 0) 1999 + return err; 2000 + phy_packet_self_id_zero_set_initiated_reset(&self_id, is_initiated_reset); 2000 2001 2001 2002 pos = get_self_id_pos(ohci, self_id, self_id_count); 2002 2003 if (pos >= 0) {