Add a property in at24.c
Subsystems (3)
cover Add a property in at24.c
From: "alanx.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 driver so that don't need to add the acpi or i2c ids for specific module.
alanx.chiang (2):
eeprom: at24: Add support for address-width property
dt-bindings: at24: Add address-width property
Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ drivers/misc/eeprom/at24.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
Signature · 1 line
2.7.4
PATCH RESEND 1/2 eeprom: at24: Add support for address-width property
From: "alanx.chiang" <[email protected]>
Provide a flexible way to determine the addressing bits of eeprom. It doesn't need to add acpi or i2c ids for specific modules.
--- drivers/misc/eeprom/at24.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/misc/eeprom/at24.c +16 -0
@@ -478,6 +478,22 @@ 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 : + 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: [RESEND PATCH v1 1/2] eeprom: at24: Add support for address-width property
Quoted 19 lines · On Mon, Jun 25, 2018 at 03:29:42PM +0800, [email protected] wrote:
From: "alanx.chiang" <[email protected]>
Provide a flexible way to determine the addressing bits of eeprom. It doesn't need to add acpi or i2c ids for specific modules.
Signed-off-by Alan Chiang <[email protected]>Signed-off-by Andy Yeh <[email protected]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Rajmohan Mani <[email protected]>--- drivers/misc/eeprom/at24.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/misc/eeprom/at24.c +0
-0
drivers/misc/eeprom/at24.c static void at24_properties_to_pdata(struct device *dev, · line 485
Quoted 8 lines
drivers/misc/eeprom/at24.c +5
-0@@ -478,6 +478,22 @@ 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 : + chip->flags &= ~AT24_FLAG_ADDR16 ;
I think I'd print a warning here if the bit was set. Perhaps unlikely that it'd happen but that'd suggest there's a problem nevertheless.
drivers/misc/eeprom/at24.c static void at24_properties_to_pdata(struct device *dev, · line 492
Quoted 7 lines
drivers/misc/eeprom/at24.c +7
-0+break ; +case 16 : + chip->flags |=AT24_FLAG_ADDR16 ; +break ; +default : + dev_warn(dev, + "Bad \"address-width\" property: %u\n",
Fits on previous line.
Quoted 7 lines
drivers/misc/eeprom/at24.c +4
-0+ val); + } + } + err =device_property_read_u32 (dev,"size" , &val);if (!err) chip->byte_len = val;
Signature · 2 lines
Sakari Ailus [email protected]
PATCH RESEND 2/2 dt-bindings: at24: Add address-width property
In reply to [email protected]From: "alanx.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.
--- Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/eeprom/at24.txt +3 -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 {
@@ -79,4 +81,5 @@ eeprom@52 { reg = <0x52>; pagesize = <32>; wp-gpios = <&gpio1 3 0>; + address-width = <16>; };
Signature · 1 line
2.7.4
Re: [RESEND PATCH v1 2/2] dt-bindings: at24: Add address-width property
Quoted 32 lines · On Mon, Jun 25, 2018 at 03:29:43PM +0800, [email protected] wrote:
From: "alanx.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]>Reviewed-by Sakari Ailus <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Reviewed-by Rajmohan Mani <[email protected]>--- Documentation/devicetree/bindings/eeprom/at24.txt | 3 +++ 1 file changed, 3 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 {
Documentation/devicetree/bindings/eeprom/at24.txt eeprom@52 { · line 84
Quoted 4 lines
Documentation/devicetree/bindings/eeprom/at24.txt +1
-0@@ -79,4 +81,5 @@ eeprom@52 { reg = <0x52>; pagesize = <32>; wp-gpios = <&gpio1 3 0>; + address-width = <16>;
Since we're only now adding address-width, it hasn't been needed previously. Therefore I wouldn't add it to an example.
Quoted 1 line
Documentation/devicetree/bindings/eeprom/at24.txt +0
-0};
Signature · 2 lines
Sakari Ailus [email protected]
Hi Alan,
Quoted 6 lines · On Mon, Jun 25, 2018 at 03:29:41PM +0800, [email protected] wrote:
From: "alanx.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 driver so that don't need to add the acpi or i2c ids for specific module.
Instead I'd point to the fact that other chip features have specific properties while this one does not have one yet.
Quoted 9 lines
alanx.chiang (2):
eeprom: at24: Add support for address-width property
dt-bindings: at24: Add address-width propertyDocumentation/devicetree/bindings/eeprom/at24.txt | 3 +++ drivers/misc/eeprom/at24.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
A few notes:
- Please cc patches (or patchsets) touching DT bindings to the devicetree list <[email protected]>.
- Do also CC the maintainer (use scripts/get_maintainer.pl if unclear).
- Linux-media list is not the right list for I²C EEPROM driver patches --- please send the patches to [email protected] instead.
- You generally need to obtain the reviewed-by (or acked-by) tags from reviewers explicitly. You can't just add them based on people commenting on your patches.
- DT binding patches precede driver changes.
Please send v2 with these addressed.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Quoted 2 lines · Sakari Ailus
Hi Alan,
On Mon, Jun 25, 2018 at 03:29:41PM +0800, [email protected] wrote:
Agreed on all Sakari's comments against the series.
Signature · 2 lines
With Best Regards, Andy Shevchenko