lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 24 Apr 2020 12:03:07 +0200
From:   Wolfram Sang <wsa@...-dreams.de>
To:     Björn Ardö <bjorn.ardo@...s.com>
Cc:     linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
        patrick@...cx.xyz, kernel@...s.com
Subject: Re: [PATCHv2] i2c: slave-eeprom: Make it possible to pre-load eeprom
 data

On Fri, Apr 24, 2020 at 11:04:43AM +0200, Björn Ardö wrote:
> If the slave eeprom has a "firmware-name" in devicetree, then
> pre-load the data in the eeprom with this file. Otherwise we
> init the eeprom with 0xFF.
> 
> Signed-off-by: Björn Ardö <bjorn.ardo@...s.com>

I like it a lot, thanks! Maybe we could add a SoB from Patrick for his
0xff-suggestion (but keeping you as the patch author).

Is this okay for everyone?

> ---
>  drivers/i2c/i2c-slave-eeprom.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c
> index cb415b10642f..c846c96c25c9 100644
> --- a/drivers/i2c/i2c-slave-eeprom.c
> +++ b/drivers/i2c/i2c-slave-eeprom.c
> @@ -18,6 +18,7 @@
>   */
>  
>  #include <linux/bitfield.h>
> +#include <linux/firmware.h>
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
> @@ -120,6 +121,26 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob
>  	return count;
>  }
>  
> +static int i2c_slave_init_eeprom_data(struct eeprom_data *eeprom, struct i2c_client *client,
> +					 unsigned int size)
> +{
> +	const struct firmware *fw;
> +	const char *eeprom_data;
> +	int error = device_property_read_string(&client->dev, "firmware-name", &eeprom_data);
> +
> +	if (!error) {
> +		int ret = request_firmware_into_buf(&fw, eeprom_data, &client->dev,
> +						    eeprom->buffer, size);
> +		if (ret)
> +			return ret;
> +		release_firmware(fw);
> +	} else {
> +		/* An empty eeprom typically has all bits set to 1 */
> +		memset(eeprom->buffer, 0xFF, size);
> +	}
> +	return 0;
> +}
> +
>  static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_device_id *id)
>  {
>  	struct eeprom_data *eeprom;
> @@ -138,6 +159,10 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de
>  	spin_lock_init(&eeprom->buffer_lock);
>  	i2c_set_clientdata(client, eeprom);
>  
> +	ret = i2c_slave_init_eeprom_data(eeprom, client, size);
> +	if (ret)
> +		return ret;
> +
>  	sysfs_bin_attr_init(&eeprom->bin);
>  	eeprom->bin.attr.name = "slave-eeprom";
>  	eeprom->bin.attr.mode = S_IRUSR | S_IWUSR;
> -- 
> 2.11.0
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ