From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>,
Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] em28xx: fix compiler warnings
Date: Tue, 05 Aug 2014 17:18:06 +0200 [thread overview]
Message-ID: <53E0F5AE.2050903@googlemail.com> (raw)
In-Reply-To: <53E080F6.30301@xs4all.nl>
Hi Hans,
Am 05.08.2014 um 09:00 schrieb Hans Verkuil:
> Fix three compiler warnings:
>
> drivers/media/usb/em28xx/em28xx-input.c: In function ‘em28xx_i2c_ir_handle_key’:
> drivers/media/usb/em28xx/em28xx-input.c:318:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> }
> ^
> CC [M] drivers/media/usb/em28xx/em28xx-dvb.o
> drivers/media/usb/em28xx/em28xx-camera.c: In function ‘em28xx_probe_sensor_micron’:
> drivers/media/usb/em28xx/em28xx-camera.c:199:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> }
> ^
> drivers/media/usb/em28xx/em28xx-camera.c: In function ‘em28xx_probe_sensor_omnivision’:
> drivers/media/usb/em28xx/em28xx-camera.c:304:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> }
> ^
Hmmm... I don't get these weird warnings.
How can I reproduce them ?
> Note: there is no way the code in em28xx_i2c_ir_handle_key() is correct: it's
> using an almost completely uninitialized i2c_client struct with random flags,
> dev and name fields. Can't this turned into a proper i2c_client struct in
> struct em28xx? At least with this patch it's no longer random data.
Why do you think the client setup is random ?
Which fields do you think are wrong ? AFAICS this patch doesn't change
any fields.
What's wrong with using local i2c_client variables ?
Indeed, the way the driver currently tracks i2c clients / subdevices is
... let's say "improvable".
But IMHO, we should go the opposite direction and get rid of the
i2c_clients in the main device struct.
They are in fact just temporary helpers and dangerous to use with
devices with multiple i2c clients on the same bus.
Regards,
Frank
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c
> index 6d2ea9a..c8490ba 100644
> --- a/drivers/media/usb/em28xx/em28xx-camera.c
> +++ b/drivers/media/usb/em28xx/em28xx-camera.c
> @@ -110,40 +110,40 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
> __be16 id_be;
> u16 id;
>
> - struct i2c_client client = dev->i2c_client[dev->def_i2c_bus];
> + dev->tmp_i2c_client = dev->i2c_client[dev->def_i2c_bus];
>
> dev->em28xx_sensor = EM28XX_NOSENSOR;
> for (i = 0; micron_sensor_addrs[i] != I2C_CLIENT_END; i++) {
> - client.addr = micron_sensor_addrs[i];
> + dev->tmp_i2c_client.addr = micron_sensor_addrs[i];
> /* NOTE: i2c_smbus_read_word_data() doesn't work with BE data */
> /* Read chip ID from register 0x00 */
> reg = 0x00;
> - ret = i2c_master_send(&client, ®, 1);
> + ret = i2c_master_send(&dev->tmp_i2c_client, ®, 1);
> if (ret < 0) {
> if (ret != -ENXIO)
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> - ret = i2c_master_recv(&client, (u8 *)&id_be, 2);
> + ret = i2c_master_recv(&dev->tmp_i2c_client, (u8 *)&id_be, 2);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> id = be16_to_cpu(id_be);
> /* Read chip ID from register 0xff */
> reg = 0xff;
> - ret = i2c_master_send(&client, ®, 1);
> + ret = i2c_master_send(&dev->tmp_i2c_client, ®, 1);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> - ret = i2c_master_recv(&client, (u8 *)&id_be, 2);
> + ret = i2c_master_recv(&dev->tmp_i2c_client, (u8 *)&id_be, 2);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> /* Validate chip ID to be sure we have a Micron device */
> @@ -191,7 +191,7 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev)
> else
> em28xx_info("sensor %s detected\n", name);
>
> - dev->i2c_client[dev->def_i2c_bus].addr = client.addr;
> + dev->i2c_client[dev->def_i2c_bus].addr = dev->tmp_i2c_client.addr;
> return 0;
> }
>
> @@ -207,28 +207,29 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
> char *name;
> u8 reg;
> u16 id;
> - struct i2c_client client = dev->i2c_client[dev->def_i2c_bus];
> +
> + dev->tmp_i2c_client = dev->i2c_client[dev->def_i2c_bus];
>
> dev->em28xx_sensor = EM28XX_NOSENSOR;
> /* NOTE: these devices have the register auto incrementation disabled
> * by default, so we have to use single byte reads ! */
> for (i = 0; omnivision_sensor_addrs[i] != I2C_CLIENT_END; i++) {
> - client.addr = omnivision_sensor_addrs[i];
> + dev->tmp_i2c_client.addr = omnivision_sensor_addrs[i];
> /* Read manufacturer ID from registers 0x1c-0x1d (BE) */
> reg = 0x1c;
> - ret = i2c_smbus_read_byte_data(&client, reg);
> + ret = i2c_smbus_read_byte_data(&dev->tmp_i2c_client, reg);
> if (ret < 0) {
> if (ret != -ENXIO)
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> id = ret << 8;
> reg = 0x1d;
> - ret = i2c_smbus_read_byte_data(&client, reg);
> + ret = i2c_smbus_read_byte_data(&dev->tmp_i2c_client, reg);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> id += ret;
> @@ -237,18 +238,18 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
> continue;
> /* Read product ID from registers 0x0a-0x0b (BE) */
> reg = 0x0a;
> - ret = i2c_smbus_read_byte_data(&client, reg);
> + ret = i2c_smbus_read_byte_data(&dev->tmp_i2c_client, reg);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> id = ret << 8;
> reg = 0x0b;
> - ret = i2c_smbus_read_byte_data(&client, reg);
> + ret = i2c_smbus_read_byte_data(&dev->tmp_i2c_client, reg);
> if (ret < 0) {
> em28xx_errdev("couldn't read from i2c device 0x%02x: error %i\n",
> - client.addr << 1, ret);
> + dev->tmp_i2c_client.addr << 1, ret);
> continue;
> }
> id += ret;
> @@ -296,7 +297,7 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev)
> else
> em28xx_info("sensor %s detected\n", name);
>
> - dev->i2c_client[dev->def_i2c_bus].addr = client.addr;
> + dev->i2c_client[dev->def_i2c_bus].addr = dev->tmp_i2c_client.addr;
> return 0;
> }
>
> diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
> index ed843bd..07069b6 100644
> --- a/drivers/media/usb/em28xx/em28xx-input.c
> +++ b/drivers/media/usb/em28xx/em28xx-input.c
> @@ -298,12 +298,11 @@ static int em28xx_i2c_ir_handle_key(struct em28xx_IR *ir)
> static u32 scancode;
> enum rc_type protocol;
> int rc;
> - struct i2c_client client;
>
> - client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus];
> - client.addr = ir->i2c_dev_addr;
> + dev->tmp_i2c_client.adapter = &ir->dev->i2c_adap[dev->def_i2c_bus];
> + dev->tmp_i2c_client.addr = ir->i2c_dev_addr;
>
> - rc = ir->get_key_i2c(&client, &protocol, &scancode);
> + rc = ir->get_key_i2c(&dev->tmp_i2c_client, &protocol, &scancode);
> if (rc < 0) {
> dprintk("ir->get_key_i2c() failed: %d\n", rc);
> return rc;
> diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
> index 84ef8ef..437ca08 100644
> --- a/drivers/media/usb/em28xx/em28xx.h
> +++ b/drivers/media/usb/em28xx/em28xx.h
> @@ -630,6 +630,7 @@ struct em28xx {
> struct i2c_adapter i2c_adap[NUM_I2C_BUSES];
> struct i2c_client i2c_client[NUM_I2C_BUSES];
> struct em28xx_i2c_bus i2c_bus[NUM_I2C_BUSES];
> + struct i2c_client tmp_i2c_client;
>
> unsigned char eeprom_addrwidth_16bit:1;
> unsigned def_i2c_bus; /* Default I2C bus */
next prev parent reply other threads:[~2014-08-05 15:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-05 7:00 [PATCH] em28xx: fix compiler warnings Hans Verkuil
2014-08-05 13:57 ` Shuah Khan
2014-08-05 14:18 ` Hans Verkuil
2014-08-05 14:50 ` Shuah Khan
2014-08-05 15:18 ` Frank Schäfer [this message]
2014-08-07 6:45 ` Hans Verkuil
2014-08-07 16:36 ` Frank Schäfer
2014-08-09 9:58 ` Hans Verkuil
2014-08-15 17:37 ` Frank Schäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53E0F5AE.2050903@googlemail.com \
--to=fschaefer.oss@googlemail.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).