Re: [bug report] firewire: ohci: use guard macro to serialize accesses to phy registers
Brought to you by:
aeb,
bencollins
From: Takashi S. <o-t...@sa...> - 2024-08-15 14:41:07
|
Hi, On Thu, Aug 15, 2024 at 10:08:27AM +0300, Dan Carpenter wrote: > Hello Takashi Sakamoto, > > Commit 404957c1e207 ("firewire: ohci: use guard macro to serialize > accesses to phy registers") from Aug 5, 2024 (linux-next), leads to > the following Smatch static checker warning: > > drivers/firewire/ohci.c:1927 initiated_reset() > warn: potential negative cast to bool 'reg' > > drivers/firewire/ohci.c > 1923 static bool initiated_reset(struct fw_ohci *ohci) > 1924 { > 1925 int reg; > 1926 > --> 1927 guard(mutex)(&ohci->phy_reg_mutex); > > I'm not sure why Smatch is blaming this line... > > 1928 > 1929 // Select page 7 > 1930 reg = write_phy_reg(ohci, 7, 0xe0); > 1931 if (reg < 0) > 1932 return reg; > > This is a bool function. I think these should be return false, instead of > return negative/true. > > 1933 > 1934 reg = read_phy_reg(ohci, 8); > 1935 if (reg < 0) > 1936 return reg; > ^^^^^^^^^^ > > 1937 > 1938 // set PMODE bit > 1939 reg |= 0x40; > 1940 reg = write_phy_reg(ohci, 8, reg); > 1941 if (reg < 0) > 1942 return reg; > ^^^^^^^^^^ > > 1943 > 1944 // read register 12 > 1945 reg = read_phy_reg(ohci, 12); > 1946 if (reg < 0) > 1947 return reg; > ^^^^^^^^^^ > > 1948 > 1949 // bit 3 indicates "initiated reset" > 1950 return !!((reg & 0x08) == 0x08); > 1951 } Indeed. It is my mistake, and I'll fix it soon. Thanks Takashi Sakamoto |