All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/3] staging:iio: allow channels to be set up using a table of iio_channel_spec structures.
Date: Fri, 25 Mar 2011 16:26:36 +0100	[thread overview]
Message-ID: <201103251626.36765.arnd@arndb.de> (raw)
In-Reply-To: <4D8CB186.5030101@cam.ac.uk>

On Friday 25 March 2011, Jonathan Cameron wrote:
> > Better make it "unsigned long" instead of int when it's driver specific.
> > That way, a driver can store a pointer here if necessary.
> Makes sense. Perhaps a union to make the option explicit would be even
> better?

You can try it, but often unions cause more trouble than they are
worth. If most drivers just need an integer, using unsigned long
should be easier than a union.

> Whilst we are talking about types, some of the masks should probably switch to
> fixed length arrays of longs though so we don't have massive changes the
> moment we run out of space in the single longs.  All access will have to then
> be through the bitmap functions, but that should be fine.

Depends on whether you expect the masks to be exceeded any time soon.
I would expect 32 bits to be quite a lot, and it's easy to extend to
64 before you need to move to the bitops API.

> >> @@ -116,6 +248,31 @@ struct iio_dev {
> >>      u32                             *available_scan_masks;
> >>      struct iio_trigger              *trig;
> >>      struct iio_poll_func            *pollfunc;
> >> +
> >> +    struct iio_chan_spec *channels;
> >> +    int num_channels;
> >> +    struct list_head channel_attr_list;
> >> +
> >> +    char *name; /*device name - IMPLEMENT */
> >> +    int (*read_raw)(struct iio_dev *indio_dev, 
> >> +                    struct iio_chan_spec *chan,
> >> +                    int *val,
> >> +                    long mask);
> >> +
> >> +    int (*read_event_config)(struct iio_dev *indio_dev,
> >> +                             int event_code);
> >> +
> >> +    int (*write_event_config)(struct iio_dev *indio_dev,
> >> +                              int event_code,
> >> +                              struct iio_event_handler_list *listel,
> >> +                              int state);
> >> +
> >> +    int (*read_event_value)(struct iio_dev *indio_dev,
> >> +                            int event_code,
> >> +                            int *val);
> >> +    int (*write_event_value)(struct iio_dev *indio_dev,
> >> +                             int event_code,
> >> +                             int val);
> >>  };
> > 
> > As mentioned in the comment for 2/3, a number of the members here are
> > constant, so you could split the structure into a per-driver constant
> > part and a per-device part, like most other subsystems do.
>
> Good idea. Might have to be at a finer level than per driver though.
> I can certainly envision some drivers want for example to have a number
> of variants of read_raw to account for subtle difference in what channels
> are present on individual parts.

Right.

> However I think this refactoring should wait until after the other
> big changes are in. 

Ok.

	Arnd

  reply	other threads:[~2011-03-25 15:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 20:05 [RFC PATCH 0/3] Experimenting with channel specification structures Jonathan Cameron
2011-03-24 20:05 ` [PATCH 1/3] staging:iio: allow channels to be set up using a table of iio_channel_spec structures Jonathan Cameron
2011-03-25 14:37   ` Arnd Bergmann
2011-03-25 15:15     ` Jonathan Cameron
2011-03-25 15:26       ` Arnd Bergmann [this message]
2011-03-24 20:05 ` [PATCH 2/3] staging:iio:lis3l02dq - experimental move to new channel_spec approach Jonathan Cameron
2011-03-25 14:26   ` Arnd Bergmann
2011-03-25 15:38     ` Jonathan Cameron
2011-03-25 16:02       ` Arnd Bergmann
2011-03-24 20:05 ` [PATCH 3/3] staging:iio:max1363 - experimental move to channel_spec registration Jonathan Cameron
2011-03-25 15:03 ` [RFC PATCH 0/3] Experimenting with channel specification structures Arnd Bergmann
2011-03-25 15:19   ` Jonathan Cameron

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=201103251626.36765.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.