Google
  Web www.spinics.net

[PATCH] zoran: i2c structure templates clean-up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Clean up the use of structure templates in zoran_card. For one thing,
a real template is supposed to be read-only. And in some cases it's
more efficient to initialize the few fields we need individually.

Signed-off-by: Jean Delvare <khali@xxxxxxxxxxxx>
---
This is basically the same changes that were applied to the cx88-i2c
driver several months ago. Note that this patch is untested, although I
am confident it is correct. Any volunteer to test it and report?

Patch already sent on:
 * 2007-12-13

 drivers/media/video/zoran_card.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

--- linux-2.6.24-rc5.orig/drivers/media/video/zoran_card.c	2007-10-24 09:59:29.000000000 +0200
+++ linux-2.6.24-rc5/drivers/media/video/zoran_card.c	2007-12-13 10:59:05.000000000 +0100
@@ -59,8 +59,6 @@
 #include "zoran_device.h"
 #include "zoran_procfs.h"
 
-#define I2C_NAME(x) (x)->name
-
 extern const struct zoran_format zoran_formats[];
 
 static int card[BUZ_MAX] = { -1, -1, -1, -1 };
@@ -809,7 +807,7 @@ clientunreg_unlock_and_return:
 	return res;
 }
 
-static struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
+static const struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
 	.setsda = zoran_i2c_setsda,
 	.setscl = zoran_i2c_setscl,
 	.getsda = zoran_i2c_getsda,
@@ -818,24 +816,17 @@ static struct i2c_algo_bit_data zoran_i2
 	.timeout = 100,
 };
 
-static struct i2c_adapter zoran_i2c_adapter_template = {
-	.name = "zr36057",
-	.id = I2C_HW_B_ZR36067,
-	.algo = NULL,
-	.client_register = zoran_i2c_client_register,
-	.client_unregister = zoran_i2c_client_unregister,
-};
-
 static int
 zoran_register_i2c (struct zoran *zr)
 {
 	memcpy(&zr->i2c_algo, &zoran_i2c_bit_data_template,
 	       sizeof(struct i2c_algo_bit_data));
 	zr->i2c_algo.data = zr;
-	memcpy(&zr->i2c_adapter, &zoran_i2c_adapter_template,
-	       sizeof(struct i2c_adapter));
-	strncpy(I2C_NAME(&zr->i2c_adapter), ZR_DEVNAME(zr),
-		sizeof(I2C_NAME(&zr->i2c_adapter)) - 1);
+	zr->i2c_adapter.id = I2C_HW_B_ZR36067;
+	zr->i2c_adapter.client_register = zoran_i2c_client_register;
+	zr->i2c_adapter.client_unregister = zoran_i2c_client_unregister;
+	strlcpy(zr->i2c_adapter.name, ZR_DEVNAME(zr),
+		sizeof(zr->i2c_adapter.name));
 	i2c_set_adapdata(&zr->i2c_adapter, zr);
 	zr->i2c_adapter.algo_data = &zr->i2c_algo;
 	zr->i2c_adapter.dev.parent = &zr->pci_dev->dev;


-- 
Jean Delvare

_______________________________________________
v4l-dvb-maintainer mailing list
v4l-dvb-maintainer@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/v4l-dvb-maintainer

[Linux Media]     [Older V4L]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [SSH]     [Linux USB]

-->
Add to Google Powered by Linux

Google PageRank Checking tool