From: Ivan Safonov <insafonov@gmail.com>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator
Date: Tue, 29 Dec 2015 11:11:02 +0700 [thread overview]
Message-ID: <568207D6.3070608@gmail.com> (raw)
In-Reply-To: <1451349084.3219.19.camel@perches.com>
On 12/29/2015 07:31 AM, Joe Perches wrote:
> On Tue, 2015-12-29 at 01:38 +0700, Ivan Safonov wrote:
>> On 12/29/2015 12:56 AM, Joe Perches wrote:
>>> On Mon, 2015-12-28 at 20:48 +0700, Ivan Safonov wrote:
>>>> ((thermometer < 0) ? 0 : (thermometer == X)) and (thermometer ==
>>>> X) are equal for X >= 0.
>>> X is not guaranteed to be >= 0 here
>> X is fixed constant. In this case X is {0, 1, 2}.
> Looks like it can be -1 to me (range: -1, 0, 1, 2)
>
> static int ar9003_hw_get_thermometer(struct ath_hw *ah)
> {
> struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
> struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
> int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
>
> return --thermometer;
> }
X is not thermometer. The thermometer is {-1, 0, 1, 2}. X is {0, 1, 2}.
All possible X valueswritten in the comments:
ar9003_hw_get_thermometer used only in ar9003_hw_thermometer_apply:
static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
{
struct ath9k_hw_capabilities *pCap = &ah->caps;
int thermometer = ar9003_hw_get_thermometer(ah);
u8 therm_on = (thermometer < 0) ? 0 : 1;
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(1))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(2))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
therm_on = (thermometer < 0) ? 0 : (thermometer == 0); /* X = 0 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
if (pCap->chip_chainmask & BIT(1)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
/* X = 1 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
if (pCap->chip_chainmask & BIT(2)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
/* X = 2 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
}
There is no X = -1.
WARNING: multiple messages have this Message-ID (diff)
From: Ivan Safonov <insafonov@gmail.com>
To: Joe Perches <joe@perches.com>,
QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator
Date: Tue, 29 Dec 2015 11:11:02 +0700 [thread overview]
Message-ID: <568207D6.3070608@gmail.com> (raw)
In-Reply-To: <1451349084.3219.19.camel@perches.com>
On 12/29/2015 07:31 AM, Joe Perches wrote:
> On Tue, 2015-12-29 at 01:38 +0700, Ivan Safonov wrote:
>> On 12/29/2015 12:56 AM, Joe Perches wrote:
>>> On Mon, 2015-12-28 at 20:48 +0700, Ivan Safonov wrote:
>>>> ((thermometer < 0) ? 0 : (thermometer == X)) and (thermometer ==
>>>> X) are equal for X >= 0.
>>> X is not guaranteed to be >= 0 here
>> X is fixed constant. In this case X is {0, 1, 2}.
> Looks like it can be -1 to me (range: -1, 0, 1, 2)
>
> static int ar9003_hw_get_thermometer(struct ath_hw *ah)
> {
> struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
> struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
> int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
>
> return --thermometer;
> }
X is not thermometer. The thermometer is {-1, 0, 1, 2}. X is {0, 1, 2}.
All possible X valueswritten in the comments:
ar9003_hw_get_thermometer used only in ar9003_hw_thermometer_apply:
static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
{
struct ath9k_hw_capabilities *pCap = &ah->caps;
int thermometer = ar9003_hw_get_thermometer(ah);
u8 therm_on = (thermometer < 0) ? 0 : 1;
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(1))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(2))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
therm_on = (thermometer < 0) ? 0 : (thermometer == 0); /* X = 0 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
if (pCap->chip_chainmask & BIT(1)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
/* X = 1 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
if (pCap->chip_chainmask & BIT(2)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
/* X = 2 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
}
There is no X = -1.
WARNING: multiple messages have this Message-ID (diff)
From: Ivan Safonov <insafonov@gmail.com>
To: Joe Perches <joe@perches.com>,
QCA ath9k Development <ath9k-devel@qca.qualcomm.com>
Cc: Kalle Valo <kvalo@codeaurora.org>,
linux-wireless@vger.kernel.org, ath9k-devel@venema.h4ckr.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator
Date: Tue, 29 Dec 2015 11:11:02 +0700 [thread overview]
Message-ID: <568207D6.3070608@gmail.com> (raw)
In-Reply-To: <1451349084.3219.19.camel@perches.com>
On 12/29/2015 07:31 AM, Joe Perches wrote:
> On Tue, 2015-12-29 at 01:38 +0700, Ivan Safonov wrote:
>> On 12/29/2015 12:56 AM, Joe Perches wrote:
>>> On Mon, 2015-12-28 at 20:48 +0700, Ivan Safonov wrote:
>>>> ((thermometer < 0) ? 0 : (thermometer == X)) and (thermometer ==
>>>> X) are equal for X >= 0.
>>> X is not guaranteed to be >= 0 here
>> X is fixed constant. In this case X is {0, 1, 2}.
> Looks like it can be -1 to me (range: -1, 0, 1, 2)
>
> static int ar9003_hw_get_thermometer(struct ath_hw *ah)
> {
> struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
> struct ar9300_base_eep_hdr *pBase = &eep->baseEepHeader;
> int thermometer = (pBase->miscConfiguration >> 1) & 0x3;
>
> return --thermometer;
> }
X is not thermometer. The thermometer is {-1, 0, 1, 2}. X is {0, 1, 2}.
All possible X valueswritten in the comments:
ar9003_hw_get_thermometer used only in ar9003_hw_thermometer_apply:
static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
{
struct ath9k_hw_capabilities *pCap = &ah->caps;
int thermometer = ar9003_hw_get_thermometer(ah);
u8 therm_on = (thermometer < 0) ? 0 : 1;
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(1))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
if (pCap->chip_chainmask & BIT(2))
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
therm_on = (thermometer < 0) ? 0 : (thermometer == 0); /* X = 0 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
if (pCap->chip_chainmask & BIT(1)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
/* X = 1 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
if (pCap->chip_chainmask & BIT(2)) {
therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
/* X = 2 */
REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
}
}
There is no X = -1.
next prev parent reply other threads:[~2015-12-29 4:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-28 13:48 [ath9k-devel] [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator Ivan Safonov
2015-12-28 13:48 ` Ivan Safonov
2015-12-28 13:48 ` Ivan Safonov
2015-12-28 17:56 ` [ath9k-devel] " Joe Perches
2015-12-28 17:56 ` Joe Perches
2015-12-28 17:56 ` Joe Perches
2015-12-28 17:56 ` Joe Perches
2015-12-28 18:38 ` [ath9k-devel] " Ivan Safonov
2015-12-28 18:38 ` Ivan Safonov
2015-12-28 18:38 ` Ivan Safonov
2015-12-29 0:31 ` [ath9k-devel] " Joe Perches
2015-12-29 0:31 ` Joe Perches
2015-12-29 0:31 ` Joe Perches
2015-12-29 4:11 ` Ivan Safonov [this message]
2015-12-29 4:11 ` Ivan Safonov
2015-12-29 4:11 ` Ivan Safonov
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=568207D6.3070608@gmail.com \
--to=insafonov@gmail.com \
--cc=ath9k-devel@lists.ath9k.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.