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:	Tue, 9 Oct 2012 14:30:35 +0200
From:	Jean Delvare <khali@...ux-fr.org>
To:	Julia Lawall <Julia.Lawall@...6.fr>
Cc:	Michael Krufky <mkrufky@...uxtv.org>,
	kernel-janitors@...r.kernel.org, rmallon@...il.com,
	shubhrajyoti@...com, Mauro Carvalho Chehab <mchehab@...radead.org>,
	linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/13] drivers/media/tuners/mxl5007t.c: use macros for
 i2c_msg initialization

Hi Julia,

On Sun,  7 Oct 2012 17:38:33 +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@...6.fr>
> 
> Introduce use of I2c_MSG_READ/WRITE/OP, for readability.

Next time you send this patch set, please Cc me on every post so that I
don't have to hunt for them on lkml.org.

> In each case, a length expressed as an explicit constant is also
> re-expressed as the size of the buffer, when this is possible.

This is conceptually wrong, please don't do that. It is perfectly valid
to use a buffer which is larger than the message being written or read.
When exchanging multiple messages, it is actually quite common to
declare only 2 buffers and reuse them:

	char reg;
	char val[2];

	struct i2c_msg msg[2] = {
		{ .addr = addr, .flags = 0, .buf = &reg, .len = 1 },
		{ .addr = addr, .flags = I2C_M_RD, .buf = val, .len = 1 },
	};

	reg = 0x04;
	i2c_transfer(i2c_adap, msg, 2);
	/* Do stuff with val */

	reg = 0x06;
	msg[1].len = 2;
	i2c_transfer(i2c_adap, msg, 2);
	/* Do stuff with val */

Your conversion would read 2 bytes from register 0x04 instead of 1 in
the example above.

I am not opposed to the idea of i2c_msg initialization helper macros,
but please don't mix that with actual code changes which could have bad
side effects.

Thanks,
-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ