Skip to content

Commit 2e38abe

Browse files
Cezar ChiruAndi Shyti
authored andcommitted
i2c: pcf8584: Fix do not use assignment inside if conditional
Assign inside of 'if' conditional is not allowed. Move assignment from inside 'if' conditional, to one line before each 'if'conditional statement that caused errors. Enforce errors fixing based on checkpatch.pl output on file. Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20251018091258.5266-3-chiru.cezar.89@gmail.com
1 parent faef278 commit 2e38abe

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

drivers/i2c/algos/i2c-algo-pcf.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
129129
*
130130
* vdovikin: added detect code for PCF8584
131131
*/
132-
static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
132+
static int pcf_init_8584(struct i2c_algo_pcf_data *adap)
133133
{
134134
unsigned char temp;
135135

@@ -139,38 +139,38 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
139139
* check to see S1 now used as R/W ctrl -
140140
* PCF8584 does that when ESO is zero
141141
*/
142-
if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
142+
temp = get_pcf(adap, 1);
143+
if ((temp & 0x7f) != 0)
143144
return -ENXIO; /* definitely not PCF8584 */
144-
}
145145

146146
/* load own address in S0, effective address is (own << 1) */
147147
i2c_outb(adap, get_own(adap));
148148
/* check it's really written */
149-
if ((temp = i2c_inb(adap)) != get_own(adap)) {
149+
temp = i2c_inb(adap);
150+
if (temp != get_own(adap))
150151
return -ENXIO;
151-
}
152152

153153
/* S1=0xA0, next byte in S2 */
154154
set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
155155
/* check to see S2 now selected */
156-
if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
156+
temp = get_pcf(adap, 1);
157+
if ((temp & 0x7f) != I2C_PCF_ES1)
157158
return -ENXIO;
158-
}
159159

160160
/* load clock register S2 */
161161
i2c_outb(adap, get_clock(adap));
162162
/* check it's really written, the only 5 lowest bits does matter */
163-
if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
163+
temp = i2c_inb(adap);
164+
if ((temp & 0x1f) != get_clock(adap))
164165
return -ENXIO;
165-
}
166166

167167
/* Enable serial interface, idle, S0 selected */
168168
set_pcf(adap, 1, I2C_PCF_IDLE);
169169

170170
/* check to see PCF is really idled and we can access status register */
171-
if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
171+
temp = get_pcf(adap, 1);
172+
if (temp != (I2C_PCF_PIN | I2C_PCF_BB))
172173
return -ENXIO;
173-
}
174174

175175
printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");
176176

@@ -218,7 +218,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
218218
/* increment number of bytes to read by one -- read dummy byte */
219219
for (i = 0; i <= count; i++) {
220220

221-
if ((wfp = wait_for_pin(adap, &status))) {
221+
wfp = wait_for_pin(adap, &status);
222+
if (wfp) {
222223
if (wfp == -EINTR)
223224
return -EINTR; /* arbitration lost */
224225

@@ -351,7 +352,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
351352
/* register new adapter to i2c module... */
352353
adap->algo = &pcf_algo;
353354

354-
if ((rval = pcf_init_8584(pcf_adap)))
355+
rval = pcf_init_8584(pcf_adap);
356+
if (rval)
355357
return rval;
356358

357359
rval = i2c_add_adapter(adap);

0 commit comments

Comments
 (0)