i2c: i801: Series with minor improvements
v2 cover i2c: i801: Series with minor improvements
This series includes a number of minor improvements, partially it's a re-send of patches submitted in December last year already.
Changes in v2:
patch 1
- change one expression for generating less binary code patch 2
- add a commit message part as comment to the code
- make changed code cleaner
patch 3
- add a commit message part as comment to the code original patch 4
- dropped
patch 4 (previously patch 5)
- change expressions for generating less binary code patch 5 (previously patch 6)
- rename new function to i801_simple_transaction
- code style fixes
patch 6
- added
patch 7
- added based on a suggestion in a review comment patch 8
- added based on a suggestion in a review comment
Heiner Kallweit (10):
i2c: i801: improve interrupt handler
i2c: i801: make FEATURE_HOST_NOTIFY dependent on FEATURE_IRQ
i2c: i801: make FEATURE_BLOCK_PROC dependent on FEATURE_BLOCK_BUFFER
i2c: i801: add helper i801_set_hstadd()
i2c: i801: add i801_simple_transaction(), complementing
i801_block_transaction()
i2c: i801: handle SMBAUXCTL_E32B in i801_block_transaction_by_block
only
i2c: i801: centralize configuring non-block commands in
i801_simple_transaction
i2c: i801: centralize configuring block commands in
i801_block_transaction
i2c: i801: call i801_check_pre() from i801_access()
i2c: i801: call i801_check_post() from i801_access()
drivers/i2c/busses/i2c-i801.c | 311 +++++++++++++++++----------------- 1 file changed, 153 insertions(+), 158 deletions(-)
Signature · 1 line
2.39.0
PATCH v2 1/10 i2c: i801: improve interrupt handler
Not sure if it can happen, but better play safe: If SMBHSTSTS_BYTE_DONE and an error flag is set, then don't trust the result and skip calling i801_isr_byte_done(). In addition clear status bit SMBHSTSTS_BYTE_DONE in the main interrupt handler, this allows to simplify the code a little.
---
v2:
- change one expression for generating less binary code
--- drivers/i2c/busses/i2c-i801.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/i2c/busses/i2c-i801.c +8 -17
@@ -558,9 +558,6 @@ static void i801_isr_byte_done(struct i801_priv *priv)/* Write next byte, except for IRQ after last byte */ outb_p (priv->data[++priv->count],SMBBLKDAT (priv)); } - -/* Clear BYTE_DONE to continue with next byte */ -outb_p (SMBHSTSTS_BYTE_DONE ,SMBHSTSTS (priv)); }static irqreturn_t i801_host_notify_isr (struct i801_priv *priv)
@@ -590,7 +587,6 @@ static irqreturn_t i801_host_notify_isr(struct i801_priv *priv)* BUS_ERR - SMI# transaction collision * FAILED - transaction was canceled due to a KILL request * When any of these occur, update ->status and signal completion. -* ->status must be cleared before kicking off the next transaction. * * 2) For byte-by-byte (I2C read/write) transactions, one BYTE_DONE interrupt * occurs for each byte of a byte-by-byte to prepare the next byte.
@@ -615,23 +611,18 @@ static irqreturn_t i801_isr(int irq, void *dev_id) } status =inb_p (SMBHSTSTS (priv)); -if (status &SMBHSTSTS_BYTE_DONE ) +if ((status & (SMBHSTSTS_BYTE_DONE |STATUS_ERROR_FLAGS )) ==SMBHSTSTS_BYTE_DONE )i801_isr_byte_done (priv);/* -* Clear remaining IRQ sources: Completion of last command, errors -* and the SMB_ALERT signal. SMB_ALERT status is set after signal -* assertion independently of the interrupt generation being blocked -* or not so clear it always when the status is set. -*/ - status &=SMBHSTSTS_INTR |STATUS_ERROR_FLAGS |SMBHSTSTS_SMBALERT_STS ; -if (status) -outb_p (status,SMBHSTSTS (priv)); - status &= ~SMBHSTSTS_SMBALERT_STS ;/* SMB_ALERT not reported */ -/* -* Report transaction result. -* ->status must be cleared before the next transaction is started. +* Clear IRQ sources: SMB_ALERT status is set after signal assertion +* independently of the interrupt generation being blocked or not +* so clear it always when the status is set. */ + status &=STATUS_FLAGS |SMBHSTSTS_SMBALERT_STS ; +outb_p (status,SMBHSTSTS (priv)); + + status &=STATUS_ERROR_FLAGS |SMBHSTSTS_INTR ;if (status) { priv->status = status;complete (&priv->done);
Signature · 1 line
2.39.0
Re: [PATCH v2 01/10] i2c: i801: improve interrupt handler
Quoted 6 lines · Heiner Kallweit
Not sure if it can happen, but better play safe: If
SMBHSTSTS_BYTE_DONEand an error flag is set, then don't trust the result and skip callingi801_isr_byte_done(). In addition clear status bitSMBHSTSTS_BYTE_DONEin the main interrupt handler, this allows to simplify the code a little.
Quoted 8 lines
Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- change one expression for generating less binary code--- drivers/i2c/busses/i2c-i801.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)(...)
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedRe: [PATCH v2 01/10] i2c: i801: improve interrupt handler
In reply to Heiner KallweitQuoted 7 lines · Heiner Kallweit
Not sure if it can happen, but better play safe: If
SMBHSTSTS_BYTE_DONEand an error flag is set, then don't trust the result and skip callingi801_isr_byte_done(). In addition clear status bitSMBHSTSTS_BYTE_DONEin the main interrupt handler, this allows to simplify the code a little.Signed-off-by Heiner Kallweit <[email protected]>
Applied to for-next, thanks!
PATCH v2 2/10 i2c: i801: make FEATURE_HOST_NOTIFY dependent on FEATURE_IRQ
In reply to Heiner KallweitHost notification uses an interrupt, therefore it makes sense only if interrupts are enabled. Make this dependency explicit by removing FEATURE_HOST_NOTIFY if FEATURE_IRQ isn't set.
---
v2:
- add a commit message part as comment to the code
- make changed code cleaner
--- drivers/i2c/busses/i2c-i801.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-i801.c +9 -5
@@ -1705,11 +1705,6 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)outb_p (inb_p (SMBAUXCTL (priv)) & ~(SMBAUXCTL_CRC |SMBAUXCTL_E32B ),SMBAUXCTL (priv)); -/* Remember original Interrupt and Host Notify settings */ - priv->original_hstcnt =inb_p (SMBHSTCNT (priv)) & ~SMBHSTCNT_KILL ; -if (priv->features &FEATURE_HOST_NOTIFY ) - priv->original_slvcmd =inb_p (SMBSLVCMD (priv)); -/* Default timeout in interrupt mode: 200 ms */ priv->adapter.timeout =HZ /5 ;
@@ -1739,6 +1734,15 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)dev_info (&dev->dev,"SMBus using %s\n" , priv->features &FEATURE_IRQ ?"PCI interrupt" :"polling" ); +/* Host notification uses an interrupt */ +if (!(priv->features &FEATURE_IRQ )) + priv->features &= ~FEATURE_HOST_NOTIFY ; + +/* Remember original Interrupt and Host Notify settings */ + priv->original_hstcnt =inb_p (SMBHSTCNT (priv)) & ~SMBHSTCNT_KILL ; +if (priv->features &FEATURE_HOST_NOTIFY ) + priv->original_slvcmd =inb_p (SMBSLVCMD (priv)); +i801_add_tco (priv); snprintf(priv->adapter.name, sizeof(priv->adapter.name),
Signature · 1 line
2.39.0
Re: [PATCH v2 02/10] i2c: i801: make FEATURE_HOST_NOTIFY dependent on FEATURE_IRQ
Quoted 5 lines · Heiner Kallweit
Host notification uses an interrupt, therefore it makes sense only if interrupts are enabled. Make this dependency explicit by removing
FEATURE_HOST_NOTIFYifFEATURE_IRQisn't set.Signed-off-by Heiner Kallweit <[email protected]>
Quoted 8 lines
---
v2:
- add a commit message part as comment to the code
- make changed code cleaner--- drivers/i2c/busses/i2c-i801.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)(...)
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedRe: [PATCH v2 02/10] i2c: i801: make FEATURE_HOST_NOTIFY dependent on FEATURE_IRQ
In reply to Heiner KallweitQuoted 5 lines · Heiner Kallweit
Host notification uses an interrupt, therefore it makes sense only if interrupts are enabled. Make this dependency explicit by removing
FEATURE_HOST_NOTIFYifFEATURE_IRQisn't set.Signed-off-by Heiner Kallweit <[email protected]>
Applied to for-next, thanks!
PATCH v2 3/10 i2c: i801: make FEATURE_BLOCK_PROC dependent on FEATURE_BLOCK_BUFFER
In reply to Heiner KallweitAccording to the datasheet the block process call requires block buffer mode. The user may disable block buffer mode by module parameter disable_features, in such a case we have to clear FEATURE_BLOCK_PROC.
---
v2:
- add a commit message part as comment to the code
--- drivers/i2c/busses/i2c-i801.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/i2c/busses/i2c-i801.c +4 -0
@@ -1658,6 +1658,10 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) } priv->features &= ~disable_features; +/* The block process call uses block buffer mode */ +if (!(priv->features &FEATURE_BLOCK_BUFFER )) + priv->features &= ~FEATURE_BLOCK_PROC ; + err =pcim_enable_device (dev);if (err) { dev_err(&dev->dev, "Failed to enable SMBus PCI device (%d)\n",
Signature · 1 line
2.39.0
Re: [PATCH v2 03/10] i2c: i801: make FEATURE_BLOCK_PROC dependent on FEATURE_BLOCK_BUFFER
Quoted 5 lines · Heiner Kallweit
According to the datasheet the block process call requires block buffer mode. The user may disable block buffer mode by module parameter
disable_features, in such a case we have to clearFEATURE_BLOCK_PROC.
Quoted 8 lines
Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- add a commit message part as comment to the code--- drivers/i2c/busses/i2c-i801.c | 4 ++++ 1 file changed, 4 insertions(+)(...)
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedRe: [PATCH v2 03/10] i2c: i801: make FEATURE_BLOCK_PROC dependent on FEATURE_BLOCK_BUFFER
In reply to Heiner KallweitQuoted 6 lines · Heiner Kallweit
According to the datasheet the block process call requires block buffer mode. The user may disable block buffer mode by module parameter
disable_features, in such a case we have to clearFEATURE_BLOCK_PROC.Signed-off-by Heiner Kallweit <[email protected]>
Applied to for-next, thanks!
PATCH v2 4/10 i2c: i801: add helper i801_set_hstadd()
In reply to Heiner KallweitFactor out setting SMBHSTADD to a helper. The current code makes the assumption that constant I2C_SMBUS_READ has bit 0 set, that's not ideal. Therefore let the new helper explicitly check for I2C_SMBUS_READ.
---
v2:
- change expressions for generating less binary code
--- drivers/i2c/busses/i2c-i801.c | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/i2c/busses/i2c-i801.c +16 -20
@@ -727,6 +727,11 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,return i801_check_post (priv, status); } +static void i801_set_hstadd (struct i801_priv *priv,u8 addr,char read_write) +{ +outb_p ((addr <<1 ) | (read_write &0x01 ),SMBHSTADD (priv)); +} +/* Block transaction function */ static int i801_block_transaction (struct i801_priv *priv,union i2c_smbus_data *data,char read_write,int command)
@@ -797,28 +802,24 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,switch (size) {case I2C_SMBUS_QUICK : -outb_p (((addr &0x7f ) <<1 ) | (read_write &0x01 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, read_write); xact =I801_QUICK ;break ;case I2C_SMBUS_BYTE : -outb_p (((addr &0x7f ) <<1 ) | (read_write &0x01 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE )outb_p (command,SMBHSTCMD (priv)); xact =I801_BYTE ;break ;case I2C_SMBUS_BYTE_DATA : -outb_p (((addr &0x7f ) <<1 ) | (read_write &0x01 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, read_write);outb_p (command,SMBHSTCMD (priv));if (read_write ==I2C_SMBUS_WRITE )outb_p (data->byte,SMBHSTDAT0 (priv)); xact =I801_BYTE_DATA ;break ;case I2C_SMBUS_WORD_DATA : -outb_p (((addr &0x7f ) <<1 ) | (read_write &0x01 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, read_write);outb_p (command,SMBHSTCMD (priv));if (read_write ==I2C_SMBUS_WRITE ) {outb_p (data->word &0xff ,SMBHSTDAT0 (priv));
@@ -827,7 +828,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL : -outb_p ((addr &0x7f ) <<1 ,SMBHSTADD (priv)); +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE );outb_p (command,SMBHSTCMD (priv));outb_p (data->word &0xff ,SMBHSTDAT0 (priv));outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv));
@@ -835,8 +836,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, read_write =I2C_SMBUS_READ ;break ;case I2C_SMBUS_BLOCK_DATA : -outb_p (((addr &0x7f ) <<1 ) | (read_write &0x01 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, read_write);outb_p (command,SMBHSTCMD (priv)); block =1 ;break ;
@@ -847,10 +847,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,* However if SPD Write Disable is set (Lynx Point and later), * the read will fail if we don't set the R/#W bit. */ -outb_p (((addr &0x7f ) <<1 ) | - ((priv->original_hstcfg &SMBHSTCFG_SPD_WD ) ? - (read_write &0x01 ) :0 ), -SMBHSTADD (priv)); +i801_set_hstadd (priv, addr, + priv->original_hstcfg &SMBHSTCFG_SPD_WD ? + read_write :I2C_SMBUS_WRITE );if (read_write ==I2C_SMBUS_READ ) {/* NB: page 240 of ICH5 datasheet also shows * that DATA1 is the cmd field when reading */
@@ -860,11 +859,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, block =1 ;break ;case I2C_SMBUS_BLOCK_PROC_CALL : -/* -* Bit 0 of the slave address register always indicate a write -* command. -*/ -outb_p ((addr &0x7f ) <<1 ,SMBHSTADD (priv)); +/* Needs to be flagged as write transaction */ +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE );outb_p (command,SMBHSTCMD (priv)); block =1 ;break ;
Signature · 1 line
2.39.0
Re: [PATCH v2 04/10] i2c: i801: add helper i801_set_hstadd()
Quoted 4 lines · Heiner Kallweit
Factor out setting SMBHSTADD to a helper. The current code makes the assumption that constant
I2C_SMBUS_READhas bit 0 set, that's not ideal. Therefore let the new helper explicitly check forI2C_SMBUS_READ.
Quoted 8 lines
Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- change expressions for generating less binary code--- drivers/i2c/busses/i2c-i801.c | 36 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 20 deletions(-)(...)
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedRe: [PATCH v2 04/10] i2c: i801: add helper i801_set_hstadd()
In reply to Heiner KallweitQuoted 5 lines · Heiner Kallweit
Factor out setting SMBHSTADD to a helper. The current code makes the assumption that constant
I2C_SMBUS_READhas bit 0 set, that's not ideal. Therefore let the new helper explicitly check forI2C_SMBUS_READ.Signed-off-by Heiner Kallweit <[email protected]>
Applied to for-next, thanks!
PATCH v2 5/10 i2c: i801: add i801_simple_transaction(), complementing i801_block_transaction()
In reply to Heiner KallweitThis patch factors out non-block pre/post processing to a new function i801_simple_transaction(), complementing existing function i801_block_transaction(). This makes i801_access() better readable.
---
v2:
- rename new function to i801_simple_transaction
- code style fixes
--- drivers/i2c/busses/i2c-i801.c | 92 +++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 37 deletions(-)
drivers/i2c/busses/i2c-i801.c +55 -37
@@ -732,6 +732,59 @@ static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write)outb_p ((addr <<1 ) | (read_write &0x01 ),SMBHSTADD (priv)); } +/* Single value transaction function */ +static int i801_simple_transaction (struct i801_priv *priv,union i2c_smbus_data *data, +char read_write,int command) +{ +int xact, ret; + +switch (command) { +case I2C_SMBUS_QUICK : + xact =I801_QUICK ; +break ; +case I2C_SMBUS_BYTE : + xact =I801_BYTE ; +break ; +case I2C_SMBUS_BYTE_DATA : +if (read_write ==I2C_SMBUS_WRITE ) +outb_p (data->byte,SMBHSTDAT0 (priv)); + xact =I801_BYTE_DATA ; +break ; +case I2C_SMBUS_WORD_DATA : +if (read_write ==I2C_SMBUS_WRITE ) { +outb_p (data->word &0xff ,SMBHSTDAT0 (priv)); +outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); + } + xact =I801_WORD_DATA ; +break ; +case I2C_SMBUS_PROC_CALL : +outb_p (data->word &0xff ,SMBHSTDAT0 (priv)); +outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); + xact =I801_PROC_CALL ; +break ; +default : +return -EOPNOTSUPP ; + } + + ret =i801_transaction (priv, xact); +if (ret || read_write ==I2C_SMBUS_WRITE ) +return ret; + +switch (command) { +case I2C_SMBUS_BYTE : +case I2C_SMBUS_BYTE_DATA : + data->byte =inb_p (SMBHSTDAT0 (priv)); +break ; +case I2C_SMBUS_WORD_DATA : +case I2C_SMBUS_PROC_CALL : + data->word =inb_p (SMBHSTDAT0 (priv)) + + (inb_p (SMBHSTDAT1 (priv)) <<8 ); +break ; + } + +return 0 ; +} +/* Block transaction function */ static int i801_block_transaction (struct i801_priv *priv,union i2c_smbus_data *data,char read_write,int command)
@@ -783,9 +836,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { - int hwpec; -int block =0 ; -int ret, xact; + int hwpec, ret, block = 0;struct i801_priv *priv =i2c_get_adapdata (adap);mutex_lock (&priv->acpi_lock);
@@ -803,36 +854,23 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,switch (size) {case I2C_SMBUS_QUICK :i801_set_hstadd (priv, addr, read_write); - xact =I801_QUICK ;break ;case I2C_SMBUS_BYTE :i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE )outb_p (command,SMBHSTCMD (priv)); - xact =I801_BYTE ;break ;case I2C_SMBUS_BYTE_DATA :i801_set_hstadd (priv, addr, read_write);outb_p (command,SMBHSTCMD (priv)); -if (read_write ==I2C_SMBUS_WRITE ) -outb_p (data->byte,SMBHSTDAT0 (priv)); - xact =I801_BYTE_DATA ;break ;case I2C_SMBUS_WORD_DATA :i801_set_hstadd (priv, addr, read_write);outb_p (command,SMBHSTCMD (priv)); -if (read_write ==I2C_SMBUS_WRITE ) { -outb_p (data->word &0xff ,SMBHSTDAT0 (priv)); -outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); - } - xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL :i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE );outb_p (command,SMBHSTCMD (priv)); -outb_p (data->word &0xff ,SMBHSTDAT0 (priv)); -outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); - xact =I801_PROC_CALL ; read_write =I2C_SMBUS_READ ;break ;case I2C_SMBUS_BLOCK_DATA :
@@ -880,7 +918,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,if (block) ret =i801_block_transaction (priv, data, read_write, size);else - ret =i801_transaction (priv, xact); + ret =i801_simple_transaction (priv, data, read_write, size);/* Some BIOSes don't like it when PEC is enabled at reboot or resume time, so we forcibly disable it after every transaction. Turn off
@@ -888,26 +926,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,if (hwpec || block)outb_p (inb_p (SMBAUXCTL (priv)) & ~(SMBAUXCTL_CRC |SMBAUXCTL_E32B ),SMBAUXCTL (priv)); - -if (block) - goto out; -if (ret) - goto out; -if ((read_write ==I2C_SMBUS_WRITE ) || (xact ==I801_QUICK )) - goto out; - -switch (xact) { -case I801_BYTE :/* Result put in SMBHSTDAT0 */ -case I801_BYTE_DATA : - data->byte =inb_p (SMBHSTDAT0 (priv)); -break ; -case I801_WORD_DATA : -case I801_PROC_CALL : - data->word =inb_p (SMBHSTDAT0 (priv)) + - (inb_p (SMBHSTDAT1 (priv)) <<8 ); -break ; - } - out:/* * Unlock the SMBus device for use by BIOS/ACPI,
Signature · 1 line
2.39.0
Re: [PATCH v2 05/10] i2c: i801: add i801_simple_transaction(), complementing i801_block_transaction()
Quoted 18 lines · Heiner Kallweit
This patch factors out non-block pre/post processing to a new function
i801_simple_transaction(), complementing existing functioni801_block_transaction(). This makesi801_access()better readable.Signed-off-by Heiner Kallweit <[email protected]>---
v2:
- rename new function toi801_simple_transaction
- code style fixes--- drivers/i2c/busses/i2c-i801.c | 92 +++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 37 deletions(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write) · line 741
Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +7
-0@@ -732,6 +732,59 @@ static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write)outb_p ((addr <<1 ) | (read_write &0x01 ),SMBHSTADD (priv)); } +/* Single value transaction function */ +static int i801_simple_transaction (struct i801_priv *priv,union i2c_smbus_data *data, +char read_write,int command) +{ +int xact, ret; + +switch (command) {
I did not notice during my initial review, but this parameter name is confusing, and this becomes even more obvious with patch 7 later. What you name "command" here is named "size" in function i801_access(). And what is named "command" there, you will name "hstcmd" in this function in patch 7. I would prefer to keep the same names (and parameter order) throughout the function stack for consistency.
Rest is OK.
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH v2 6/10 i2c: i801: handle SMBAUXCTL_E32B in i801_block_transaction_by_block only
In reply to Heiner KallweitCurrently we touch SMBAUXCTL even if not needed. That's the case for block commands that don't use block buffer mode, either because block buffer mode isn't available or because it's not supported for the respective command (e.g. I2C block transfer). Improve this by setting/resetting SMBAUXCTL_E32B in i801_block_transaction_by_block() only.
Small downside is that we know access SMBAUXCTL twice for transactions that use PEC and block buffer mode. But this should a rather rare case and the impact is negligible.
--- drivers/i2c/busses/i2c-i801.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/i2c/busses/i2c-i801.c +12 -9
@@ -511,19 +511,23 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, status =i801_transaction (priv, xact);if (status) -return status; + goto out;if (read_write ==I2C_SMBUS_READ || command ==I2C_SMBUS_BLOCK_PROC_CALL ) { len =inb_p (SMBHSTDAT0 (priv)); -if (len <1 || len >I2C_SMBUS_BLOCK_MAX ) -return -EPROTO ; +if (len <1 || len >I2C_SMBUS_BLOCK_MAX ) { + status = -EPROTO ; + goto out; + } data->block[0 ] = len;for (i =0 ; i < len; i++) data->block[i +1 ] =inb_p (SMBBLKDAT (priv)); } -return 0 ; +out: +outb_p (inb_p (SMBAUXCTL (priv)) & ~SMBAUXCTL_E32B ,SMBAUXCTL (priv)); +return status; }static void i801_isr_byte_done (struct i801_priv *priv)
@@ -921,11 +925,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, ret =i801_simple_transaction (priv, data, read_write, size);/* Some BIOSes don't like it when PEC is enabled at reboot or resume -time, so we forcibly disable it after every transaction. Turn off -E32B for the same reason. */ -if (hwpec || block) -outb_p (inb_p (SMBAUXCTL (priv)) & - ~(SMBAUXCTL_CRC |SMBAUXCTL_E32B ),SMBAUXCTL (priv)); +* time, so we forcibly disable it after every transaction. +*/ +if (hwpec) +outb_p (inb_p (SMBAUXCTL (priv)) & ~SMBAUXCTL_CRC ,SMBAUXCTL (priv)); out:/* * Unlock the SMBus device for use by BIOS/ACPI,
Signature · 1 line
2.39.0
Re: [PATCH v2 06/10] i2c: i801: handle SMBAUXCTL_E32B in i801_block_transaction_by_block only
Quoted 7 lines · Heiner Kallweit
Currently we touch SMBAUXCTL even if not needed. That's the case for block commands that don't use block buffer mode, either because block buffer mode isn't available or because it's not supported for the respective command (e.g. I2C block transfer). Improve this by setting/resetting
SMBAUXCTL_E32Bini801_block_transaction_by_block()only.Small downside is that we know access SMBAUXCTL twice for transactions
Typo: know -> now.
Quoted 2 lines
that use PEC and block buffer mode. But this should a rather rare case and the impact is negligible.
I agree, and the new way also makes things symmetric and thus more obviously correct.
Quoted 5 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)(...)
One possible further improvement step, performance-wise, would be to store the original value of SMBAUXCTL so that we can skip the inb_p() at the end of the function. What do you think?
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH v2 7/10 i2c: i801: centralize configuring non-block commands in i801_simple_transaction
In reply to Heiner KallweitCurrently configuring command register settings is disributed over multiple functions. At first cetralize this for non-block commands in i801_simple_transaction().
--- drivers/i2c/busses/i2c-i801.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/i2c/busses/i2c-i801.c +14 -17
@@ -738,35 +738,47 @@ static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write)/* Single value transaction function */ static int i801_simple_transaction (struct i801_priv *priv,union i2c_smbus_data *data, -char read_write,int command) +u8 addr,u8 hstcmd,char read_write,int command) {int xact, ret;switch (command) {case I2C_SMBUS_QUICK : +i801_set_hstadd (priv, addr, read_write); xact =I801_QUICK ;break ;case I2C_SMBUS_BYTE : +i801_set_hstadd (priv, addr, read_write); +if (read_write ==I2C_SMBUS_WRITE ) +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_BYTE ;break ;case I2C_SMBUS_BYTE_DATA : +i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE )outb_p (data->byte,SMBHSTDAT0 (priv)); +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_BYTE_DATA ;break ;case I2C_SMBUS_WORD_DATA : +i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE ) {outb_p (data->word &0xff ,SMBHSTDAT0 (priv));outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); } +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL : +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE );outb_p (data->word &0xff ,SMBHSTDAT0 (priv));outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); +outb_p (hstcmd,SMBHSTCMD (priv)); + read_write =I2C_SMBUS_READ ; xact =I801_PROC_CALL ;break ;default : +pci_err (priv->pci_dev,"Unsupported transaction %d\n" , command);return -EOPNOTSUPP ; }
@@ -857,25 +869,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,switch (size) {case I2C_SMBUS_QUICK : -i801_set_hstadd (priv, addr, read_write); -break ;case I2C_SMBUS_BYTE : -i801_set_hstadd (priv, addr, read_write); -if (read_write ==I2C_SMBUS_WRITE ) -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_BYTE_DATA : -i801_set_hstadd (priv, addr, read_write); -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_WORD_DATA : -i801_set_hstadd (priv, addr, read_write); -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_PROC_CALL : -i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); -outb_p (command,SMBHSTCMD (priv)); - read_write =I2C_SMBUS_READ ;break ;case I2C_SMBUS_BLOCK_DATA :i801_set_hstadd (priv, addr, read_write);
@@ -922,7 +919,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,if (block) ret =i801_block_transaction (priv, data, read_write, size);else - ret =i801_simple_transaction (priv, data, read_write, size); + ret =i801_simple_transaction (priv, data, addr, command, read_write, size);/* Some BIOSes don't like it when PEC is enabled at reboot or resume * time, so we forcibly disable it after every transaction.
Signature · 1 line
2.39.0
Re: [PATCH v2 07/10] i2c: i801: centralize configuring non-block commands in i801_simple_transaction
Hi Heiner,
Quoted 2 lines · Heiner Kallweit
Currently configuring command register settings is disributed over multiple functions. At first cetralize this for non-block commands in
Typo: cetralize -> centralize.
Quoted 6 lines
i801_simple_transaction().Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
I'm happy with the idea (well I kind of suggested it in the first place, so...), and pleased to see that the diffstats confirm it was a good idea.
drivers/i2c/busses/i2c-i801.c static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write) · line 741
Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +1
-1@@ -738,35 +738,47 @@ static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write)/* Single value transaction function */ static int i801_simple_transaction (struct i801_priv *priv,union i2c_smbus_data *data, -char read_write,int command) +u8 addr,u8 hstcmd,char read_write,int command)
See my review of patch 5 about how I don't like some of the parameter names. But I realize now that this problem predates your patches, functions i801_block_transaction_by_block() and i801_block_transaction_byte_by_byte() already carry the confusion. So I'm fine leaving it as is for now, maybe we can clean it up later driver-wide.
Quoted 32 lines
drivers/i2c/busses/i2c-i801.c +9
-0{int xact, ret;switch (command) {case I2C_SMBUS_QUICK : +i801_set_hstadd (priv, addr, read_write); xact =I801_QUICK ;break ;case I2C_SMBUS_BYTE : +i801_set_hstadd (priv, addr, read_write); +if (read_write ==I2C_SMBUS_WRITE ) +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_BYTE ;break ;case I2C_SMBUS_BYTE_DATA : +i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE )outb_p (data->byte,SMBHSTDAT0 (priv)); +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_BYTE_DATA ;break ;case I2C_SMBUS_WORD_DATA : +i801_set_hstadd (priv, addr, read_write);if (read_write ==I2C_SMBUS_WRITE ) {outb_p (data->word &0xff ,SMBHSTDAT0 (priv));outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); } +outb_p (hstcmd,SMBHSTCMD (priv)); xact =I801_WORD_DATA ;break ;case I2C_SMBUS_PROC_CALL : +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE );
drivers/i2c/busses/i2c-i801.c static void i801_set_hstadd(struct i801_priv *priv, u8 addr, char read_write) · line 783
Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +3
-0outb_p (data->word &0xff ,SMBHSTDAT0 (priv));outb_p ((data->word &0xff00 ) >>8 ,SMBHSTDAT1 (priv)); +outb_p (hstcmd,SMBHSTCMD (priv)); + read_write =I2C_SMBUS_READ ; xact =I801_PROC_CALL ;break ;default : +pci_err (priv->pci_dev,"Unsupported transaction %d\n" , command);return -EOPNOTSUPP ; }
The split between patches 7 and 8 isn't really clean, as you have dead code here at this step, which will only become active with the next patch. I'm willing to let it go though.
Quoted 28 lines
drivers/i2c/busses/i2c-i801.c +0
-15@@ -857,25 +869,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,switch (size) {case I2C_SMBUS_QUICK : -i801_set_hstadd (priv, addr, read_write); -break ;case I2C_SMBUS_BYTE : -i801_set_hstadd (priv, addr, read_write); -if (read_write ==I2C_SMBUS_WRITE ) -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_BYTE_DATA : -i801_set_hstadd (priv, addr, read_write); -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_WORD_DATA : -i801_set_hstadd (priv, addr, read_write); -outb_p (command,SMBHSTCMD (priv)); -break ;case I2C_SMBUS_PROC_CALL : -i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); -outb_p (command,SMBHSTCMD (priv)); - read_write =I2C_SMBUS_READ ;break ;case I2C_SMBUS_BLOCK_DATA :i801_set_hstadd (priv, addr, read_write);
drivers/i2c/busses/i2c-i801.c static s32 i801_access(struct i2c_adapter *adap, u16 addr, · line 925
Quoted 8 lines
drivers/i2c/busses/i2c-i801.c +1
-1@@ -922,7 +919,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,if (block) ret =i801_block_transaction (priv, data, read_write, size);else - ret =i801_simple_transaction (priv, data, read_write, size); + ret =i801_simple_transaction (priv, data, addr, command, read_write, size);/* Some BIOSes don't like it when PEC is enabled at reboot or resume * time, so we forcibly disable it after every transaction.
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH v2 8/10 i2c: i801: centralize configuring block commands in i801_block_transaction
In reply to Heiner KallweitSimilar to the patch for non-block commands, centralize block command register settings in i801_block_transaction().
--- drivers/i2c/busses/i2c-i801.c | 85 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 49 deletions(-)
drivers/i2c/busses/i2c-i801.c +36 -49
@@ -803,7 +803,7 @@ static int i801_simple_transaction(struct i801_priv *priv, union i2c_smbus_data/* Block transaction function */ static int i801_block_transaction (struct i801_priv *priv,union i2c_smbus_data *data, -char read_write,int command) +u8 addr,u8 hstcmd,char read_write,int command) {int result =0 ;unsigned char hostc;
@@ -813,7 +813,29 @@ static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data *else if (data->block[0 ] <1 || data->block[0 ] >I2C_SMBUS_BLOCK_MAX )return -EPROTO ; -if (command ==I2C_SMBUS_I2C_BLOCK_DATA ) { +switch (command) { +case I2C_SMBUS_BLOCK_DATA : +i801_set_hstadd (priv, addr, read_write); +outb_p (hstcmd,SMBHSTCMD (priv)); +break ; +case I2C_SMBUS_I2C_BLOCK_DATA : +/* +* NB: page 240 of ICH5 datasheet shows that the R/#W +* bit should be cleared here, even when reading. +* However if SPD Write Disable is set (Lynx Point and later), +* the read will fail if we don't set the R/#W bit. +*/ +i801_set_hstadd (priv, addr, + priv->original_hstcfg &SMBHSTCFG_SPD_WD ? + read_write :I2C_SMBUS_WRITE ); +if (read_write ==I2C_SMBUS_READ ) { +/* NB: page 240 of ICH5 datasheet also shows +* that DATA1 is the cmd field when reading +*/ +outb_p (hstcmd,SMBHSTDAT1 (priv)); + }else +outb_p (hstcmd,SMBHSTCMD (priv)); +if (read_write ==I2C_SMBUS_WRITE ) {/* set I2C_EN bit in configuration register */ pci_read_config_byte (priv->pci_dev,SMBHSTCFG , &hostc);
@@ -824,6 +846,13 @@ static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * "I2C block read is unsupported!\n");return -EOPNOTSUPP ; } + +break ; +case I2C_SMBUS_BLOCK_PROC_CALL : +/* Needs to be flagged as write transaction */ +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); +outb_p (hstcmd,SMBHSTCMD (priv)); +break ; }/* Experience has shown that the block buffer can only be used for
@@ -852,7 +881,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { - int hwpec, ret, block = 0; + int hwpec, ret;struct i801_priv *priv =i2c_get_adapdata (adap);mutex_lock (&priv->acpi_lock);
@@ -867,57 +896,16 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, && size !=I2C_SMBUS_QUICK && size !=I2C_SMBUS_I2C_BLOCK_DATA ; -switch (size) { -case I2C_SMBUS_QUICK : -case I2C_SMBUS_BYTE : -case I2C_SMBUS_BYTE_DATA : -case I2C_SMBUS_WORD_DATA : -case I2C_SMBUS_PROC_CALL : -break ; -case I2C_SMBUS_BLOCK_DATA : -i801_set_hstadd (priv, addr, read_write); -outb_p (command,SMBHSTCMD (priv)); - block =1 ; -break ; -case I2C_SMBUS_I2C_BLOCK_DATA : -/* -* NB: page 240 of ICH5 datasheet shows that the R/#W -* bit should be cleared here, even when reading. -* However if SPD Write Disable is set (Lynx Point and later), -* the read will fail if we don't set the R/#W bit. -*/ -i801_set_hstadd (priv, addr, - priv->original_hstcfg &SMBHSTCFG_SPD_WD ? - read_write :I2C_SMBUS_WRITE ); -if (read_write ==I2C_SMBUS_READ ) { -/* NB: page 240 of ICH5 datasheet also shows -* that DATA1 is the cmd field when reading */ -outb_p (command,SMBHSTDAT1 (priv)); - }else -outb_p (command,SMBHSTCMD (priv)); - block =1 ; -break ; -case I2C_SMBUS_BLOCK_PROC_CALL : -/* Needs to be flagged as write transaction */ -i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); -outb_p (command,SMBHSTCMD (priv)); - block =1 ; -break ; -default : -dev_err (&priv->pci_dev->dev,"Unsupported transaction %d\n" , - size); - ret = -EOPNOTSUPP ; - goto out; - } -if (hwpec)/* enable/disable hardware PEC */ outb_p (inb_p (SMBAUXCTL (priv)) |SMBAUXCTL_CRC ,SMBAUXCTL (priv));else outb_p (inb_p (SMBAUXCTL (priv)) & (~SMBAUXCTL_CRC ),SMBAUXCTL (priv)); -if (block) - ret =i801_block_transaction (priv, data, read_write, size); +if (size ==I2C_SMBUS_BLOCK_DATA || + size ==I2C_SMBUS_I2C_BLOCK_DATA || + size ==I2C_SMBUS_BLOCK_PROC_CALL ) + ret =i801_block_transaction (priv, data, addr, command, read_write, size);else ret =i801_simple_transaction (priv, data, addr, command, read_write, size);
@@ -926,7 +914,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,*/ if (hwpec)outb_p (inb_p (SMBAUXCTL (priv)) & ~SMBAUXCTL_CRC ,SMBAUXCTL (priv)); -out:/* * Unlock the SMBus device for use by BIOS/ACPI, * and clear status flags if not done already.
Signature · 1 line
2.39.0
Re: [PATCH v2 08/10] i2c: i801: centralize configuring block commands in i801_block_transaction
Quoted 14 lines · Heiner Kallweit
Similar to the patch for non-block commands, centralize block command register settings in
i801_block_transaction().Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 85 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 49 deletions(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * · line 849
Quoted 4 lines
drivers/i2c/busses/i2c-i801.c +1
-0@@ -824,6 +846,13 @@ static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * "I2C block read is unsupported!\n");return -EOPNOTSUPP ; } +
No blank line here.
drivers/i2c/busses/i2c-i801.c static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data * · line 858
Quoted 9 lines
drivers/i2c/busses/i2c-i801.c +6
-0+break ; +case I2C_SMBUS_BLOCK_PROC_CALL : +/* Needs to be flagged as write transaction */ +i801_set_hstadd (priv, addr,I2C_SMBUS_WRITE ); +outb_p (hstcmd,SMBHSTCMD (priv)); +break ; }/* Experience has shown that the block buffer can only be used for
Other that this minor style issue, looks good, nice clean-up.
Signature · 2 lines
Jean Delvare SUSE L3 Support
PATCH v2 9/10 i2c: i801: call i801_check_pre() from i801_access()
In reply to Heiner KallweitThis avoids code duplication, in a next step we'll call i801_check_post() from i801_transaction() as well.
--- drivers/i2c/busses/i2c-i801.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-i801.c +5 -8
@@ -462,10 +462,6 @@ static int i801_transaction(struct i801_priv *priv, int xact)unsigned long result;const struct i2c_adapter *adap = &priv->adapter; - status =i801_check_pre (priv); -if (status <0 ) -return status; -if (priv->features &FEATURE_IRQ ) {reinit_completion (&priv->done); outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START,
@@ -653,10 +649,6 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,if (command ==I2C_SMBUS_BLOCK_PROC_CALL )return -EOPNOTSUPP ; - status =i801_check_pre (priv); -if (status <0 ) -return status; - len = data->block[0 ];if (read_write ==I2C_SMBUS_WRITE ) {
@@ -892,6 +884,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,pm_runtime_get_sync (&priv->pci_dev->dev); + ret =i801_check_pre (priv); +if (ret) + goto out; + hwpec = (priv->features &FEATURE_SMBUS_PEC ) && (flags &I2C_CLIENT_PEC ) && size !=I2C_SMBUS_QUICK && size !=I2C_SMBUS_I2C_BLOCK_DATA ;
@@ -914,6 +910,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,*/ if (hwpec)outb_p (inb_p (SMBAUXCTL (priv)) & ~SMBAUXCTL_CRC ,SMBAUXCTL (priv)); +out:/* * Unlock the SMBus device for use by BIOS/ACPI, * and clear status flags if not done already.
Signature · 1 line
2.39.0
PATCH v2 10/10 i2c: i801: call i801_check_post() from i801_access()
In reply to Heiner KallweitAvoid code duplication by calling i801_check_post() from i801_access().
--- drivers/i2c/busses/i2c-i801.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-i801.c +9 -11
@@ -434,7 +434,7 @@ static int i801_wait_intr(struct i801_priv *priv) busy = status &SMBHSTSTS_HOST_BUSY ; status &=STATUS_ERROR_FLAGS |SMBHSTSTS_INTR ;if (!busy && status) -return status; +return status &STATUS_ERROR_FLAGS ; }while (time_is_after_eq_jiffies (timeout));return -ETIMEDOUT ;
@@ -458,7 +458,6 @@ static int i801_wait_byte_done(struct i801_priv *priv)static int i801_transaction (struct i801_priv *priv,int xact) { -int status;unsigned long result;const struct i2c_adapter *adap = &priv->adapter;
@@ -467,13 +466,12 @@ static int i801_transaction(struct i801_priv *priv, int xact)outb_p (xact |SMBHSTCNT_INTREN |SMBHSTCNT_START ,SMBHSTCNT (priv)); result =wait_for_completion_timeout (&priv->done, adap->timeout); -return i801_check_post (priv, result ? priv->status : -ETIMEDOUT ); +return result ? priv->status : -ETIMEDOUT ; }outb_p (xact |SMBHSTCNT_START ,SMBHSTCNT (priv)); - status =i801_wait_intr (priv); -return i801_check_post (priv, status); +return i801_wait_intr (priv); } static int i801_block_transaction_by_block(struct i801_priv *priv,
@@ -624,7 +622,7 @@ static irqreturn_t i801_isr(int irq, void *dev_id) status &=STATUS_ERROR_FLAGS |SMBHSTSTS_INTR ;if (status) { - priv->status = status; + priv->status = status &STATUS_ERROR_FLAGS ;complete (&priv->done); }
@@ -674,7 +672,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,reinit_completion (&priv->done);outb_p (priv->cmd |SMBHSTCNT_START ,SMBHSTCNT (priv)); result =wait_for_completion_timeout (&priv->done, adap->timeout); -return i801_check_post (priv, result ? priv->status : -ETIMEDOUT ); +return result ? priv->status : -ETIMEDOUT ; }for (i =1 ; i <= len; i++) {
@@ -688,7 +686,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, status =i801_wait_byte_done (priv);if (status) - goto exit; +return status;if (i ==1 && read_write ==I2C_SMBUS_READ && command !=I2C_SMBUS_I2C_BLOCK_DATA ) {
@@ -718,9 +716,7 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv,outb_p (SMBHSTSTS_BYTE_DONE ,SMBHSTSTS (priv)); } - status =i801_wait_intr (priv); -exit: -return i801_check_post (priv, status); +return i801_wait_intr (priv); }static void i801_set_hstadd (struct i801_priv *priv,u8 addr,char read_write)
@@ -905,6 +901,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,else ret =i801_simple_transaction (priv, data, addr, command, read_write, size); + ret =i801_check_post (priv, ret); +/* Some BIOSes don't like it when PEC is enabled at reboot or resume * time, so we forcibly disable it after every transaction. */
Signature · 1 line
2.39.0
Re: [PATCH v2 10/10] i2c: i801: call i801_check_post() from i801_access()
Hi Heiner,
Quoted 7 lines · Heiner Kallweit
Avoid code duplication by calling
i801_check_post()fromi801_access().Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)(...)
So I'm done reviewing the series. I have also tested the result, successfully, albeit my coverage is limited.
Patches 1-4 have been committed by Wolfram already. Patches 6, 7 and 8 have minor issues. I can take care of resubmitting if you want.
My suggested changes (renaming function parameters and storing the original value of SMBAUXCTL) are better implemented on top of that later (if you agree with them) so as to not delay this series even further.
Thanks for your work,
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH v2 10/10] i2c: i801: call i801_check_post() from i801_access()
Quoted 11 lines · Jean Delvare
Hi Heiner,
Quoted 7 lines · Heiner Kallweit
Avoid code duplication by calling
i801_check_post()fromi801_access().Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)(...)
Quoted 8 lines
Reviewed-by Jean Delvare <[email protected]>So I'm done reviewing the series. I have also tested the result, successfully, albeit my coverage is limited.
Patches 1-4 have been committed by Wolfram already. Patches 6, 7 and 8 have minor issues. I can take care of resubmitting if you want.
This would be great, thanks!
Quoted 6 lines
My suggested changes (renaming function parameters and storing the original value of SMBAUXCTL) are better implemented on top of that later (if you agree with them) so as to not delay this series even further.
Thanks for your work,