linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: linux-media@vger.kernel.org
Cc: Oliver Endriss <o.endriss@gmx.de>, Ralph Metzler <rjkm@metzlerbros.de>
Subject: Re: [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge)
Date: Sun, 03 Jul 2011 21:17:52 -0300	[thread overview]
Message-ID: <4E1106B0.7030102@redhat.com> (raw)
In-Reply-To: <201107040124.04924@orion.escape-edv.de>

Em 03-07-2011 20:24, Oliver Endriss escreveu:
> Hi Mauro,
> 
> On Monday 04 July 2011 00:27:54 Mauro Carvalho Chehab wrote:
>> Hi Oliver,
>>
>> Em 03-07-2011 18:21, Oliver Endriss escreveu:
>>> [PATCH 1/5] ddbridge: Initial check-in
>>> [PATCH 2/5] ddbridge: Codingstyle fixes
>>> [PATCH 3/5] ddbridge: Allow compiling of the driver
>>> [PATCH 4/5] cxd2099: Fix compilation of ngene/ddbridge for DVB_CXD2099=n
>>> [PATCH 5/5] cxd2099: Update Kconfig descrition (ddbridge support)
>>>
>>> Note:
>>> This patch series depends on the previous one:
>>> [PATCH 00/16] New drivers: DRX-K, TDA18271c2, Updates: CXD2099 and ngene
>>
>> I've applied both series today on an experimental tree that I use when merging
>> some complex drivers. They are at:
>> 	http://git.linuxtv.org/mchehab/experimental.git?a=shortlog;h=refs/heads/ngene
>>
>> I didn't actually reviewed the patch series yet, but I noticed some troubles
>> related to Coding Style, and 2 compilation breakages, when all drivers are selected,
>> due to some duplicated symbols. So, I've applied some patches fixing the issues
>> I noticed. It would be great if you could test if the changes didn't break anything.
> 
> Apparently these duplicated symbols did not show up here,
> because I compiled the drivers as modules. :-(

Likely. When merging things, I compile here with allyesconfig, in order to catch duplicated
symbols.

>> There's a problem that I've noticed already at the patch series: the usage of
>> CHK_ERROR macro hided a trouble on some places, especially at drxd_hard.c.
>>
>> As you know, the macro was defined as:
>> 	#define CHK_ERROR(s) if ((status = s)) break
>>
>> I've replaced it, on all places, using a small perl script, as the above is a CodingStyle
>> violation, and may hide some troubles[1].
> 
> True.
> 
>> [1] http://git.linuxtv.org/mchehab/experimental.git?a=commit;h=792ecdd1cc494a1e10ed494052ed697ab4e1aa8a
>>
>> After the removal, I've noticed that this works fine on several places
>> where the code have things like:
>> 	do {
>> 		status = foo()
>> 		if (status < 0)
>> 			break;
>>
>> 	} while (0);
>>
>> There are places, however, that there are two loops, like, for example, at:
>>
>> static int DRX_Start(struct drxd_state *state, s32 off)
>> {
>> ...
>> 	do {
>> ...
>> 		switch (p->transmission_mode) {
>> 		case TRANSMISSION_MODE_8K:
>> 			transmissionParams |= SC_RA_RAM_OP_PARAM_MODE_8K;
>> 			if (state->type_A) {
>> 				status = Write16(state, EC_SB_REG_TR_MODE__A, EC_SB_REG_TR_MODE_8K, 0x0000);
>> 				if (status < 0)
>> 					break;
>> 			}
>> 			break;
>> ...
>> 		}
>>
>> ...
>> 	} while (0);
>>
>> 	return status;
>>
>> On those cases, instead of returning the error status, the function
>> will just ignore the error and proceed to the next switch(). In this specific 
>> routine, as there are no locks inside the code, the better fix would be to 
>> just replace:
>> 	if (status < 0)
>> 		break;
>> by
>> 	if (status < 0)
>> 		return (status);
>>
>> But I suspect that the same trouble is also present on other parts of the code.
>>
>> Another issue that I've noticed alread is that, on some places, instead of doing 
>> "return -EINVAL" (or some other proper error code), the code is just doing: "return -1".
>>
>> Could you please take a look on those issues?
> 
> That CHK_ERROR stuff appears very dangerous to me.
> Btw, this is why I did not remove the curly braces { } in some cases:
>         if (...) {
>                 CHK_ERROR(...)
>         }
> It would have caused really nasty effects.

True. 

> Anyway, I spent the whole weekend to re-format the code carefully
> and create both patch series, trying not to break anything.
> I simply cannot go through the driver code and verify everything.

As the changes on CHK_ERROR were done via script, it is unlikely that it
introduced any problems (well, except if some function is returning
a positive value as an error code, but I think that this is not the
case).

I did the same replacement when I've cleanup the drx-d driver (well, the 
script were not the same, but it used a similar approach), and the changes 
didn't break anything, but it is safer to have a test, to be sure that no
functional changes were introduced.

A simple test with the code and some working board is probably enough
to verify that nothing broke.

The bad error check logic, checking for "break" inside two loops instead just
one will require a careful code inspection, though.

> Please note that I am not the driver author!
> I think Ralph should comment on this.

Ralph,

Could you please take a look on it?

Thanks!
Mauro

  reply	other threads:[~2011-07-04  0:18 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-03 21:21 [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge) Oliver Endriss
2011-07-03 21:23 ` PATCH 1/5] ddbridge: Initial check-in Oliver Endriss
2011-07-03 21:24 ` [PATCH 2/5] ddbridge: Codingstyle fixes Oliver Endriss
2011-07-03 21:25 ` [PATCH 3/5] ddbridge: Allow compiling of the driver Oliver Endriss
2011-07-03 21:26 ` [PATCH 4/5] cxd2099: Fix compilation of ngene/ddbridge for DVB_CXD2099=n Oliver Endriss
2011-07-04 10:14   ` Bjørn Mork
2011-07-03 21:27 ` [PATCH 5/5] cxd2099: Update Kconfig description (ddbridge support) Oliver Endriss
2011-07-04  0:06   ` Walter Van Eetvelt
2011-07-03 22:27 ` [PATCH 0/5] Driver support for cards based on Digital Devices bridge (ddbridge) Mauro Carvalho Chehab
2011-07-03 23:24   ` Oliver Endriss
2011-07-04  0:17     ` Mauro Carvalho Chehab [this message]
2011-07-14 23:45       ` Oliver Endriss
2011-07-15  0:47         ` Mauro Carvalho Chehab
2011-07-15  2:11           ` Oliver Endriss
2011-07-15  4:01             ` Mauro Carvalho Chehab
2011-07-15  3:56           ` Mauro Carvalho Chehab
2011-07-15  5:17             ` Oliver Endriss
2011-07-15  8:26               ` Ralph Metzler
2011-07-15 13:25                 ` Mauro Carvalho Chehab
2011-07-15 17:01                   ` Andreas Oberritter
2011-07-15 17:34                     ` Mauro Carvalho Chehab
2011-07-15 23:41                     ` Antti Palosaari
2011-07-16 12:25                       ` Mauro Carvalho Chehab
2011-07-16 14:16                         ` Antti Palosaari
2011-07-16 14:54                           ` Mauro Carvalho Chehab
2011-07-16 15:40                             ` Andreas Oberritter
2011-07-16 15:44                               ` Antti Palosaari
2011-07-16 15:53                                 ` Andreas Oberritter
2011-07-16 15:59                                   ` Antti Palosaari
2011-07-16 16:37                                   ` Rémi Denis-Courmont
2011-07-17  2:51                                     ` Andreas Oberritter
2011-07-17  7:51                                       ` Rémi Denis-Courmont
2011-07-17  0:56                                   ` Mauro Carvalho Chehab
2011-07-17  3:02                                     ` Andreas Oberritter
2011-07-17  3:59                                       ` Mauro Carvalho Chehab
2011-07-17  7:39                                     ` Rémi Denis-Courmont
2011-07-17  8:01                                       ` Mauro Carvalho Chehab
2011-07-17  1:07                                 ` Mauro Carvalho Chehab
2011-07-16 15:40                             ` Oliver Endriss
2011-11-03  7:49                               ` Steffen Barszus
2011-11-03 17:24                                 ` Lars Hanisch
2011-07-15  4:18         ` Mauro Carvalho Chehab
2011-07-15  5:21           ` Oliver Endriss
2011-07-15 12:40             ` Mauro Carvalho Chehab
2011-07-17 11:44               ` Oliver Endriss

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=4E1106B0.7030102@redhat.com \
    --to=mchehab@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=o.endriss@gmx.de \
    --cc=rjkm@metzlerbros.de \
    /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).