mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] eeprom/at25: add erase support
@ 2011-11-21 13:31 Hubert Feurstein
  2011-11-22  9:19 ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Hubert Feurstein @ 2011-11-21 13:31 UTC (permalink / raw)
  To: barebox

Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
---
 drivers/eeprom/at25.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
index 8a979d5..39c5846 100644
--- a/drivers/eeprom/at25.c
+++ b/drivers/eeprom/at25.c
@@ -237,10 +237,25 @@ static off_t at25_ee_lseek(struct cdev *cdev, off_t off)
 	return off;
 }
 
+static int at25_ee_erase(struct cdev *cdev, size_t count, unsigned long offset)
+{
+	int result;
+	void *buf = xzalloc(count);
+
+	result = at25_ee_write(cdev, buf, count, offset, 0);
+	free(buf);
+
+	if (result < 0)
+		return result;
+
+	return 0;
+}
+
 static struct file_operations at25_fops = {
 	.read	= at25_ee_read,
 	.write	= at25_ee_write,
 	.lseek	= at25_ee_lseek,
+	.erase	= at25_ee_erase,
 };
 
 static int at25_probe(struct device_d *dev)
-- 
1.7.4.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eeprom/at25: add erase support
  2011-11-21 13:31 [PATCH] eeprom/at25: add erase support Hubert Feurstein
@ 2011-11-22  9:19 ` Sascha Hauer
  2011-11-22  9:58   ` Hubert Feurstein
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2011-11-22  9:19 UTC (permalink / raw)
  To: Hubert Feurstein; +Cc: barebox

On Mon, Nov 21, 2011 at 02:31:31PM +0100, Hubert Feurstein wrote:
> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
> ---
>  drivers/eeprom/at25.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)

Do we need this? We normally only have erase functions for devices that
need it, namely flashes.

Sascha

> 
> diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c
> index 8a979d5..39c5846 100644
> --- a/drivers/eeprom/at25.c
> +++ b/drivers/eeprom/at25.c
> @@ -237,10 +237,25 @@ static off_t at25_ee_lseek(struct cdev *cdev, off_t off)
>  	return off;
>  }
>  
> +static int at25_ee_erase(struct cdev *cdev, size_t count, unsigned long offset)
> +{
> +	int result;
> +	void *buf = xzalloc(count);
> +
> +	result = at25_ee_write(cdev, buf, count, offset, 0);
> +	free(buf);
> +
> +	if (result < 0)
> +		return result;
> +
> +	return 0;
> +}
> +
>  static struct file_operations at25_fops = {
>  	.read	= at25_ee_read,
>  	.write	= at25_ee_write,
>  	.lseek	= at25_ee_lseek,
> +	.erase	= at25_ee_erase,
>  };
>  
>  static int at25_probe(struct device_d *dev)
> -- 
> 1.7.4.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eeprom/at25: add erase support
  2011-11-22  9:19 ` Sascha Hauer
@ 2011-11-22  9:58   ` Hubert Feurstein
  2011-11-22 10:45     ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Hubert Feurstein @ 2011-11-22  9:58 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

2011/11/22 Sascha Hauer <s.hauer@pengutronix.de>:
> On Mon, Nov 21, 2011 at 02:31:31PM +0100, Hubert Feurstein wrote:
>> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
>> ---
>>  drivers/eeprom/at25.c |   15 +++++++++++++++
>>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> Do we need this? We normally only have erase functions for devices that
> need it, namely flashes.
>
In my case I use the eeprom (or fram) to store the environment. So
with this I can erase the env-partition simply by calling 'erase
/dev/env0'.
So it's more like a convenience function. Or is there a other
possibility to easily erase a partition completely? The memset-command
is not really suitable because I have to pass the size as an argument.

Best Regards
Hubert

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eeprom/at25: add erase support
  2011-11-22  9:58   ` Hubert Feurstein
@ 2011-11-22 10:45     ` Sascha Hauer
  2011-11-24 13:02       ` Hubert Feurstein
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2011-11-22 10:45 UTC (permalink / raw)
  To: Hubert Feurstein; +Cc: barebox

On Tue, Nov 22, 2011 at 10:58:56AM +0100, Hubert Feurstein wrote:
> 2011/11/22 Sascha Hauer <s.hauer@pengutronix.de>:
> > On Mon, Nov 21, 2011 at 02:31:31PM +0100, Hubert Feurstein wrote:
> >> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
> >> ---
> >>  drivers/eeprom/at25.c |   15 +++++++++++++++
> >>  1 files changed, 15 insertions(+), 0 deletions(-)
> >
> > Do we need this? We normally only have erase functions for devices that
> > need it, namely flashes.
> >
> In my case I use the eeprom (or fram) to store the environment. So
> with this I can erase the env-partition simply by calling 'erase
> /dev/env0'.
> So it's more like a convenience function. Or is there a other
> possibility to easily erase a partition completely? The memset-command
> is not really suitable because I have to pass the size as an argument.

How about cp /dev/zero /dev/env0?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] eeprom/at25: add erase support
  2011-11-22 10:45     ` Sascha Hauer
@ 2011-11-24 13:02       ` Hubert Feurstein
  0 siblings, 0 replies; 5+ messages in thread
From: Hubert Feurstein @ 2011-11-24 13:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

2011/11/22 Sascha Hauer <s.hauer@pengutronix.de>:
> How about cp /dev/zero /dev/env0?
>
Well, this works, aside from the error message "write: No space left
on device". Personally I still prefer the 'erase' support also for
eeprom-like devices. Then the handling of partitions would become
uniform. But there is still the protect/unprotect thing ...

Best Regards
Hubert

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-24 13:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-21 13:31 [PATCH] eeprom/at25: add erase support Hubert Feurstein
2011-11-22  9:19 ` Sascha Hauer
2011-11-22  9:58   ` Hubert Feurstein
2011-11-22 10:45     ` Sascha Hauer
2011-11-24 13:02       ` Hubert Feurstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox