linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Timur Tabi <timur@freescale.com>
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: Wed, 25 Jul 2012 09:43:42 +1000	[thread overview]
Message-ID: <1343173422.2218.2.camel@concordia> (raw)
In-Reply-To: <500EB47F.1040903@freescale.com>

On Tue, 2012-07-24 at 09:43 -0500, Timur Tabi wrote:
> Singh Sandeep-B37400 wrote:
> 
> >> +int tdm_adap_send(struct tdm_adapter *adap, void **buf, int count) {
> >> +       int res;
> >> +
> >> +       if (adap->algo->tdm_write)
> >> +               res = adap->algo->tdm_write(adap, buf, count);
> > 
> > Why does tdm_write() return a u32?  And shouldn't 'res' also be a u32, to make tdm_write()?
> > [Sandeep] tdm_write() returns number of bytes written. You are right, 'res' should be declared as u32
> 
> Then it should return an unsigned int.  You should used a sized integer
> type only when the size really matters (e.g. hardware registers or packed
> fields in a structure).
> 
> >> +/* tdm_adapter_mode is to define in mode of the device */ enum 
> >> +tdm_adapter_mode {
> >> +       TDM_ADAPTER_MODE_NONE = 0x00,
> >> +       TDM_ADAPTER_MODE_T1 = 0x01,
> >> +       TDM_ADAPTER_MODE_E1 = 0x02,
> >> +       TDM_ADAPTER_MODE_T1_RAW = 0x10,
> >> +       TDM_ADAPTER_MODE_E1_RAW = 0x20,
> > 
> > Where did these numbers come from?
> > [Sandeep] This is not related to any bit definition, just enum values.
> 
> Yes, but why these particular numbers?  Also, do they really need to be an
> enum?  Since you're defining hard values for each enum, you're not really
> using them as an enum.  Make these into macros.

I agree these values are odd. But there's no rule that you can only use
an enum if the values are monotonically increasing.

It can still serve as helpful documentation, and reduce the number of
places you pass a bare int around.

cheers

  reply	other threads:[~2012-07-24 23:43 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 [this message]
2012-07-25  2:40         ` Tabi Timur-B04825
2012-07-25  5:18           ` Michael Ellerman
2012-07-26 21:28             ` Timur Tabi
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=1343173422.2218.2.camel@concordia \
    --to=michael@ellerman.id.au \
    --cc=B10812@freescale.com \
    --cc=B37400@freescale.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=timur@freescale.com \
    /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).