@@ -1593,23 +1593,21 @@ EXPORT_SYMBOL(i2c_del_adapter);
1593
1593
* @dev: The device to scan for I2C timing properties
1594
1594
* @t: the i2c_timings struct to be filled with values
1595
1595
* @use_defaults: bool to use sane defaults derived from the I2C specification
1596
- * when properties are not found, otherwise use 0
1596
+ * when properties are not found, otherwise don't update
1597
1597
*
1598
1598
* Scan the device for the generic I2C properties describing timing parameters
1599
1599
* for the signal and fill the given struct with the results. If a property was
1600
1600
* not found and use_defaults was true, then maximum timings are assumed which
1601
1601
* are derived from the I2C specification. If use_defaults is not used, the
1602
- * results will be 0, so drivers can apply their own defaults later. The latter
1603
- * is mainly intended for avoiding regressions of existing drivers which want
1604
- * to switch to this function. New drivers almost always should use the defaults.
1602
+ * results will be as before, so drivers can apply their own defaults before
1603
+ * calling this helper. The latter is mainly intended for avoiding regressions
1604
+ * of existing drivers which want to switch to this function. New drivers
1605
+ * almost always should use the defaults.
1605
1606
*/
1606
-
1607
1607
void i2c_parse_fw_timings (struct device * dev , struct i2c_timings * t , bool use_defaults )
1608
1608
{
1609
1609
int ret ;
1610
1610
1611
- memset (t , 0 , sizeof (* t ));
1612
-
1613
1611
ret = device_property_read_u32 (dev , "clock-frequency" , & t -> bus_freq_hz );
1614
1612
if (ret && use_defaults )
1615
1613
t -> bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ ;
@@ -1632,19 +1630,25 @@ void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_de
1632
1630
t -> scl_fall_ns = 120 ;
1633
1631
}
1634
1632
1635
- device_property_read_u32 (dev , "i2c-scl-internal-delay-ns" , & t -> scl_int_delay_ns );
1633
+ ret = device_property_read_u32 (dev , "i2c-scl-internal-delay-ns" , & t -> scl_int_delay_ns );
1634
+ if (ret && use_defaults )
1635
+ t -> scl_int_delay_ns = 0 ;
1636
1636
1637
1637
ret = device_property_read_u32 (dev , "i2c-sda-falling-time-ns" , & t -> sda_fall_ns );
1638
1638
if (ret && use_defaults )
1639
1639
t -> sda_fall_ns = t -> scl_fall_ns ;
1640
1640
1641
- device_property_read_u32 (dev , "i2c-sda-hold-time-ns" , & t -> sda_hold_ns );
1641
+ ret = device_property_read_u32 (dev , "i2c-sda-hold-time-ns" , & t -> sda_hold_ns );
1642
+ if (ret && use_defaults )
1643
+ t -> sda_hold_ns = 0 ;
1642
1644
1643
- device_property_read_u32 (dev , "i2c-digital-filter-width-ns" ,
1644
- & t -> digital_filter_width_ns );
1645
+ ret = device_property_read_u32 (dev , "i2c-digital-filter-width-ns" , & t -> digital_filter_width_ns );
1646
+ if (ret && use_defaults )
1647
+ t -> digital_filter_width_ns = 0 ;
1645
1648
1646
- device_property_read_u32 (dev , "i2c-analog-filter-cutoff-frequency" ,
1647
- & t -> analog_filter_cutoff_freq_hz );
1649
+ ret = device_property_read_u32 (dev , "i2c-analog-filter-cutoff-frequency" , & t -> analog_filter_cutoff_freq_hz );
1650
+ if (ret && use_defaults )
1651
+ t -> analog_filter_cutoff_freq_hz = 0 ;
1648
1652
}
1649
1653
EXPORT_SYMBOL_GPL (i2c_parse_fw_timings );
1650
1654
0 commit comments