Skip to contentSkip to conversation

lis3: Change lis3 driver to one module

RFC PATCH In review Samu Onkalo 2 participants 4 messages Apr 15, 2010 – Apr 16, 2010 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 lis3: Change lis3 driver to one module

If lis3 driver is compiled as module, it consists of two modules:
core and interface. However, both of them are mandatory for proper functionality. Furthermore, it is possible to keep /dev/freefall open and remove interface part of the driver. Kernel crashes when the /dev/freefall handle is closed.

Makefile is modifed so that now there is
only one module. Filename for core part is also changed from lis3lv02d to lis3lv02d-core.c.

New modules:
lis3lv02d (for hp-laptops)
lis3lv02d_i2c for I2C connected boards
lis3lv02d_spi for SPI connected boards.

---
 drivers/hwmon/Makefile         |   10 +-
 drivers/hwmon/lis3lv02d-core.c |  610 ++++++++++++++++++++++++++++++++++++++++
 drivers/hwmon/lis3lv02d.c      |  610 ----------------------------------------
 3 files changed, 617 insertions(+), 613 deletions(-)
 create mode 100644 drivers/hwmon/lis3lv02d-core.c
 delete mode 100644 drivers/hwmon/lis3lv02d.c
drivers/hwmon/Makefile +7 -3
index 4aa1a3d..d1a245e 100644
@@ -2,6 +2,10 @@
 # Makefile for sensor chip drivers.
 #
 
+lis3lv02d-objs := lis3lv02d-core.o hp_accel.o
+lis3lv02d_i2c-objs := lis3lv02d-core.o lis3lv02d_spi.o
+lis3lv02d_spi-objs := lis3lv02d-core.o lis3lv02d_i2c.o
+
 obj-$(CONFIG_HWMON)		+= hwmon.o
 obj-$(CONFIG_HWMON_VID)		+= hwmon-vid.o
 
@@ -55,9 +59,9 @@ obj-$(CONFIG_SENSORS_IBMPEX)	+= ibmpex.o
 obj-$(CONFIG_SENSORS_IT87)	+= it87.o
 obj-$(CONFIG_SENSORS_K8TEMP)	+= k8temp.o
 obj-$(CONFIG_SENSORS_K10TEMP)	+= k10temp.o
-obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o
-obj-$(CONFIG_SENSORS_LIS3_SPI)	+= lis3lv02d.o lis3lv02d_spi.o
-obj-$(CONFIG_SENSORS_LIS3_I2C)	+= lis3lv02d.o lis3lv02d_i2c.o
+obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o
+obj-$(CONFIG_SENSORS_LIS3_SPI)	+= lis3lv02d_spi.o
+obj-$(CONFIG_SENSORS_LIS3_I2C)	+= lis3lv02d_i2c.o
 obj-$(CONFIG_SENSORS_LM63)	+= lm63.o
 obj-$(CONFIG_SENSORS_LM70)	+= lm70.o
 obj-$(CONFIG_SENSORS_LM73)	+= lm73.o
drivers/hwmon/lis3lv02d-core.c new file +610 -0

610 lines not on this page · raw message

drivers/hwmon/lis3lv02d.c deleted +0 -610

610 lines not on this page · raw message

Signature · 7 lines
1.6.0.4


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 6 lines · Samu Onkalo

If lis3 driver is compiled as module, it consists of two modules:
core and interface. However, both of them are mandatory for proper functionality. Furthermore, it is possible to keep /dev/freefall open and remove interface part of the driver. Kernel crashes when the /dev/freefall handle is closed.

Quoted 8 lines

Makefile is modifed so that now there is
only one module. Filename for core part is also changed from lis3lv02d to lis3lv02d-core.c.

New modules:
lis3lv02d (for hp-laptops)
lis3lv02d_i2c for I2C connected boards
lis3lv02d_spi for SPI connected boards.

This duplicates 11kB of binary code across 3 drivers. And you won't be able to load more than one of them due to common symbols. So, nack. There must be a better way to solve this problem.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Samu Onkalo
Quoted 19 lines

-----Original Message-----
From: ext Jean Delvare [mailto:[email protected]]
Sent: 15 April, 2010 15:25
To: Onkalo Samu.P (Nokia-D/Tampere)
Cc: [email protected]; [email protected]
Subject: Re: [lm-sensors] [RFC PATCH] lis3: Change lis3 driver to one module

Quoted 10 lines · Samu Onkalo

If lis3 driver is compiled as module, it consists of two modules:
core and interface. However, both of them are mandatory for proper functionality. Furthermore, it is possible to keep /dev/freefall open and remove interface part of the driver. Kernel crashes when the /dev/freefall handle is closed.

Makefile is modifed so that now there is
only one module. Filename for core part is also changed from lis3lv02d to lis3lv02d-core.c.

Quoted 8 lines
Quoted 4 lines

New modules:
lis3lv02d (for hp-laptops)
lis3lv02d_i2c for I2C connected boards
lis3lv02d_spi for SPI connected boards.

This duplicates 11kB of binary code across 3 drivers. And you won't be able to load more than one of them due to common symbols. So, nack. There must be a better way to solve this problem.

Well, there is only one statically reserved instance of lis3_dev which contains pointers to interface specific functions. It is possible to use only one interface at time, I think.

-Samu

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#3 lore raw
In reply to Samu Onkalo
Quoted 24 lines · On Fri, 16 Apr 2010 07:11:52 +0200, [email protected] wrote:
Quoted 24 lines

-----Original Message-----
From: ext Jean Delvare [mailto:[email protected]]
Sent: 15 April, 2010 15:25
To: Onkalo Samu.P (Nokia-D/Tampere)
Cc: [email protected]; [email protected]
Subject: Re: [lm-sensors] [RFC PATCH] lis3: Change lis3 driver to one module

Quoted 14 lines · Samu Onkalo

If lis3 driver is compiled as module, it consists of two modules:
core and interface. However, both of them are mandatory for proper functionality. Furthermore, it is possible to keep /dev/freefall open and remove interface part of the driver. Kernel crashes when the /dev/freefall handle is closed.

Makefile is modifed so that now there is
only one module. Filename for core part is also changed from lis3lv02d to lis3lv02d-core.c.

New modules:
lis3lv02d (for hp-laptops)
lis3lv02d_i2c for I2C connected boards
lis3lv02d_spi for SPI connected boards.

Quoted 7 lines
Quoted 3 lines

This duplicates 11kB of binary code across 3 drivers. And you won't be able to load more than one of them due to common symbols. So, nack. There must be a better way to solve this problem.

Well, there is only one statically reserved instance of lis3_dev which contains pointers to interface specific functions. It is possible to use only one interface at time, I think.

There are many exported functions, which will collide too. Maybe only one interface can be used at a time for a given chip, but you could have more than one chip on a given system, using different interfaces.

I didn't look at the code too closely, but I am under the impression that all these symbol exports become useless if lis3lv02d becomes a simple object instead of a separate kernel module. So you should at least remove the exports. This won't solve the problem of lis3_dev though, even if it's not exported, it is still a global.

Again, I don't think your solution makes any sense. If you have a reference counting issue, let's fix it by adding reference counting where it is needed, rather than duplicating binary code.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors