Add a property in at24.c
v3 cover Add a property in at24.c
From: Alan Chiang <[email protected]>
In at24.c, it uses 8-bit addressing by default. In this patch, add a property address-width that provides a flexible method to pass the information to the driver.
Alan Chiang (2):
dt-bindings: at24: Add address-width property
eeprom: at24: Add support for address-width property
Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++ drivers/misc/eeprom/at24.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
Signature · 1 line
2.7.4
PATCH v3 1/2 dt-bindings: at24: Add address-width property
From: Alan Chiang <[email protected]>
The AT24 series chips use 8-bit address by default. If some chips would like to support more than 8 bits, the at24 driver should be added the compatible field for specfic chips.
Provide a flexible way to determine the addressing bits through address-width in this patch.
---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.
--- Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +2 -0
@@ -72,6 +72,8 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip is connected. + - address-width: number of address bits (one of 8, 16). + Example: eeprom@52 {
Signature · 1 line
2.7.4
PATCH v3 2/2 eeprom: at24: Add support for address-width property
In reply to [email protected]From: Alan Chiang <[email protected]>
Provide a flexible way to determine the addressing bits of eeprom. Pass the addressing bits to driver through address-width property.
---
since v1
-- Add a warn message for 8-bit addressing.
since v2
-- Modify the warning message for clear.
-- Move the clearing bit operation outside of a statement.
--- drivers/misc/eeprom/at24.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/misc/eeprom/at24.c +18 -0
@@ -478,6 +478,24 @@ static void at24_properties_to_pdata(struct device *dev,if (device_property_present (dev,"no-read-rollover" )) chip->flags |=AT24_FLAG_NO_RDROL ; + err =device_property_read_u32 (dev,"address-width" , &val); +if (!err) { +switch (val) { +case 8 : +if (chip->flags &AT24_FLAG_ADDR16 ) +dev_warn (dev,"Override address width to be 8," +"while default is 16\n" ); + chip->flags &= ~AT24_FLAG_ADDR16 ; +break ; +case 16 : + chip->flags |=AT24_FLAG_ADDR16 ; +break ; +default : +dev_warn (dev,"Bad \"address-width\" property: %u\n" , + val); + } + } + err =device_property_read_u32 (dev,"size" , &val);if (!err) chip->byte_len = val;
Signature · 1 line
2.7.4
Re: [PATCH v3 2/2] eeprom: at24: Add support for address-width property
Quoted 24 lines · On Wed, Jun 27, 2018 at 01:46:25PM +0800, [email protected] wrote:
From: Alan Chiang <[email protected]>
Provide a flexible way to determine the addressing bits of eeprom. Pass the addressing bits to driver through address-width property.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>---
since v1
-- Add a warn message for 8-bit addressing.
since v2
-- Modify the warning message for clear.
-- Move the clearing bit operation outside of a statement.--- drivers/misc/eeprom/at24.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/misc/eeprom/at24.c +0
-0
drivers/misc/eeprom/at24.c static void at24_properties_to_pdata(struct device *dev, · line 487
Quoted 10 lines
drivers/misc/eeprom/at24.c +7
-0@@ -478,6 +478,24 @@ static void at24_properties_to_pdata(struct device *dev,if (device_property_present (dev,"no-read-rollover" )) chip->flags |=AT24_FLAG_NO_RDROL ; + err =device_property_read_u32 (dev,"address-width" , &val); +if (!err) { +switch (val) { +case 8 : +if (chip->flags &AT24_FLAG_ADDR16 ) +dev_warn (dev,"Override address width to be 8," +"while default is 16\n" );
Please don't wrap strings --- it breaks grep. Exceeding 80 is ok in this case.
Quoted 17 lines
drivers/misc/eeprom/at24.c +11
-0+ chip->flags &= ~AT24_FLAG_ADDR16 ; +break ; +case 16 : + chip->flags |=AT24_FLAG_ADDR16 ; +break ; +default : +dev_warn (dev,"Bad \"address-width\" property: %u\n" , + val); + } + } + err =device_property_read_u32 (dev,"size" , &val);if (!err) chip->byte_len = val;Signature · 1 line
2.7.4
Signature · 2 lines
Sakari Ailus [email protected]
Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
In reply to [email protected]Quoted 11 lines · On Wed, Jun 27, 2018 at 01:46:24PM +0800, [email protected] wrote:
From: Alan Chiang <[email protected]>
The AT24 series chips use 8-bit address by default. If some chips would like to support more than 8 bits, the at24 driver should be added the compatible field for specfic chips.
Provide a flexible way to determine the addressing bits through address-width in this patch.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>
Signature · 2 lines
Sakari Ailus [email protected]
Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
In reply to [email protected]2018-06-27 7:46 GMT+02:00 <[email protected]>:
Quoted 36 lines
From: Alan Chiang <[email protected]>
The AT24 series chips use 8-bit address by default. If some chips would like to support more than 8 bits, the at24 driver should be added the compatible field for specfic chips.
Provide a flexible way to determine the addressing bits through address-width in this patch.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.--- Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/eeprom/at24.txt +2
-1@@ -72,6 +72,8 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip is connected. + - address-width: number of address bits (one of 8, 16). + Example: eeprom@52 { --
Quoted 2 lines
2.7.4
Rob,
we only have two possibilities here and the default is 8 bits.
What do you think about introducing a boolean property here called:
'address-width-16' instead of an integer?
Best regards,
Bartosz Golaszewski
Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
Quoted 42 lines · Bartosz Golaszewski
2018-06-27 7:46 GMT+02:00 <[email protected]>:
Quoted 36 lines
From: Alan Chiang <[email protected]>
The AT24 series chips use 8-bit address by default. If some chips would like to support more than 8 bits, the at24 driver should be added the compatible field for specfic chips.
Provide a flexible way to determine the addressing bits through address-width in this patch.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.--- Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/eeprom/at24.txt +2
-1@@ -72,6 +72,8 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip is connected. + - address-width: number of address bits (one of 8, 16). + Example: eeprom@52 { --Quoted 2 lines
2.7.4
Rob,
Quoted 4 lines
we only have two possibilities here and the default is 8 bits.
What do you think about introducing a boolean property here called:
'address-width-16' instead of an integer?
I'd have thought the same, but it turns out address-width is already being used by the at25 bindings:
Documentation/devicetree/bindings/eeprom/at25.txt
Signature · 2 lines
Sakari Ailus [email protected]
Re: [PATCH v3 1/2] dt-bindings: at24: Add address-width property
Quoted 47 lines · Sakari Ailus
Quoted 46 lines · Bartosz Golaszewski
2018-06-27 7:46 GMT+02:00 <[email protected]>:
Quoted 38 lines
From: Alan Chiang <[email protected]>
The AT24 series chips use 8-bit address by default. If some chips would like to support more than 8 bits, the at24 driver should be added the compatible field for specfic chips.
Provide a flexible way to determine the addressing bits through address-width in this patch.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>---
since v1:
-- Remove the address-width field in the example.
since v2:
-- Remove redundant space.--- Documentation/devicetree/bindings/eeprom/at24.txt | 2 ++ 1 file changed, 2 insertions(+)Documentation/devicetree/bindings/eeprom/at24.txt +0
-0@@ -72,6 +72,8 @@ Optional properties: - wp-gpios: GPIO to which the write-protect pin of the chip isconnected.
Documentation/devicetree/bindings/eeprom/at24.txt +2
-1+ - address-width: number of address bits (one of 8, 16). + Example: eeprom@52 { --Quoted 2 lines
2.7.4
Rob,
we only have two possibilities here and the default is 8 bits.
Quoted 9 lines
Quoted 2 lines
What do you think about introducing a boolean property here called:
'address-width-16' instead of an integer?I'd have thought the same, but it turns out address-width is already being
used by the at25 bindings:
Documentation/devicetree/bindings/eeprom/at25.txt
Agree with Sakari, there is no need to evolve a chaos in DT bindings. We have too many semi-hemi-duplications in bindings. Especially in this case we have already established property by a similar driver.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy