From: Timur Tabi <timur@freescale.com>
To: Michael Ellerman <michael@ellerman.id.au>
Cc: Aggrwal Poonam-B10812 <B10812@freescale.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Singh Sandeep-B37400 <B37400@freescale.com>
Subject: Re: [2/3][PATCH][upstream] TDM Framework
Date: Thu, 26 Jul 2012 16:28:19 -0500 [thread overview]
Message-ID: <5011B673.4030802@freescale.com> (raw)
In-Reply-To: <1343193511.2218.10.camel@concordia>
Michael Ellerman wrote:
> And the bible, K & R, includes an example of an enum which explicitly
> specifies all its values. It goes on to say "enumeration variables offer
> the chance of [type] checking and so are often better than #defines".
I don't want to beat a dead horse here, but if the driver doesn't do enum
type checking, then it's hard to justify using an enum. Now you said,
"Yes, if you're going to define an enum you should use it, which this
patch doesn't, but that's just a bug in this patch." It could be argued
that there's no real place to incorporate enum type checking in this code.
IMHO, this is pointless:
enum mytype {
VALUE1 = 0x10,
VALUE2 = 0x20
};
int func(void)
{
if (some-condition)
return VALUE1;
else
return VALUE2;
}
> And the bible, K & R, includes an example of an enum which explicitly
> specifies all its values.
First, K&R is pretty old, and there are a lot of style issues in it that
are no longer in favor. I don't think anyone would advocate this:
int func(x, y)
int x;
int y;
{
...
}
Secondly, one of the benefits of an enum (which again, is not actually
being used in this patch), is to be able to specify multiple constants
that are given unique values, but you don't actually care what the values
are, like this:
enum radeon_family {
CHIP_FAMILY_UNKNOW,
CHIP_FAMILY_LEGACY,
CHIP_FAMILY_RADEON,
CHIP_FAMILY_RV100,
CHIP_FAMILY_RS100, /* U1 (IGP320M) or A3 (IGP320)*/
CHIP_FAMILY_RV200,
...
};
The code will still work if I swap CHIP_FAMILY_RV100 with
CHIP_FAMILY_RS100. As long as each value is unique, everything works.
--
Timur Tabi
Linux kernel developer at Freescale
next prev parent reply other threads:[~2012-07-26 21:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-23 10:49 [2/3][PATCH][upstream] TDM Framework b37400
2012-07-23 10:49 ` [1/3][PATCH][upstream]Adding documentation for TDM b37400
2012-07-23 10:49 ` [3/3][PATCH][upstream]Added TDM device support and Freescale Starlite driver b37400
2012-07-23 12:32 ` [1/3][PATCH][upstream]Adding documentation for TDM David Laight
2012-07-24 15:12 ` Aggrwal Poonam-B10812
2012-07-25 8:44 ` David Laight
2012-07-25 12:08 ` Aggrwal Poonam-B10812
2012-07-23 16:33 ` [2/3][PATCH][upstream] TDM Framework Tabi Timur-B04825
2012-07-24 13:22 ` Singh Sandeep-B37400
2012-07-24 14:43 ` Timur Tabi
2012-07-24 23:43 ` Michael Ellerman
2012-07-25 2:40 ` Tabi Timur-B04825
2012-07-25 5:18 ` Michael Ellerman
2012-07-26 21:28 ` Timur Tabi [this message]
2012-07-26 22:09 ` Scott Wood
2012-07-26 10:49 ` Singh Sandeep-B37400
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=5011B673.4030802@freescale.com \
--to=timur@freescale.com \
--cc=B10812@freescale.com \
--cc=B37400@freescale.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=michael@ellerman.id.au \
/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).