aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2015-01-07 06:24:10 -0500
committerWolfram Sang <wsa@the-dreams.de>2015-03-13 10:10:58 -0400
commitfb3de30cd9c7e90c3e58cfe51b02c768b291873b (patch)
tree604d510f57293aaa928b8f44950401414adbe887
parentf2325c54f362ffa1e2e3254bcb70d6d4da49a17a (diff)
i2c: pmcmsp: make use of the new infrastructure for quirks
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index d37d9db6681e..2c40edbf6224 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -456,14 +456,6 @@ static enum pmcmsptwi_xfer_result pmcmsptwi_xfer_cmd(
456 return -EINVAL; 456 return -EINVAL;
457 } 457 }
458 458
459 if (cmd->read_len > MSP_MAX_BYTES_PER_RW ||
460 cmd->write_len > MSP_MAX_BYTES_PER_RW) {
461 dev_err(&pmcmsptwi_adapter.dev,
462 "%s: Cannot transfer more than %d bytes\n",
463 __func__, MSP_MAX_BYTES_PER_RW);
464 return -EINVAL;
465 }
466
467 mutex_lock(&data->lock); 459 mutex_lock(&data->lock);
468 dev_dbg(&pmcmsptwi_adapter.dev, 460 dev_dbg(&pmcmsptwi_adapter.dev,
469 "Setting address to 0x%04x\n", cmd->addr); 461 "Setting address to 0x%04x\n", cmd->addr);
@@ -520,25 +512,14 @@ static int pmcmsptwi_master_xfer(struct i2c_adapter *adap,
520 struct pmcmsptwi_cfg oldcfg, newcfg; 512 struct pmcmsptwi_cfg oldcfg, newcfg;
521 int ret; 513 int ret;
522 514
523 if (num > 2) { 515 if (num == 2) {
524 dev_dbg(&adap->dev, "%d messages unsupported\n", num);
525 return -EINVAL;
526 } else if (num == 2) {
527 /* Check for a dual write-then-read command */
528 struct i2c_msg *nextmsg = msg + 1; 516 struct i2c_msg *nextmsg = msg + 1;
529 if (!(msg->flags & I2C_M_RD) && 517
530 (nextmsg->flags & I2C_M_RD) && 518 cmd.type = MSP_TWI_CMD_WRITE_READ;
531 msg->addr == nextmsg->addr) { 519 cmd.write_len = msg->len;
532 cmd.type = MSP_TWI_CMD_WRITE_READ; 520 cmd.write_data = msg->buf;
533 cmd.write_len = msg->len; 521 cmd.read_len = nextmsg->len;
534 cmd.write_data = msg->buf; 522 cmd.read_data = nextmsg->buf;
535 cmd.read_len = nextmsg->len;
536 cmd.read_data = nextmsg->buf;
537 } else {
538 dev_dbg(&adap->dev,
539 "Non write-read dual messages unsupported\n");
540 return -EINVAL;
541 }
542 } else if (msg->flags & I2C_M_RD) { 523 } else if (msg->flags & I2C_M_RD) {
543 cmd.type = MSP_TWI_CMD_READ; 524 cmd.type = MSP_TWI_CMD_READ;
544 cmd.read_len = msg->len; 525 cmd.read_len = msg->len;
@@ -598,6 +579,14 @@ static u32 pmcmsptwi_i2c_func(struct i2c_adapter *adapter)
598 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL; 579 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL;
599} 580}
600 581
582static struct i2c_adapter_quirks pmcmsptwi_i2c_quirks = {
583 .flags = I2C_AQ_COMB_WRITE_THEN_READ,
584 .max_write_len = MSP_MAX_BYTES_PER_RW,
585 .max_read_len = MSP_MAX_BYTES_PER_RW,
586 .max_comb_1st_msg_len = MSP_MAX_BYTES_PER_RW,
587 .max_comb_2nd_msg_len = MSP_MAX_BYTES_PER_RW,
588};
589
601/* -- Initialization -- */ 590/* -- Initialization -- */
602 591
603static struct i2c_algorithm pmcmsptwi_algo = { 592static struct i2c_algorithm pmcmsptwi_algo = {
@@ -609,6 +598,7 @@ static struct i2c_adapter pmcmsptwi_adapter = {
609 .owner = THIS_MODULE, 598 .owner = THIS_MODULE,
610 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD, 599 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
611 .algo = &pmcmsptwi_algo, 600 .algo = &pmcmsptwi_algo,
601 .quirks = &pmcmsptwi_i2c_quirks,
612 .name = DRV_NAME, 602 .name = DRV_NAME,
613}; 603};
614 604