Commit 8bf98651 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
 "This contains a 5.8 regression fix for the Designware driver, a
  register bitfield fix for the fsi driver, and a missing sanity check
  for the I2C core"

* 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: core: check returned size of emulated smbus block read
  i2c: fsi: Fix the port number field in status register
  i2c: designware: Adjust bus speed independently of ACPI
parents 42afe7d1 40e05200
...@@ -286,10 +286,8 @@ int i2c_dw_acpi_configure(struct device *device) ...@@ -286,10 +286,8 @@ int i2c_dw_acpi_configure(struct device *device)
} }
EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure); EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure);
void i2c_dw_acpi_adjust_bus_speed(struct device *device) static u32 i2c_dw_acpi_round_bus_speed(struct device *device)
{ {
struct dw_i2c_dev *dev = dev_get_drvdata(device);
struct i2c_timings *t = &dev->timings;
u32 acpi_speed; u32 acpi_speed;
int i; int i;
...@@ -300,9 +298,22 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device) ...@@ -300,9 +298,22 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
*/ */
for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) { for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
if (acpi_speed >= supported_speeds[i]) if (acpi_speed >= supported_speeds[i])
break; return supported_speeds[i];
} }
acpi_speed = i < ARRAY_SIZE(supported_speeds) ? supported_speeds[i] : 0;
return 0;
}
#else /* CONFIG_ACPI */
static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; }
#endif /* CONFIG_ACPI */
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev)
{
u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev);
struct i2c_timings *t = &dev->timings;
/* /*
* Find bus speed from the "clock-frequency" device property, ACPI * Find bus speed from the "clock-frequency" device property, ACPI
...@@ -315,9 +326,7 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device) ...@@ -315,9 +326,7 @@ void i2c_dw_acpi_adjust_bus_speed(struct device *device)
else else
t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ; t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
} }
EXPORT_SYMBOL_GPL(i2c_dw_acpi_adjust_bus_speed); EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed);
#endif /* CONFIG_ACPI */
u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset) u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset)
{ {
......
...@@ -361,11 +361,10 @@ static inline int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev) { return 0; ...@@ -361,11 +361,10 @@ static inline int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev) { return 0;
#endif #endif
int i2c_dw_validate_speed(struct dw_i2c_dev *dev); int i2c_dw_validate_speed(struct dw_i2c_dev *dev);
void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev);
#if IS_ENABLED(CONFIG_ACPI) #if IS_ENABLED(CONFIG_ACPI)
int i2c_dw_acpi_configure(struct device *device); int i2c_dw_acpi_configure(struct device *device);
void i2c_dw_acpi_adjust_bus_speed(struct device *device);
#else #else
static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; } static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; }
static inline void i2c_dw_acpi_adjust_bus_speed(struct device *device) {}
#endif #endif
...@@ -240,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, ...@@ -240,7 +240,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
} }
} }
i2c_dw_acpi_adjust_bus_speed(&pdev->dev); i2c_dw_adjust_bus_speed(dev);
if (has_acpi_companion(&pdev->dev)) if (has_acpi_companion(&pdev->dev))
i2c_dw_acpi_configure(&pdev->dev); i2c_dw_acpi_configure(&pdev->dev);
......
...@@ -228,7 +228,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) ...@@ -228,7 +228,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
else else
i2c_parse_fw_timings(&pdev->dev, t, false); i2c_parse_fw_timings(&pdev->dev, t, false);
i2c_dw_acpi_adjust_bus_speed(&pdev->dev); i2c_dw_adjust_bus_speed(dev);
if (pdev->dev.of_node) if (pdev->dev.of_node)
dw_i2c_of_configure(pdev); dw_i2c_of_configure(pdev);
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
#define I2C_STAT_DAT_REQ BIT(25) #define I2C_STAT_DAT_REQ BIT(25)
#define I2C_STAT_CMD_COMP BIT(24) #define I2C_STAT_CMD_COMP BIT(24)
#define I2C_STAT_STOP_ERR BIT(23) #define I2C_STAT_STOP_ERR BIT(23)
#define I2C_STAT_MAX_PORT GENMASK(19, 16) #define I2C_STAT_MAX_PORT GENMASK(22, 16)
#define I2C_STAT_ANY_INT BIT(15) #define I2C_STAT_ANY_INT BIT(15)
#define I2C_STAT_SCL_IN BIT(11) #define I2C_STAT_SCL_IN BIT(11)
#define I2C_STAT_SDA_IN BIT(10) #define I2C_STAT_SDA_IN BIT(10)
......
...@@ -495,6 +495,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, ...@@ -495,6 +495,13 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
break; break;
case I2C_SMBUS_BLOCK_DATA: case I2C_SMBUS_BLOCK_DATA:
case I2C_SMBUS_BLOCK_PROC_CALL: case I2C_SMBUS_BLOCK_PROC_CALL:
if (msg[1].buf[0] > I2C_SMBUS_BLOCK_MAX) {
dev_err(&adapter->dev,
"Invalid block size returned: %d\n",
msg[1].buf[0]);
status = -EPROTO;
goto cleanup;
}
for (i = 0; i < msg[1].buf[0] + 1; i++) for (i = 0; i < msg[1].buf[0] + 1; i++)
data->block[i] = msg[1].buf[i]; data->block[i] = msg[1].buf[i];
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment