mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: "Jon Arne Jørgensen" <jonarne@jonarne.no>
Cc: linux-media@vger.kernel.org, jonjon.arnearne@gmail.com,
	linux-kernel@vger.kernel.org, hverkuil@xs4all.nl,
	elezegarcia@gmail.com, mkrufky@linuxtv.org, bjorn@mork.no
Subject: Re: [RFC V2 1/3] [smi2021] Add gm7113c chip to the saa7115 driver
Date: Thu, 25 Apr 2013 17:39:48 -0300	[thread overview]
Message-ID: <20130425173948.10ff0a2a@redhat.com> (raw)
In-Reply-To: <20130425203319.GA18656@dell.arpanet.local>

Em Thu, 25 Apr 2013 22:33:20 +0200
Jon Arne Jørgensen <jonarne@jonarne.no> escreveu:

> On Thu, Apr 25, 2013 at 05:13:28PM -0300, Mauro Carvalho Chehab wrote:
> > Em Thu, 25 Apr 2013 21:10:18 +0200
> > Jon Arne Jørgensen <jonarne@jonarne.no> escreveu:
> > 
> > >  	/* Check whether this chip is part of the saa711x series */
> > > -	if (memcmp(name + 1, "f711", 4)) {
> > > +	if (memcmp(id->name + 1, "gm7113c", 7)) {
> > > +		chip_id = 'c';
> > 
> > There are several issues on the above:
> > 1) "id" may be NULL on autodetect mode;
> > 
> > 2) Why are you adding 1 here?
> >    It should be, instead id->name
> > 
> > 3) memcmp returns 0 if matches. So, the test is wrong.
> >    So, It should be instead:
> > 	if (!memcmp(id->name, "gm7113c", 7)) {
> > 
> > 4) Also, while that works, it seems a little hackish...
> > 
> 
> Oh, this is embarrassing.
> I just tried to change as little as possible in this module to make the
> device work.

No problems. On my experience, quick hacks like that are the
ones that generally have more troubles ;)

> > Something like:
> > 
> > static int saa711x_detect_chip(struct i2c_client *client,
> > 			       struct saa711x_state *state,
> > 			       const struct i2c_device_id *id)
> > {
> > 	int i;
> > 	char chip_id, name[16];
> > 
> > 	/*
> > 	 * Check for gm7113c (a saa7113 clone). Currently, there's no
> > 	 * known way to autodetect it, so boards that use will need to
> > 	 * explicitly fill the id->name field.
> > 	 */
> > 	if (id && !memcmp(id->name, "gm7113c", 7)) {
> > 		state->ident = V4L2_IDENT_GM7113C;
> > 		snprintf(client->name, sizeof(client->name), "%s", id->name);
> > 		return 0;
> > 	}
> > 
> > 	/* Check for Philips/NXP original chips */
> > 	for (i = 0; i < sizeof(name); i++) {
> > 		i2c_smbus_write_byte_data(client, 0, i);
> > 		name[i] = (i2c_smbus_read_byte_data(client, 0) & 0x0f) + '0';
> > 		if (name[i] > '9')
> > 			name[i] += 'a' - '9' - 1;
> > 	}
> > 	name[i] = '\0';
> > 
> > 	if (memcmp(name + 1, "f711", 4))
> > 		return -ENODEV;
> > 
> > 	chip_id = name[5];
> > 
> > 	snprintf(client->name, sizeof(client->name), "saa711%c", chip_id);
> > 
> > 	/*
> > 	 * Put here the code that fills state->ident for Philips/NXP chips
> > 	 */
> > ...
> > 
> > 	return 0;
> 
> Yes this seems to be a much better way to do it.
> I will fix my code.

Thanks!
Mauro

  reply	other threads:[~2013-04-25 20:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-25 19:10 [RFC V2 0/3] Add a driver for Somagic smi2021 Jon Arne Jørgensen
2013-04-25 19:10 ` [RFC V2 1/3] [smi2021] Add gm7113c chip to the saa7115 driver Jon Arne Jørgensen
2013-04-25 20:13   ` Mauro Carvalho Chehab
2013-04-25 20:33     ` Jon Arne Jørgensen
2013-04-25 20:39       ` Mauro Carvalho Chehab [this message]
2013-04-25 20:36     ` Mauro Carvalho Chehab
2013-04-25 21:05       ` Jon Arne Jørgensen
2013-06-13 12:20         ` rafael.coutinho
2013-04-25 19:10 ` [RFC V2 2/3] [smi2021] This is the smi2021 driver Jon Arne Jørgensen
2013-04-25 19:10 ` [RFC V2 3/3] [smi2021] Add smi2021 driver to buildsystem Jon Arne Jørgensen

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=20130425173948.10ff0a2a@redhat.com \
    --to=mchehab@redhat.com \
    --cc=bjorn@mork.no \
    --cc=elezegarcia@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonarne@jonarne.no \
    --cc=jonjon.arnearne@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mkrufky@linuxtv.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

all inboxes | Powered by JetHome®