linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Denis CIOCCA <denis.ciocca@st.com>
Cc: Denis Ciocca <denis.ciocca@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@jic23.retrosnub.co.uk>,
	Pavel Machek <pavel@denx.de>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"burman.yan@gmail.com" <burman.yan@gmail.com>
Subject: Re: STMicroelectronics accelerometers driver.
Date: Mon, 12 Nov 2012 18:48:37 +0000	[thread overview]
Message-ID: <50A14485.2060902@kernel.org> (raw)
In-Reply-To: <50A12D8C.6040207@st.com>

On 11/12/2012 05:10 PM, Denis CIOCCA wrote:
> Hi Jonathan,
> 
> can you please provide me one direction to modify the part in question 
> about the style of struct, in such a way I can do some modifications.
> 
Sorry, I haven't caught up with my emails for a few days!

Anyhow, quick reply below.
> Thanks,
> 
> Denis Ciocca
> 
> 
> 
> On 11/06/2012 12:11 PM, Denis Ciocca wrote:
>> Hi Jonathan,
>>
>> Thanks for your support!
>> I have applied your comments, only two point I would check better.
>>
>>
>>
>>>> +} st_accel_sensors[] = {
>>>> +     {
>>>> +             .wai = ST_ACCEL_1_WAI_EXP,
>>>> +             .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
>>>> +             .odr = {
>>>> +                     .addr = ST_ACCEL_1_ODR_ADDR,
>>>> +                     .mask = ST_ACCEL_1_ODR_MASK,
>>>> +                     .num_bit = ST_ACCEL_1_ODR_N_BIT,
>>>> +                     .odr_avl = {
>>>    While sometimes c99 assignment helps with clarity - sometimes it
>>> just bloats the code.
>>>    Personally I'd do these as
>>>    .odr_avl = {{ST_ACCEL_ODR_AVL_1HZ, ST_ACCEL_1_ODR_AVL_1HZ_VAL},
>>>                {...}
>>> etc
>>>
>>> or for that matter take the view that the defines are largely
>>> pointless as they
>>> are only used here and
>>> just do
>>>       .odr_avl = {{1, 0x01},
>>>                   {10, 0x02},
>>> etc.
>>> Or maybe if it fits on the line
>>>     .odr_avl = {{ .hz = 1, .value = 0x01 } might be the clearest...
>>> Not sure.
>>>
>>
>> In my first version I have used about this compact approach but
>> Lars-Peter tell to me to use this style code:
>>  >I'd use
>>  > .odr_avl = {
>>  >        [0] = {
>>  >                ...
>>  >        },
>>  >        [1] = {
>>  >                ...
>>  >
>>  >Makes things a bit more readable in my opinion.
>>
>> Ok for me it is not a problem but you must tell me one definitive style
>> please. I think this style is more cleanly, though are necessary more rows.

The indexing gives no benefit - it's not relevant to the use of this
array as far as I can tell. Now we had index value pairs, then it would make
sense, but we don't.

My personal view is go for whatever gives the best combination of readability to
code compactness.  So here, where what we have is effectively key value pairs,
I'd just have them as an array.  Elsewhere, when you have general elements of
a structure then c99 style assignment is clearest and allows the structure
to sometimes be extended without needing to be careful about the ordering etc.

To a certain extent I don't care, I just thought for key value pairs there
was an awful lot of code here and it actually damaged readability rather
than enhancing it.

Hence have a think about it and go with whatever you think is clearest.

>
>
>>
>>
>>>> +/**
>>>> + * struct st_accel_platform_data - ST accel device platform data
>>>> + * @fullscale: Value of fullscale used for the sensor.
>>>> + * @sampling_frequency: Value of sampling frequency used for the
>>>> sensor.
>>>> + */
>>>> +
>>>> +struct st_accel_platform_data {
>>>> +     int fullscale;
>>>> +     int sampling_frequency;
>>>> +};
>>>
>>> What is the purpose of having these as platform data?
>>>
>>
>> For now the purpose is to set only the initial values for fullscale and
>> sampling_frequency but I think it's good thing include the mapping of
>> axis. You think it's necessary to remove this for now?
I'd not bother with it.  Just put a sensible default in the driver and
if anything else is wanted leave it up to userspace once the driver
is loaded.

Axis alignment is an interesting one.  So far we have it for just one
driver and that was to maintain feature parity with an existing driver
when we pulled it into the kernel.

It is often rather arbitary. The case where it matters is usually for
human input in which case it can be handled in the mapping code
(if using iio and the input bridge driver).

  reply	other threads:[~2012-11-12 18:48 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-08 15:39 STMicroelectronics accelerometers driver Denis CIOCCA
2012-10-08 19:14 ` Lars-Peter Clausen
2012-10-08 19:50   ` Pavel Machek
2012-10-08 20:33     ` Lars-Peter Clausen
2012-10-08 20:37       ` Jonathan Cameron
2012-10-14 15:05         ` Denis Ciocca
2012-10-14 19:08           ` Lars-Peter Clausen
2012-10-16 17:51           ` Lars-Peter Clausen
2012-10-22  9:31             ` Denis CIOCCA
2012-10-22 18:07               ` Jonathan Cameron
2012-10-22 19:37                 ` Denis Ciocca
2012-10-24 12:44                 ` Denis CIOCCA
2012-10-26 12:10                   ` Lars-Peter Clausen
2012-10-29  8:55                     ` Denis CIOCCA
2012-10-29  9:13                       ` Lars-Peter Clausen
2012-10-29 10:24                         ` Denis CIOCCA
2012-10-29 10:30                           ` Lars-Peter Clausen
2012-10-29 10:38                             ` Denis CIOCCA
2012-10-31 14:27                             ` Denis CIOCCA
2012-10-31 16:40                               ` Lars-Peter Clausen
2012-10-31 20:33                                 ` Jonathan Cameron
2012-11-04 10:09                                 ` Denis Ciocca
2012-11-05 21:28                                   ` Jonathan Cameron
2012-11-06 11:11                                     ` Denis CIOCCA
2012-11-12 17:10                                       ` Denis CIOCCA
2012-11-12 18:48                                         ` Jonathan Cameron [this message]
2012-11-13 15:38                                           ` Denis CIOCCA
2012-11-18 13:20                                             ` Jonathan Cameron
2012-11-23 16:10                                               ` Denis CIOCCA
2012-11-24 16:23                                                 ` Jonathan Cameron
2012-11-26 16:57                                                   ` Denis CIOCCA
2012-11-27 11:52                                                   ` Denis CIOCCA
2012-11-29  9:46                                                     ` Lars-Peter Clausen
2012-11-27 15:36                                                   ` STMicroelectronics gyroscopes driver Denis CIOCCA
2012-11-29  9:51                                                     ` Lars-Peter Clausen
2012-11-30  9:13                                                       ` Denis CIOCCA
2012-11-30 10:36                                                         ` Lars-Peter Clausen
2012-11-30 13:06                                                           ` Jonathan Cameron
2012-12-03 16:40                                                             ` STMicroelectronics driver Denis CIOCCA
2012-12-03 19:01                                                               ` Lars-Peter Clausen
2012-11-19 13:00                                             ` STMicroelectronics accelerometers driver Lars-Peter Clausen
2012-11-06 11:14                                     ` Denis CIOCCA

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=50A14485.2060902@kernel.org \
    --to=jic23@kernel.org \
    --cc=burman.yan@gmail.com \
    --cc=denis.ciocca@gmail.com \
    --cc=denis.ciocca@st.com \
    --cc=jic23@jic23.retrosnub.co.uk \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pavel@denx.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).