* [PATCH V2 0/3] at24: parse OF-data @ 2010-11-17 12:00 Wolfram Sang 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Wolfram Sang @ 2010-11-17 12:00 UTC (permalink / raw) To: devicetree-discuss; +Cc: linuxppc-dev Here is the second round of this series: * 1/3 now uses __be32 instead of u32. * 2/3 is new and adds some more sanity checks * 3/3 is unchanged Grant, I hope you can pick 2/3 as well. Should make things easier and it is just a misc-driver (which I maintain) :) Wolfram Sang (3): misc: at24: parse OF-data, too misc: at24: add more sanity checks for parameters powerpc: pcm030/032: add pagesize to dts Documentation/powerpc/dts-bindings/eeprom.txt | 28 ++++++++++++++++ arch/powerpc/boot/dts/pcm030.dts | 1 + arch/powerpc/boot/dts/pcm032.dts | 3 +- drivers/misc/eeprom/at24.c | 43 +++++++++++++++++++++--- 4 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 Documentation/powerpc/dts-bindings/eeprom.txt -- 1.7.2.3 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-17 12:00 [PATCH V2 0/3] at24: parse OF-data Wolfram Sang @ 2010-11-17 12:00 ` Wolfram Sang 2010-11-20 10:54 ` Stijn Devriendt 2010-12-24 9:15 ` Grant Likely 2010-11-17 12:00 ` [PATCH 2/3] misc: at24: add more sanity checks for parameters Wolfram Sang 2010-11-17 12:00 ` [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts Wolfram Sang 2 siblings, 2 replies; 11+ messages in thread From: Wolfram Sang @ 2010-11-17 12:00 UTC (permalink / raw) To: devicetree-discuss; +Cc: linuxppc-dev Information about the pagesize and read-only-status may also come from the devicetree. Parse this data, too, and act accordingly. While we are here, change the initialization printout a bit. write_max is useful to know to detect performance bottlenecks, the rest is superfluous. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> --- Changes since last version: - use __be32 instead of u32 Documentation/powerpc/dts-bindings/eeprom.txt | 28 +++++++++++++++++++++ drivers/misc/eeprom/at24.c | 33 ++++++++++++++++++++---- 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 Documentation/powerpc/dts-bindings/eeprom.txt diff --git a/Documentation/powerpc/dts-bindings/eeprom.txt b/Documentation/powerpc/dts-bindings/eeprom.txt new file mode 100644 index 0000000..4342c10 --- /dev/null +++ b/Documentation/powerpc/dts-bindings/eeprom.txt @@ -0,0 +1,28 @@ +EEPROMs (I2C) + +Required properties: + + - compatible : should be "<manufacturer>,<type>" + If there is no specific driver for <manufacturer>, a generic + driver based on <type> is selected. Possible types are: + 24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64, + 24c128, 24c256, 24c512, 24c1024, spd + + - reg : the I2C address of the EEPROM + +Optional properties: + + - pagesize : the length of the pagesize for writing. Please consult the + manual of your device, that value varies a lot. A wrong value + may result in data loss! If not specified, a safety value of + '1' is used which will be very slow. + + - read-only: this parameterless property disables writes to the eeprom + +Example: + +eeprom@52 { + compatible = "atmel,24c32"; + reg = <0x52>; + pagesize = <32>; +}; diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 559b0b3..3a53efc 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -20,6 +20,7 @@ #include <linux/log2.h> #include <linux/bitops.h> #include <linux/jiffies.h> +#include <linux/of.h> #include <linux/i2c.h> #include <linux/i2c/at24.h> @@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, /*-------------------------------------------------------------------------*/ +#ifdef CONFIG_OF +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ + const __be32 *val; + struct device_node *node = client->dev.of_node; + + if (node) { + if (of_get_property(node, "read-only", NULL)) + chip->flags |= AT24_FLAG_READONLY; + val = of_get_property(node, "pagesize", NULL); + if (val) + chip->page_size = be32_to_cpup(val); + } +} +#else +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ } +#endif /* CONFIG_OF */ + static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct at24_platform_data chip; @@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) */ chip.page_size = 1; + /* update chipdata if OF is present */ + at24_get_ofdata(client, &chip); + chip.setup = NULL; chip.context = NULL; } @@ -597,19 +622,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) i2c_set_clientdata(client, at24); - dev_info(&client->dev, "%zu byte %s EEPROM %s\n", + dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n", at24->bin.size, client->name, - writable ? "(writable)" : "(read-only)"); + writable ? "writable" : "read-only", at24->write_max); if (use_smbus == I2C_SMBUS_WORD_DATA || use_smbus == I2C_SMBUS_BYTE_DATA) { dev_notice(&client->dev, "Falling back to %s reads, " "performance will suffer\n", use_smbus == I2C_SMBUS_WORD_DATA ? "word" : "byte"); } - dev_dbg(&client->dev, - "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n", - chip.page_size, num_addresses, - at24->write_max, use_smbus); /* export data to kernel code */ if (chip.setup) -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang @ 2010-11-20 10:54 ` Stijn Devriendt 2010-11-20 12:42 ` Wolfram Sang 2010-12-24 9:15 ` Grant Likely 1 sibling, 1 reply; 11+ messages in thread From: Stijn Devriendt @ 2010-11-20 10:54 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss Hi Wolfram, I'm surprised that this would work. I've patched the at24 driver as well to use OF data, but took a different approach. As far as I could tell, using compatible = <24c64>; didn't load the right module (module name is at24) and using at24 caused a device id mismatch because at24 is not a known device ID. I could be wrong here and if so, I'd very much like a source code hint as to why... My patch worked by changing drivers/of/of_i2c.c to allow a generic kind = " " statement that was filled in as i2c_board_info.type, to allow the module name and the device id to be different. This makes the at24 driver no longer rely on probing (which it claims is buggy anyway) and also benefits other drivers that support multiple devices, but where probing is difficult (e.g. lm90 driver). I'm in the process of getting employer approval to get these patches upstream. Regards, Stijn -----Oorspronkelijk bericht----- From: Wolfram Sang Sent: Wednesday, November 17, 2010 1:00 PM To: devicetree-discuss@ozlabs.org Cc: linuxppc-dev@ozlabs.org Subject: [PATCH 1/3] misc: at24: parse OF-data, too Information about the pagesize and read-only-status may also come from the devicetree. Parse this data, too, and act accordingly. While we are here, change the initialization printout a bit. write_max is useful to know to detect performance bottlenecks, the rest is superfluous. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> --- Changes since last version: - use __be32 instead of u32 Documentation/powerpc/dts-bindings/eeprom.txt | 28 +++++++++++++++++++++ drivers/misc/eeprom/at24.c | 33 ++++++++++++++++++++---- 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 Documentation/powerpc/dts-bindings/eeprom.txt diff --git a/Documentation/powerpc/dts-bindings/eeprom.txt b/Documentation/powerpc/dts-bindings/eeprom.txt new file mode 100644 index 0000000..4342c10 --- /dev/null +++ b/Documentation/powerpc/dts-bindings/eeprom.txt @@ -0,0 +1,28 @@ +EEPROMs (I2C) + +Required properties: + + - compatible : should be "<manufacturer>,<type>" + If there is no specific driver for <manufacturer>, a generic + driver based on <type> is selected. Possible types are: + 24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64, + 24c128, 24c256, 24c512, 24c1024, spd + + - reg : the I2C address of the EEPROM + +Optional properties: + + - pagesize : the length of the pagesize for writing. Please consult the + manual of your device, that value varies a lot. A wrong value + may result in data loss! If not specified, a safety value of + '1' is used which will be very slow. + + - read-only: this parameterless property disables writes to the eeprom + +Example: + +eeprom@52 { + compatible = "atmel,24c32"; + reg = <0x52>; + pagesize = <32>; +}; diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 559b0b3..3a53efc 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -20,6 +20,7 @@ #include <linux/log2.h> #include <linux/bitops.h> #include <linux/jiffies.h> +#include <linux/of.h> #include <linux/i2c.h> #include <linux/i2c/at24.h> @@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, /*-------------------------------------------------------------------------*/ +#ifdef CONFIG_OF +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ + const __be32 *val; + struct device_node *node = client->dev.of_node; + + if (node) { + if (of_get_property(node, "read-only", NULL)) + chip->flags |= AT24_FLAG_READONLY; + val = of_get_property(node, "pagesize", NULL); + if (val) + chip->page_size = be32_to_cpup(val); + } +} +#else +static void at24_get_ofdata(struct i2c_client *client, + struct at24_platform_data *chip) +{ } +#endif /* CONFIG_OF */ + static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct at24_platform_data chip; @@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) */ chip.page_size = 1; + /* update chipdata if OF is present */ + at24_get_ofdata(client, &chip); + chip.setup = NULL; chip.context = NULL; } @@ -597,19 +622,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) i2c_set_clientdata(client, at24); - dev_info(&client->dev, "%zu byte %s EEPROM %s\n", + dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n", at24->bin.size, client->name, - writable ? "(writable)" : "(read-only)"); + writable ? "writable" : "read-only", at24->write_max); if (use_smbus == I2C_SMBUS_WORD_DATA || use_smbus == I2C_SMBUS_BYTE_DATA) { dev_notice(&client->dev, "Falling back to %s reads, " "performance will suffer\n", use_smbus == I2C_SMBUS_WORD_DATA ? "word" : "byte"); } - dev_dbg(&client->dev, - "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n", - chip.page_size, num_addresses, - at24->write_max, use_smbus); /* export data to kernel code */ if (chip.setup) -- 1.7.2.3 _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-20 10:54 ` Stijn Devriendt @ 2010-11-20 12:42 ` Wolfram Sang 2010-11-20 14:07 ` Stijn Devriendt 2010-11-22 16:48 ` Stijn Devriendt 0 siblings, 2 replies; 11+ messages in thread From: Wolfram Sang @ 2010-11-20 12:42 UTC (permalink / raw) To: Stijn Devriendt; +Cc: linuxppc-dev, devicetree-discuss [-- Attachment #1: Type: text/plain, Size: 1288 bytes --] Hi, > As far as I could tell, using compatible = <24c64>; didn't load the right > module (module name is at24) and using at24 caused a device id mismatch > because at24 is not a known device ID. I could be wrong here and if so, I'd > very much like a source code hint as to why... Have you tried "<vendor>, 24c64"? All I can say is that it works for me. Plain at24 worked for years with pcm030.dts and pcm032.dts, so I don't know which issue you are facing. This patch is just about extending the support. > My patch worked by changing drivers/of/of_i2c.c to allow a generic > kind = " " statement that was filled in as i2c_board_info.type, to allow > the module name and the device id to be different. > This makes the at24 driver no longer rely on probing (which it claims > is buggy anyway) and also benefits other drivers that support multiple > devices, but where probing is difficult (e.g. lm90 driver). > > I'm in the process of getting employer approval to get these patches > upstream. I hope you will get it approved, it is a lot easier to talk about code :) Best regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-20 12:42 ` Wolfram Sang @ 2010-11-20 14:07 ` Stijn Devriendt 2010-11-22 16:48 ` Stijn Devriendt 1 sibling, 0 replies; 11+ messages in thread From: Stijn Devriendt @ 2010-11-20 14:07 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss On Sat, Nov 20, 2010 at 1:42 PM, Wolfram Sang <w.sang@pengutronix.de> wrote= : > Hi, > >> As far as I could tell, using compatible =3D <24c64>; didn't load the ri= ght >> module (module name is at24) and using at24 caused a device id mismatch >> because at24 is not a known device ID. I could be wrong here and if so, = I'd >> very =A0much like a source code hint as to why... > > Have you tried "<vendor>, 24c64"? All I can say is that it works for me. = Plain > at24 worked for years with pcm030.dts and pcm032.dts, so I don't know whi= ch > issue you are facing. This patch is just about extending the support. According to of_modalias_node, the prefix is stripped anyway, so that wouldn't help. The code probably worked using the buggy probing... > >> My patch worked by changing drivers/of/of_i2c.c to allow a generic >> kind =3D " " statement that was filled in as i2c_board_info.type, to all= ow >> the module name and the device id to be different. >> This makes the at24 driver no longer rely on probing (which it claims >> is buggy anyway) and also benefits other drivers that support multiple >> devices, but where probing is difficult (e.g. lm90 driver). >> >> I'm in the process of getting employer approval to get these patches >> upstream. > It'll get approved ;) It's the first time I'm taking these steps, but the procedures are there, so at most it'll take some extra time. > I hope you will get it approved, it is a lot easier to talk about code :) > > Best regards, > > =A0 Wolfram > > -- > Pengutronix e.K. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | Wo= lfram Sang =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| > Industrial Linux Solutions =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | http://www.p= engutronix.de/ =A0| > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkznwjIACgkQD27XaX1/VRssnwCgg55UCwZFLcMI8kJI3mhCJQxL > N7kAoJHpLn5BJpNjET+ngaQFrGxUBQm1 > =3DtyTb > -----END PGP SIGNATURE----- > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-20 12:42 ` Wolfram Sang 2010-11-20 14:07 ` Stijn Devriendt @ 2010-11-22 16:48 ` Stijn Devriendt 1 sibling, 0 replies; 11+ messages in thread From: Stijn Devriendt @ 2010-11-22 16:48 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss Hi Wolfram, I seem to be mistaken. I retried "compatible=3D<linux,24c64>" and it did all the right things. I was mistaken that request_module() only takes the driver name, at24 in this case, and not all device names in the table_ids. This pretty much makes my patch redundant. Thanks for helping me clear things out. Regards, Stijn On Sat, Nov 20, 2010 at 1:42 PM, Wolfram Sang <w.sang@pengutronix.de> wrote= : > Hi, > >> As far as I could tell, using compatible =3D <24c64>; didn't load the ri= ght >> module (module name is at24) and using at24 caused a device id mismatch >> because at24 is not a known device ID. I could be wrong here and if so, = I'd >> very =A0much like a source code hint as to why... > > Have you tried "<vendor>, 24c64"? All I can say is that it works for me. = Plain > at24 worked for years with pcm030.dts and pcm032.dts, so I don't know whi= ch > issue you are facing. This patch is just about extending the support. > >> My patch worked by changing drivers/of/of_i2c.c to allow a generic >> kind =3D " " statement that was filled in as i2c_board_info.type, to all= ow >> the module name and the device id to be different. >> This makes the at24 driver no longer rely on probing (which it claims >> is buggy anyway) and also benefits other drivers that support multiple >> devices, but where probing is difficult (e.g. lm90 driver). >> >> I'm in the process of getting employer approval to get these patches >> upstream. > > I hope you will get it approved, it is a lot easier to talk about code :) > > Best regards, > > =A0 Wolfram > > -- > Pengutronix e.K. =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | Wo= lfram Sang =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| > Industrial Linux Solutions =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | http://www.p= engutronix.de/ =A0| > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkznwjIACgkQD27XaX1/VRssnwCgg55UCwZFLcMI8kJI3mhCJQxL > N7kAoJHpLn5BJpNjET+ngaQFrGxUBQm1 > =3DtyTb > -----END PGP SIGNATURE----- > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] misc: at24: parse OF-data, too 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang 2010-11-20 10:54 ` Stijn Devriendt @ 2010-12-24 9:15 ` Grant Likely 1 sibling, 0 replies; 11+ messages in thread From: Grant Likely @ 2010-12-24 9:15 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss On Wed, Nov 17, 2010 at 01:00:48PM +0100, Wolfram Sang wrote: > Information about the pagesize and read-only-status may also come from > the devicetree. Parse this data, too, and act accordingly. While we are > here, change the initialization printout a bit. write_max is useful to > know to detect performance bottlenecks, the rest is superfluous. > > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Applied for -next, thanks. g. > --- > > Changes since last version: > > - use __be32 instead of u32 > > Documentation/powerpc/dts-bindings/eeprom.txt | 28 +++++++++++++++++++++ > drivers/misc/eeprom/at24.c | 33 ++++++++++++++++++++---- > 2 files changed, 55 insertions(+), 6 deletions(-) > create mode 100644 Documentation/powerpc/dts-bindings/eeprom.txt > > diff --git a/Documentation/powerpc/dts-bindings/eeprom.txt b/Documentation/powerpc/dts-bindings/eeprom.txt > new file mode 100644 > index 0000000..4342c10 > --- /dev/null > +++ b/Documentation/powerpc/dts-bindings/eeprom.txt > @@ -0,0 +1,28 @@ > +EEPROMs (I2C) > + > +Required properties: > + > + - compatible : should be "<manufacturer>,<type>" > + If there is no specific driver for <manufacturer>, a generic > + driver based on <type> is selected. Possible types are: > + 24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64, > + 24c128, 24c256, 24c512, 24c1024, spd > + > + - reg : the I2C address of the EEPROM > + > +Optional properties: > + > + - pagesize : the length of the pagesize for writing. Please consult the > + manual of your device, that value varies a lot. A wrong value > + may result in data loss! If not specified, a safety value of > + '1' is used which will be very slow. > + > + - read-only: this parameterless property disables writes to the eeprom > + > +Example: > + > +eeprom@52 { > + compatible = "atmel,24c32"; > + reg = <0x52>; > + pagesize = <32>; > +}; > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > index 559b0b3..3a53efc 100644 > --- a/drivers/misc/eeprom/at24.c > +++ b/drivers/misc/eeprom/at24.c > @@ -20,6 +20,7 @@ > #include <linux/log2.h> > #include <linux/bitops.h> > #include <linux/jiffies.h> > +#include <linux/of.h> > #include <linux/i2c.h> > #include <linux/i2c/at24.h> > > @@ -457,6 +458,27 @@ static ssize_t at24_macc_write(struct memory_accessor *macc, const char *buf, > > /*-------------------------------------------------------------------------*/ > > +#ifdef CONFIG_OF > +static void at24_get_ofdata(struct i2c_client *client, > + struct at24_platform_data *chip) > +{ > + const __be32 *val; > + struct device_node *node = client->dev.of_node; > + > + if (node) { > + if (of_get_property(node, "read-only", NULL)) > + chip->flags |= AT24_FLAG_READONLY; > + val = of_get_property(node, "pagesize", NULL); > + if (val) > + chip->page_size = be32_to_cpup(val); > + } > +} > +#else > +static void at24_get_ofdata(struct i2c_client *client, > + struct at24_platform_data *chip) > +{ } > +#endif /* CONFIG_OF */ > + > static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) > { > struct at24_platform_data chip; > @@ -485,6 +507,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) > */ > chip.page_size = 1; > > + /* update chipdata if OF is present */ > + at24_get_ofdata(client, &chip); > + > chip.setup = NULL; > chip.context = NULL; > } > @@ -597,19 +622,15 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) > > i2c_set_clientdata(client, at24); > > - dev_info(&client->dev, "%zu byte %s EEPROM %s\n", > + dev_info(&client->dev, "%zu byte %s EEPROM, %s, %u bytes/write\n", > at24->bin.size, client->name, > - writable ? "(writable)" : "(read-only)"); > + writable ? "writable" : "read-only", at24->write_max); > if (use_smbus == I2C_SMBUS_WORD_DATA || > use_smbus == I2C_SMBUS_BYTE_DATA) { > dev_notice(&client->dev, "Falling back to %s reads, " > "performance will suffer\n", use_smbus == > I2C_SMBUS_WORD_DATA ? "word" : "byte"); > } > - dev_dbg(&client->dev, > - "page_size %d, num_addresses %d, write_max %d, use_smbus %d\n", > - chip.page_size, num_addresses, > - at24->write_max, use_smbus); > > /* export data to kernel code */ > if (chip.setup) > -- > 1.7.2.3 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/3] misc: at24: add more sanity checks for parameters 2010-11-17 12:00 [PATCH V2 0/3] at24: parse OF-data Wolfram Sang 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang @ 2010-11-17 12:00 ` Wolfram Sang 2010-12-24 9:15 ` Grant Likely 2010-11-17 12:00 ` [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts Wolfram Sang 2 siblings, 1 reply; 11+ messages in thread From: Wolfram Sang @ 2010-11-17 12:00 UTC (permalink / raw) To: devicetree-discuss; +Cc: linuxppc-dev Side-effects happen when passing 0 to either io_limit or page_size. Give an error in case of this misconfiguration. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> --- drivers/misc/eeprom/at24.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 3a53efc..ab1ad41 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -517,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!is_power_of_2(chip.byte_len)) dev_warn(&client->dev, "byte_len looks suspicious (no power of 2)!\n"); + if (!chip.page_size) { + dev_err(&client->dev, "page_size must not be 0!\n"); + err = -EINVAL; + goto err_out; + } if (!is_power_of_2(chip.page_size)) dev_warn(&client->dev, "page_size looks suspicious (no power of 2)!\n"); @@ -681,6 +686,11 @@ static struct i2c_driver at24_driver = { static int __init at24_init(void) { + if (!io_limit) { + pr_err("at24: io_limit must not be 0!\n"); + return -EINVAL; + } + io_limit = rounddown_pow_of_two(io_limit); return i2c_add_driver(&at24_driver); } -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] misc: at24: add more sanity checks for parameters 2010-11-17 12:00 ` [PATCH 2/3] misc: at24: add more sanity checks for parameters Wolfram Sang @ 2010-12-24 9:15 ` Grant Likely 0 siblings, 0 replies; 11+ messages in thread From: Grant Likely @ 2010-12-24 9:15 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss On Wed, Nov 17, 2010 at 01:00:49PM +0100, Wolfram Sang wrote: > Side-effects happen when passing 0 to either io_limit or page_size. Give > an error in case of this misconfiguration. > > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> > --- Applied for -next, thanks. g. > drivers/misc/eeprom/at24.c | 10 ++++++++++ > 1 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > index 3a53efc..ab1ad41 100644 > --- a/drivers/misc/eeprom/at24.c > +++ b/drivers/misc/eeprom/at24.c > @@ -517,6 +517,11 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) > if (!is_power_of_2(chip.byte_len)) > dev_warn(&client->dev, > "byte_len looks suspicious (no power of 2)!\n"); > + if (!chip.page_size) { > + dev_err(&client->dev, "page_size must not be 0!\n"); > + err = -EINVAL; > + goto err_out; > + } > if (!is_power_of_2(chip.page_size)) > dev_warn(&client->dev, > "page_size looks suspicious (no power of 2)!\n"); > @@ -681,6 +686,11 @@ static struct i2c_driver at24_driver = { > > static int __init at24_init(void) > { > + if (!io_limit) { > + pr_err("at24: io_limit must not be 0!\n"); > + return -EINVAL; > + } > + > io_limit = rounddown_pow_of_two(io_limit); > return i2c_add_driver(&at24_driver); > } > -- > 1.7.2.3 > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts 2010-11-17 12:00 [PATCH V2 0/3] at24: parse OF-data Wolfram Sang 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang 2010-11-17 12:00 ` [PATCH 2/3] misc: at24: add more sanity checks for parameters Wolfram Sang @ 2010-11-17 12:00 ` Wolfram Sang 2010-12-24 9:15 ` Grant Likely 2 siblings, 1 reply; 11+ messages in thread From: Wolfram Sang @ 2010-11-17 12:00 UTC (permalink / raw) To: devicetree-discuss; +Cc: linuxppc-dev Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> --- arch/powerpc/boot/dts/pcm030.dts | 1 + arch/powerpc/boot/dts/pcm032.dts | 3 ++- 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts index 8a4ec30..e7c36bc 100644 --- a/arch/powerpc/boot/dts/pcm030.dts +++ b/arch/powerpc/boot/dts/pcm030.dts @@ -259,6 +259,7 @@ eeprom@52 { compatible = "catalyst,24c32"; reg = <0x52>; + pagesize = <32>; }; }; diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts index 85d857a..e175e2c 100644 --- a/arch/powerpc/boot/dts/pcm032.dts +++ b/arch/powerpc/boot/dts/pcm032.dts @@ -257,8 +257,9 @@ reg = <0x51>; }; eeprom@52 { - compatible = "at24,24c32"; + compatible = "catalyst,24c32"; reg = <0x52>; + pagesize = <32>; }; }; -- 1.7.2.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts 2010-11-17 12:00 ` [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts Wolfram Sang @ 2010-12-24 9:15 ` Grant Likely 0 siblings, 0 replies; 11+ messages in thread From: Grant Likely @ 2010-12-24 9:15 UTC (permalink / raw) To: Wolfram Sang; +Cc: linuxppc-dev, devicetree-discuss On Wed, Nov 17, 2010 at 01:00:50PM +0100, Wolfram Sang wrote: > Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Applied for -next, thanks. g. > --- > arch/powerpc/boot/dts/pcm030.dts | 1 + > arch/powerpc/boot/dts/pcm032.dts | 3 ++- > 2 files changed, 3 insertions(+), 1 deletions(-) > > diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts > index 8a4ec30..e7c36bc 100644 > --- a/arch/powerpc/boot/dts/pcm030.dts > +++ b/arch/powerpc/boot/dts/pcm030.dts > @@ -259,6 +259,7 @@ > eeprom@52 { > compatible = "catalyst,24c32"; > reg = <0x52>; > + pagesize = <32>; > }; > }; > > diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts > index 85d857a..e175e2c 100644 > --- a/arch/powerpc/boot/dts/pcm032.dts > +++ b/arch/powerpc/boot/dts/pcm032.dts > @@ -257,8 +257,9 @@ > reg = <0x51>; > }; > eeprom@52 { > - compatible = "at24,24c32"; > + compatible = "catalyst,24c32"; > reg = <0x52>; > + pagesize = <32>; > }; > }; > > -- > 1.7.2.3 > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-12-24 9:15 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-17 12:00 [PATCH V2 0/3] at24: parse OF-data Wolfram Sang 2010-11-17 12:00 ` [PATCH 1/3] misc: at24: parse OF-data, too Wolfram Sang 2010-11-20 10:54 ` Stijn Devriendt 2010-11-20 12:42 ` Wolfram Sang 2010-11-20 14:07 ` Stijn Devriendt 2010-11-22 16:48 ` Stijn Devriendt 2010-12-24 9:15 ` Grant Likely 2010-11-17 12:00 ` [PATCH 2/3] misc: at24: add more sanity checks for parameters Wolfram Sang 2010-12-24 9:15 ` Grant Likely 2010-11-17 12:00 ` [PATCH 3/3] powerpc: pcm030/032: add pagesize to dts Wolfram Sang 2010-12-24 9:15 ` Grant Likely
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).