Skip to contentSkip to conversation

w1: Add 1-wire slave device driver for DS28E04-100

PATCH Greg KH 5 participants 22 messages Apr 30, 2012 – May 25, 2012

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw
Quoted 4 lines · Markus Franke

This patch adds a 1-wire slave device driver for the DS28E04-100.

Andrew asked me to relook at this patch, and it turns out to be pretty messy, I should have never applid it.

You have a lot of checkpatch warnings and errors, and you are creating new sysfs files with no documentation at all as to what you are doing, and why you are doing it. sysfs binary files at that, which should not be used by ANY code that is trying to intrepret the data being sent to those files, sysfs binary files are for "pass-through" mode only.

So please redo this patch, cleaning up all of the warnings and errors, and use the standard kernel interfaces for this type of stuff (i.e. not sysfs binary files.)

I've reverted it from my tree now, sorry.

greg k-h

#1 lore raw

Dear Greg,

Am 30.04.2012 04:13, schrieb Greg KH:

Quoted 7 lines · Markus Franke
Quoted 4 lines

This patch adds a 1-wire slave device driver for the DS28E04-100.

You have a lot of checkpatch warnings and errors, and you are creating

Don't have a clue what you mean. You were able to apply the patch successfully in the past.

Quoted 4 lines

new sysfs files with no documentation at all as to what you are doing, and why you are doing it. sysfs binary files at that, which should not be used by ANY code that is trying to intrepret the data being sent to those files, sysfs binary files are for "pass-through" mode only.

Well, I just stuck to the way things are done in already existing drivers e.g. drivers/w1/slaves/w1_ds2433.c

@Evgeniy: Any comments on this?

Best regards,

Markus Franke

author
#2 lore raw
Quoted 6 lines · Markus Franke

Dear Greg,

Am 30.04.2012 04:13, schrieb Greg KH:

Quoted 3 lines · Markus Franke
Quoted 2 lines

This patch adds a 1-wire slave device driver for the DS28E04-100.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

You have a lot of checkpatch warnings and errors, and you are creating

Don't have a clue what you mean. You were able to apply the patch successfully in the past.

Applying it was fine, but the patch created lots of problems if you ran it through the scripts/checkpatch.pl tool. Please fix all of those warnings and errors up.

Quoted 7 lines
Quoted 4 lines

new sysfs files with no documentation at all as to what you are doing, and why you are doing it. sysfs binary files at that, which should not be used by ANY code that is trying to intrepret the data being sent to those files, sysfs binary files are for "pass-through" mode only.

Well, I just stuck to the way things are done in already existing drivers e.g. drivers/w1/slaves/w1_ds2433.c

Really? Ick, where are those files documented?

greg k-h

#3 lore raw
Quoted 4 lines · Greg KH
Quoted 2 lines

Well, I just stuck to the way things are done in already existing drivers e.g. drivers/w1/slaves/w1_ds2433.c

Really? Ick, where are those files documented?

I'm kinda lost here.

To clarify things a bit - w1 allows to create 'private' sysfs files for special functionality which exists only in given driver - like enable/disable checksum and so on. It has to be documented and must follow common kernel codying standards of course.

Signature · 1 line
	Evgeniy Polyakov
#4 lore raw

Dear Evgeniy,

I have reworked the patch and now I am not getting any checkpatch warnings or errors anymore.

How about the binary sysfs files? If I understand correctly I would add a documentation file under Documentation/w1/slaves which documents both sysfs files (eeprom & pio).

@Greg: Could you live with those driver specific binary sysfs files?

Best regards,
Markus Franke

Am 03.05.2012 20:00, schrieb Evgeniy Polyakov:

Quoted 13 lines · Greg KH
Quoted 4 lines
Quoted 2 lines

Well, I just stuck to the way things are done in already existing drivers e.g. drivers/w1/slaves/w1_ds2433.c

Really? Ick, where are those files documented?

I'm kinda lost here.

To clarify things a bit - w1 allows to create 'private' sysfs files for special functionality which exists only in given driver - like enable/disable checksum and so on. It has to be documented and must follow common kernel codying standards of course.

author
#5 lore raw
Quoted 10 lines · Markus Franke

Dear Evgeniy,

I have reworked the patch and now I am not getting any checkpatch warnings or errors anymore.

How about the binary sysfs files? If I understand correctly I would add a documentation file under Documentation/w1/slaves which documents both sysfs files (eeprom & pio).

@Greg: Could you live with those driver specific binary sysfs files?

Why do you need them? What are they there for?

greg k-h

#6 lore raw

Dear Greg,

the file "pio" is used for reading the current PIO state of the DS28E04-100. The "eeprom" file is for reading/writing the EEPROM memory of the same device.

As already mentioned before this is exactly the way how other w1 slave drivers are handling stuff like this. I could also wrap everything within a character device driver if this the way you would prefer. If not, then please give me some advise how to exchange these couple of bytes between user and kernel space.

Best regards,
Markus Franke

Am 10.05.2012 00:06, schrieb Greg KH:

Quoted 16 lines · Markus Franke
Quoted 10 lines

Dear Evgeniy,

I have reworked the patch and now I am not getting any checkpatch warnings or errors anymore.

How about the binary sysfs files? If I understand correctly I would add a documentation file under Documentation/w1/slaves which documents both sysfs files (eeprom & pio).

@Greg: Could you live with those driver specific binary sysfs files?

Why do you need them? What are they there for?

greg k-h

author
#7 lore raw

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

Quoted 4 lines · Markus Franke

Dear Greg,

the file "pio" is used for reading the current PIO state of the DS28E04-100.

Why is this a binary file? That seems like it should not be, as a binary sysfs file should be "pass-through" only.

Quoted 2 lines

The "eeprom" file is for reading/writing the EEPROM memory of the same device.

That seems ok.

Quoted 2 lines

As already mentioned before this is exactly the way how other w1 slave drivers are handling stuff like this.

Then those drivers are wrong as well, sorry :(

thanks,

greg k-h

#8 lore raw

Dear Greg,

Am 10.05.2012 00:24, schrieb Greg KH:

Quoted 5 lines
Quoted 2 lines

the file "pio" is used for reading the current PIO state of the DS28E04-100.

Why is this a binary file? That seems like it should not be, as a binary sysfs file should be "pass-through" only.

Well, the data read/written through this file is actually directly "passed" on to the device. There are two bits which reflect the current state of the PIO pins of the DS28E04. However, I must admit that this could also be implemented as regular sysfs attributes.

Best regards,
Markus Franke

#9 lore raw
Quoted 4 lines · Markus Franke

Well, the data read/written through this file is actually directly "passed" on to the device. There are two bits which reflect the current state of the PIO pins of the DS28E04. However, I must admit that this could also be implemented as regular sysfs attributes.

Greg, could you please describe what is exactly wrong with binary sysfs file? Or am I missing that it is not usual sysfs file but some special stuff?

Signature · 1 line
	Evgeniy Polyakov
author
#10 lore raw
Quoted 9 lines · Evgeniy Polyakov
Quoted 4 lines · Markus Franke

Well, the data read/written through this file is actually directly "passed" on to the device. There are two bits which reflect the current state of the PIO pins of the DS28E04. However, I must admit that this could also be implemented as regular sysfs attributes.

Greg, could you please describe what is exactly wrong with binary sysfs file? Or am I missing that it is not usual sysfs file but some special stuff?

Binary sysfs files should be "pass through" only, the kernel should not touch the data involved in them at all, it is a pipe directly from the kernel to userspace for binary blob data, like firmware images. You should never do any processing of any binary file data at all in the kernel.

Hope this helps,

greg k-h

#11 lore raw
Quoted 5 lines · Greg KH

Binary sysfs files should be "pass through" only, the kernel should not touch the data involved in them at all, it is a pipe directly from the kernel to userspace for binary blob data, like firmware images. You should never do any processing of any binary file data at all in the kernel.

And if some of the data should be somehow changed, what interfact should be used? Also, Markus, does DS28E04 change written/read data when doing IO?

I must admit, I never heared that binary sysfs files have to follow this constraint.

Signature · 1 line
	Evgeniy Polyakov
author
#12 lore raw
Quoted 7 lines · Evgeniy Polyakov
Quoted 5 lines · Greg KH

Binary sysfs files should be "pass through" only, the kernel should not touch the data involved in them at all, it is a pipe directly from the kernel to userspace for binary blob data, like firmware images. You should never do any processing of any binary file data at all in the kernel.

Quoted 6 lines

And if some of the data should be somehow changed, what interfact should be used? Also, Markus, does DS28E04 change written/read data when doing IO?

I must admit, I never heared that binary sysfs files have to follow this constraint.

For some reason I thought I had documented it years ago, but in digging through the Documentation directory, I don't see it anywhere, sorry about that.

I'll add it to my ever-growing TODO list...

thanks,

greg k-h

#13 lore raw
In reply to Evgeniy Polyakov

Dear Evgeniy,

Am 10.05.2012 02:43, schrieb Evgeniy Polyakov:

Quoted 2 lines

be used? Also, Markus, does DS28E04 change written/read data when doing IO?

Apart from masking the upper 6 bits within w1_f1C_write_pio() the data is directly being passed down to the DS28E04. So actually there is no other processing done within the driver. Furthermore, I added a new Documentation file to Documentation/w1/slaves directory which describes the interface of this driver.

@Greg: Is the "pio" binary file now legitimate or do I have to change it to a regular sysfs attribute?

Best regards,
Markus Franke

author
#14 lore raw
Quoted 8 lines · Markus Franke

Dear Evgeniy,

Am 10.05.2012 02:43, schrieb Evgeniy Polyakov:

Quoted 2 lines

be used? Also, Markus, does DS28E04 change written/read data when doing IO?

Quoted 8 lines

Apart from masking the upper 6 bits within w1_f1C_write_pio() the data is directly being passed down to the DS28E04. So actually there is no other processing done within the driver. Furthermore, I added a new Documentation file to Documentation/w1/slaves directory which describes the interface of this driver.

@Greg: Is the "pio" binary file now legitimate or do I have to change it to a regular sysfs attribute?

I don't remember anything anymore, you will have to send the patch for me to be able to properly review it and determine this.

greg k-h

#15 lore raw

Dear Greg,

Am 10.05.2012 17:16, schrieb Greg KH:

Quoted 2 lines

I don't remember anything anymore, you will have to send the patch for me to be able to properly review it and determine this.

here comes the updated patch.

Quoted 1 line

From 3ef34f86788bfe39fa5bdb07b7e0598d3fda1f4f Mon Sep 17 00:00:00 2001

From: Markus Franke <[email protected]>
Date: Fri, 11 May 2012 00:41:35 +0200
Subject: [PATCH] Add 1-wire slave device driver for DS28E04-100

---
 Documentation/w1/slaves/w1_ds28e04 |   36 +++
 drivers/w1/slaves/Kconfig          |   13 +
 drivers/w1/slaves/Makefile         |    1 +
 drivers/w1/slaves/w1_ds28e04.c     |  476 ++++++++++++++++++++++++++++++++++++
 drivers/w1/w1_family.h             |    1 +
 5 files changed, 527 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/w1/slaves/w1_ds28e04
 create mode 100644 drivers/w1/slaves/w1_ds28e04.c
Documentation/w1/slaves/w1_ds28e04 new file +36 -0
new file mode 100644
index 0000000..7d5993c
@@ -0,0 +1,36 @@
+Kernel driver w1_ds28e04
+========================
+
+Supported chips:
+  * Maxim DS28E04-100 4096-Bit Addressable 1-Wire EEPROM with PIO
+
+supported family codes:
+	W1_FAMILY_DS28E04	0x1C
+
+Author: Markus Franke, <[email protected]> <[email protected]>
+
+Description
+-----------
+
+Support is provided through the sysfs files "eeprom" and "pio". CRC checking
+during memory accesses can optionally be enabled/disabled via the device
+attribute "crccheck". The strong pull-up can optionally be enabled/disabled
+via the module parameter "w1_strong_pullup".
+
+Memory Access
+
+	A read operation on the "eeprom" file reads the given amount of bytes
+	from the EEPROM of the DS28E04.
+
+	A write operation on the "eeprom" file writes the given byte sequence
+	to the EEPROM of the DS28E04. If CRC checking mode is enabled only
+	fully alligned blocks of 32 bytes with valid CRC16 values (in bytes 30
+	and 31) are allowed to be written.
+
+PIO Access
+
+	The 2 PIOs of the DS28E04-100 are accessible via the "pio" sysfs file.
+
+	The current status of the PIO's is returned as an 8 bit value. Bit 0/1
+	represent the state of PIO_0/PIO_1. Bits 2..7 do not care. The PIO's are
+	driven low-active, i.e. the driver delivers/expects low-active values.
drivers/w1/slaves/Kconfig +13 -0
index eb9e376..6752669 100644
@@ -94,6 +94,19 @@ config W1_SLAVE_DS2781
 
 	  If you are unsure, say N.
 
+config W1_SLAVE_DS28E04
+	tristate "4096-Bit Addressable 1-Wire EEPROM with PIO (DS28E04-100)"
+	depends on W1
+	select CRC16
+	help
+	  If you enable this you will have the DS28E04-100
+	  chip support.
+
+	  Say Y here if you want to use a 1-wire
+	  4kb EEPROM with PIO family device (DS28E04).
+
+	  If you are unsure, say N.
+
 config W1_SLAVE_BQ27000
 	tristate "BQ27000 slave support"
 	depends on W1
drivers/w1/slaves/Makefile +1 -0
index c4f1859..05188f6 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_W1_SLAVE_DS2760)	+= w1_ds2760.o
 obj-$(CONFIG_W1_SLAVE_DS2780)	+= w1_ds2780.o
 obj-$(CONFIG_W1_SLAVE_DS2781)	+= w1_ds2781.o
 obj-$(CONFIG_W1_SLAVE_BQ27000)	+= w1_bq27000.o
+obj-$(CONFIG_W1_SLAVE_DS28E04)	+= w1_ds28e04.o
drivers/w1/slaves/w1_ds28e04.c new file +476 -0

476 lines not on this page · raw message

drivers/w1/w1_family.h +1 -0
index 874aeb0..b00ada4 100644
@@ -30,6 +30,7 @@
 #define W1_FAMILY_SMEM_01	0x01
 #define W1_FAMILY_SMEM_81	0x81
 #define W1_THERM_DS18S20 	0x10
+#define W1_FAMILY_DS28E04	0x1C
 #define W1_COUNTER_DS2423	0x1D
 #define W1_THERM_DS1822  	0x22
 #define W1_EEPROM_DS2433  	0x23
Signature · 1 line
1.7.5.4
#16 lore raw
Quoted 17 lines · Markus Franke

Dear Greg,

Am 10.05.2012 17:16, schrieb Greg KH:

Quoted 2 lines

I don't remember anything anymore, you will have to send the patch for me to be able to properly review it and determine this.

here comes the updated patch.

Quoted 1 line

From 3ef34f86788bfe39fa5bdb07b7e0598d3fda1f4f Mon Sep 17 00:00:00 2001

From: Markus Franke <[email protected]>
Date: Fri, 11 May 2012 00:41:35 +0200
Subject: [PATCH] Add 1-wire slave device driver for DS28E04-100

Quoted 9 lines
---
 Documentation/w1/slaves/w1_ds28e04 |   36 +++
 drivers/w1/slaves/Kconfig          |   13 +
 drivers/w1/slaves/Makefile         |    1 +
 drivers/w1/slaves/w1_ds28e04.c     |  476 ++++++++++++++++++++++++++++++++++++
 drivers/w1/w1_family.h             |    1 +
 5 files changed, 527 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/w1/slaves/w1_ds28e04
 create mode 100644 drivers/w1/slaves/w1_ds28e04.c

You forgot a Documentation/ABI/ update that shows your sysfs files and explains them there.

Care to retry?

greg k-h

#17 lore raw
Quoted 3 lines

You forgot a Documentation/ABI/ update that shows your sysfs files and

explains them there.

There is not even a single 1-wire driver mentioned within Documentation/ABI. In which subdirectory shall I put my documentation file into? stable?

@Evgeniy: Any suggestions?

Best regards,
Markus Franke

#18 lore raw
Quoted 3 lines · Markus Franke

There is not even a single 1-wire driver mentioned within Documentation/ABI. In which subdirectory shall I put my documentation file into? stable?

I believe it is ok to add w1 dir there and describe all your ssyfs files Feel free to document others :)

Signature · 1 line
	Evgeniy Polyakov
#19 lore raw
In reply to Greg KH

Dear Greg,

Am 11.05.2012 01:04, schrieb Greg KH:

Quoted 2 lines

You forgot a Documentation/ABI/ update that shows your sysfs files and explains them there.

here comes the updated patch including the review comments of Andrew.

Quoted 1 line

From d2afaf266d09f4c93d38b47ebeb5a5d28e230500 Mon Sep 17 00:00:00 2001

From: Markus Franke <[email protected]>
Date: Sat, 26 May 2012 00:36:58 +0200
Subject: [PATCH 2/2] Add 1-wire slave device driver for DS28E04-100

---
 Documentation/ABI/stable/sysfs-driver-w1_ds28e04 |   15 +
 Documentation/w1/slaves/w1_ds28e04               |   36 ++
 drivers/w1/slaves/Kconfig                        |   13 +
 drivers/w1/slaves/Makefile                       |    1 +
 drivers/w1/slaves/w1_ds28e04.c                   |  469 ++++++++++++++++++++++
 drivers/w1/w1_family.h                           |    1 +
 6 files changed, 535 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-driver-w1_ds28e04
 create mode 100644 Documentation/w1/slaves/w1_ds28e04
 create mode 100644 drivers/w1/slaves/w1_ds28e04.c
Documentation/ABI/stable/sysfs-driver-w1_ds28e04 new file +15 -0
new file mode 100644
index 0000000..26579ee
@@ -0,0 +1,15 @@
+What:		/sys/bus/w1/devices/.../pio
+Date:		May 2012
+Contact:	Markus Franke <[email protected]>
+Description:	read/write the contents of the two PIO's of the DS28E04-100
+		see Documentation/w1/slaves/w1_ds28e04 for detailed information
+Users:		any user space application which wants to communicate with DS28E04-100
+
+
+
+What:		/sys/bus/w1/devices/.../eeprom
+Date:		May 2012
+Contact:	Markus Franke <[email protected]>
+Description:	read/write the contents of the EEPROM memory of the DS28E04-100
+		see Documentation/w1/slaves/w1_ds28e04 for detailed information
+Users:		any user space application which wants to communicate with DS28E04-100
Documentation/w1/slaves/w1_ds28e04 new file +36 -0
new file mode 100644
index 0000000..7d5993c
@@ -0,0 +1,36 @@
+Kernel driver w1_ds28e04
+========================
+
+Supported chips:
+  * Maxim DS28E04-100 4096-Bit Addressable 1-Wire EEPROM with PIO
+
+supported family codes:
+	W1_FAMILY_DS28E04	0x1C
+
+Author: Markus Franke, <[email protected]> <[email protected]>
+
+Description
+-----------
+
+Support is provided through the sysfs files "eeprom" and "pio". CRC checking
+during memory accesses can optionally be enabled/disabled via the device
+attribute "crccheck". The strong pull-up can optionally be enabled/disabled
+via the module parameter "w1_strong_pullup".
+
+Memory Access
+
+	A read operation on the "eeprom" file reads the given amount of bytes
+	from the EEPROM of the DS28E04.
+
+	A write operation on the "eeprom" file writes the given byte sequence
+	to the EEPROM of the DS28E04. If CRC checking mode is enabled only
+	fully alligned blocks of 32 bytes with valid CRC16 values (in bytes 30
+	and 31) are allowed to be written.
+
+PIO Access
+
+	The 2 PIOs of the DS28E04-100 are accessible via the "pio" sysfs file.
+
+	The current status of the PIO's is returned as an 8 bit value. Bit 0/1
+	represent the state of PIO_0/PIO_1. Bits 2..7 do not care. The PIO's are
+	driven low-active, i.e. the driver delivers/expects low-active values.
drivers/w1/slaves/Kconfig +13 -0
index eb9e376..6752669 100644
@@ -94,6 +94,19 @@ config W1_SLAVE_DS2781
 
 	  If you are unsure, say N.
 
+config W1_SLAVE_DS28E04
+	tristate "4096-Bit Addressable 1-Wire EEPROM with PIO (DS28E04-100)"
+	depends on W1
+	select CRC16
+	help
+	  If you enable this you will have the DS28E04-100
+	  chip support.
+
+	  Say Y here if you want to use a 1-wire
+	  4kb EEPROM with PIO family device (DS28E04).
+
+	  If you are unsure, say N.
+
 config W1_SLAVE_BQ27000
 	tristate "BQ27000 slave support"
 	depends on W1
drivers/w1/slaves/Makefile +1 -0
index c4f1859..05188f6 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_W1_SLAVE_DS2760)	+= w1_ds2760.o
 obj-$(CONFIG_W1_SLAVE_DS2780)	+= w1_ds2780.o
 obj-$(CONFIG_W1_SLAVE_DS2781)	+= w1_ds2781.o
 obj-$(CONFIG_W1_SLAVE_BQ27000)	+= w1_bq27000.o
+obj-$(CONFIG_W1_SLAVE_DS28E04)	+= w1_ds28e04.o
drivers/w1/slaves/w1_ds28e04.c new file +469 -0

469 lines not on this page · raw message

drivers/w1/w1_family.h +1 -0
index 874aeb0..b00ada4 100644
@@ -30,6 +30,7 @@
 #define W1_FAMILY_SMEM_01	0x01
 #define W1_FAMILY_SMEM_81	0x81
 #define W1_THERM_DS18S20 	0x10
+#define W1_FAMILY_DS28E04	0x1C
 #define W1_COUNTER_DS2423	0x1D
 #define W1_THERM_DS1822  	0x22
 #define W1_EEPROM_DS2433  	0x23
Signature · 1 line
1.7.5.4
#20 lore raw
In reply to Markus Franke
Quoted 10 lines · On Fri, 11 May 2012 00:57:58 +0200 Markus Franke…
drivers/w1/slaves/w1_ds28e04.c new file +10 -0
+static int w1_f1C_add_slave(struct w1_slave *sl)
+{
+	int err = 0;
+	int i;
+	struct w1_f1C_data *data = NULL;
+
+	if (w1_enable_crccheck) {
+		data = kzalloc(sizeof(struct w1_f1C_data), GFP_KERNEL);
+		if (!data)
+			return -ENOMEM;

drivers/w1/slaves/w1_ds28e04.c line 417

Quoted 10 lines
drivers/w1/slaves/w1_ds28e04.c new file +10 -0
+		sl->family_data = data;
+	}
+
+	/* create binary sysfs attributes */
+	for (i = 0; i < NB_SYSFS_BIN_FILES && !err; ++i)
+		err = sysfs_create_bin_file(
+			&sl->dev.kobj, &(w1_f1C_bin_attr[i]));
+
+	if (err)
+		goto out;

If this goto is taken, we will leak 0..i sysfs files.

Quoted 4 lines
drivers/w1/slaves/w1_ds28e04.c new file +4 -0
+	/* create device attributes */
+	err = device_create_file(&sl->dev, &dev_attr_crccheck);
+
+	if (err) {

drivers/w1/slaves/w1_ds28e04.c line 432

Quoted 10 lines
drivers/w1/slaves/w1_ds28e04.c new file +10 -0
+		/* remove binary sysfs attributes */
+		for (i = 0; i < NB_SYSFS_BIN_FILES; ++i)
+			sysfs_remove_bin_file(
+				&sl->dev.kobj, &(w1_f1C_bin_attr[i]));
+	}
+
+out:
+	if (err) {
+		if (w1_enable_crccheck)
+			kfree(data);

kfree(NULL) is legal - the w1_enable_crccheck test can be removed.

Quoted 4 lines
drivers/w1/slaves/w1_ds28e04.c new file +4 -0
+	}
+
+	return err;
+}
#21 lore raw

Dear Andrew,

thanks for the feedback.

Am 11.05.2012 01:22, schrieb Andrew Morton:

Quoted 17 lines
Quoted 14 lines · On Fri, 11 May 2012 00:57:58 +0200 Markus Franke…
drivers/w1/slaves/w1_ds28e04.c new file +14 -0
+static int w1_f1C_add_slave(struct w1_slave *sl)
+{
+	int err = 0;
+	int i;
+	struct w1_f1C_data *data = NULL;
+
+	if (w1_enable_crccheck) {
+		data = kzalloc(sizeof(struct w1_f1C_data), GFP_KERNEL);
+		if (!data)
+			return -ENOMEM;
+		sl->family_data = data;
+	}
+
+	/* create binary sysfs attributes */
Quoted 8 lines

drivers/w1/slaves/w1_ds28e04.c line 417

Quoted 6 lines
drivers/w1/slaves/w1_ds28e04.c new file +6 -0
+	for (i = 0; i < NB_SYSFS_BIN_FILES && !err; ++i)
+		err = sysfs_create_bin_file(
+			&sl->dev.kobj, &(w1_f1C_bin_attr[i]));
+
+	if (err)
+		goto out;

If this goto is taken, we will leak 0..i sysfs files.

That's indeed the case. :-(

Quoted 8 lines
Quoted 8 lines
drivers/w1/slaves/w1_ds28e04.c new file +8 -0
+	/* create device attributes */
+	err = device_create_file(&sl->dev, &dev_attr_crccheck);
+
+	if (err) {
+		/* remove binary sysfs attributes */
+		for (i = 0; i < NB_SYSFS_BIN_FILES; ++i)
+			sysfs_remove_bin_file(
+				&sl->dev.kobj, &(w1_f1C_bin_attr[i]));
Quoted 8 lines

drivers/w1/slaves/w1_ds28e04.c line 432

Quoted 6 lines
drivers/w1/slaves/w1_ds28e04.c new file +6 -0
+	}
+
+out:
+	if (err) {
+		if (w1_enable_crccheck)
+			kfree(data);

kfree(NULL) is legal - the w1_enable_crccheck test can be removed.

Ok, I'll fix this for the next (hopefully final) version of the patch.

Best regards,
Markus Franke