Skip to content

Commit fb279f4

Browse files
committed
Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "I2C has three driver bugfixes for you. We agreed on the Mac regression to go in via I2C" * 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: macintosh: therm_windtunnel: fix regression when instantiating devices i2c: altera: Fix potential integer overflow i2c: jz4780: silence log flood on txabrt
2 parents 7557c1b + 38b17af commit fb279f4

File tree

3 files changed

+34
-56
lines changed

3 files changed

+34
-56
lines changed

drivers/i2c/busses/i2c-altera.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static void altr_i2c_init(struct altr_i2c_dev *idev)
171171
/* SCL Low Time */
172172
writel(t_low, idev->base + ALTR_I2C_SCL_LOW);
173173
/* SDA Hold Time, 300ns */
174-
writel(div_u64(300 * clk_mhz, 1000), idev->base + ALTR_I2C_SDA_HOLD);
174+
writel(3 * clk_mhz / 10, idev->base + ALTR_I2C_SDA_HOLD);
175175

176176
/* Mask all master interrupt bits */
177177
altr_i2c_int_enable(idev, ALTR_I2C_ALL_IRQ, false);

drivers/i2c/busses/i2c-jz4780.c

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,6 @@
7878

7979
#define X1000_I2C_DC_STOP BIT(9)
8080

81-
static const char * const jz4780_i2c_abrt_src[] = {
82-
"ABRT_7B_ADDR_NOACK",
83-
"ABRT_10ADDR1_NOACK",
84-
"ABRT_10ADDR2_NOACK",
85-
"ABRT_XDATA_NOACK",
86-
"ABRT_GCALL_NOACK",
87-
"ABRT_GCALL_READ",
88-
"ABRT_HS_ACKD",
89-
"SBYTE_ACKDET",
90-
"ABRT_HS_NORSTRT",
91-
"SBYTE_NORSTRT",
92-
"ABRT_10B_RD_NORSTRT",
93-
"ABRT_MASTER_DIS",
94-
"ARB_LOST",
95-
"SLVFLUSH_TXFIFO",
96-
"SLV_ARBLOST",
97-
"SLVRD_INTX",
98-
};
99-
10081
#define JZ4780_I2C_INTST_IGC BIT(11)
10182
#define JZ4780_I2C_INTST_ISTT BIT(10)
10283
#define JZ4780_I2C_INTST_ISTP BIT(9)
@@ -576,21 +557,8 @@ static irqreturn_t jz4780_i2c_irq(int irqno, void *dev_id)
576557

577558
static void jz4780_i2c_txabrt(struct jz4780_i2c *i2c, int src)
578559
{
579-
int i;
580-
581-
dev_err(&i2c->adap.dev, "txabrt: 0x%08x\n", src);
582-
dev_err(&i2c->adap.dev, "device addr=%x\n",
583-
jz4780_i2c_readw(i2c, JZ4780_I2C_TAR));
584-
dev_err(&i2c->adap.dev, "send cmd count:%d %d\n",
585-
i2c->cmd, i2c->cmd_buf[i2c->cmd]);
586-
dev_err(&i2c->adap.dev, "receive data count:%d %d\n",
587-
i2c->cmd, i2c->data_buf[i2c->cmd]);
588-
589-
for (i = 0; i < 16; i++) {
590-
if (src & BIT(i))
591-
dev_dbg(&i2c->adap.dev, "I2C TXABRT[%d]=%s\n",
592-
i, jz4780_i2c_abrt_src[i]);
593-
}
560+
dev_dbg(&i2c->adap.dev, "txabrt: 0x%08x, cmd: %d, send: %d, recv: %d\n",
561+
src, i2c->cmd, i2c->cmd_buf[i2c->cmd], i2c->data_buf[i2c->cmd]);
594562
}
595563

596564
static inline int jz4780_i2c_xfer_read(struct jz4780_i2c *i2c,

drivers/macintosh/therm_windtunnel.c

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,11 @@ static int control_loop(void *dummy)
300300
/* i2c probing and setup */
301301
/************************************************************************/
302302

303-
static int
304-
do_attach( struct i2c_adapter *adapter )
303+
static void do_attach(struct i2c_adapter *adapter)
305304
{
305+
struct i2c_board_info info = { };
306+
struct device_node *np;
307+
306308
/* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */
307309
static const unsigned short scan_ds1775[] = {
308310
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
@@ -313,25 +315,24 @@ do_attach( struct i2c_adapter *adapter )
313315
I2C_CLIENT_END
314316
};
315317

316-
if( strncmp(adapter->name, "uni-n", 5) )
317-
return 0;
318-
319-
if( !x.running ) {
320-
struct i2c_board_info info;
318+
if (x.running || strncmp(adapter->name, "uni-n", 5))
319+
return;
321320

322-
memset(&info, 0, sizeof(struct i2c_board_info));
323-
strlcpy(info.type, "therm_ds1775", I2C_NAME_SIZE);
321+
np = of_find_compatible_node(adapter->dev.of_node, NULL, "MAC,ds1775");
322+
if (np) {
323+
of_node_put(np);
324+
} else {
325+
strlcpy(info.type, "MAC,ds1775", I2C_NAME_SIZE);
324326
i2c_new_probed_device(adapter, &info, scan_ds1775, NULL);
327+
}
325328

326-
strlcpy(info.type, "therm_adm1030", I2C_NAME_SIZE);
329+
np = of_find_compatible_node(adapter->dev.of_node, NULL, "MAC,adm1030");
330+
if (np) {
331+
of_node_put(np);
332+
} else {
333+
strlcpy(info.type, "MAC,adm1030", I2C_NAME_SIZE);
327334
i2c_new_probed_device(adapter, &info, scan_adm1030, NULL);
328-
329-
if( x.thermostat && x.fan ) {
330-
x.running = 1;
331-
x.poll_task = kthread_run(control_loop, NULL, "g4fand");
332-
}
333335
}
334-
return 0;
335336
}
336337

337338
static int
@@ -404,8 +405,8 @@ attach_thermostat( struct i2c_client *cl )
404405
enum chip { ds1775, adm1030 };
405406

406407
static const struct i2c_device_id therm_windtunnel_id[] = {
407-
{ "therm_ds1775", ds1775 },
408-
{ "therm_adm1030", adm1030 },
408+
{ "MAC,ds1775", ds1775 },
409+
{ "MAC,adm1030", adm1030 },
409410
{ }
410411
};
411412
MODULE_DEVICE_TABLE(i2c, therm_windtunnel_id);
@@ -414,18 +415,27 @@ static int
414415
do_probe(struct i2c_client *cl, const struct i2c_device_id *id)
415416
{
416417
struct i2c_adapter *adapter = cl->adapter;
418+
int ret = 0;
417419

418420
if( !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA
419421
| I2C_FUNC_SMBUS_WRITE_BYTE) )
420422
return 0;
421423

422424
switch (id->driver_data) {
423425
case adm1030:
424-
return attach_fan( cl );
426+
ret = attach_fan(cl);
427+
break;
425428
case ds1775:
426-
return attach_thermostat(cl);
429+
ret = attach_thermostat(cl);
430+
break;
427431
}
428-
return 0;
432+
433+
if (!x.running && x.thermostat && x.fan) {
434+
x.running = 1;
435+
x.poll_task = kthread_run(control_loop, NULL, "g4fand");
436+
}
437+
438+
return ret;
429439
}
430440

431441
static struct i2c_driver g4fan_driver = {

0 commit comments

Comments
 (0)