All of lore.kernel.org
 help / color / mirror / Atom feed
* [IIO] Help understanding iio_priv(..)
@ 2017-03-13 20:15 Aishwarya Pant
  2017-03-14 12:43 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Aishwarya Pant @ 2017-03-13 20:15 UTC (permalink / raw)
  To: outreachy-kernel

Hi

I have been looking at the IIO task and came across this function
iio_priv(..). It is defined as-


static inline void *iio_priv(const struct iio_dev *indio_dev)
{
        return (char *)indio_dev + ALIGN(sizeof(struct iio_dev),
	IIO_ALIGN);
}

It returns a void pointer and used as struct dev_state = iio_priv(indio_dev).
Looks like it is used to store an iio device state private to the file.

Could someone help me understand what exactly is happening inside here?

Thanks
Aishwarya





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [IIO] Help understanding iio_priv(..)
  2017-03-14 12:43 ` [Outreachy kernel] " Julia Lawall
@ 2017-03-13 22:09   ` Aishwarya Pant
  0 siblings, 0 replies; 3+ messages in thread
From: Aishwarya Pant @ 2017-03-13 22:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

On Tue, Mar 14, 2017 at 01:43:08PM +0100, Julia Lawall wrote:
> 
> 
> On Tue, 14 Mar 2017, Aishwarya Pant wrote:
> 
> > Hi
> >
> > I have been looking at the IIO task and came across this function
> > iio_priv(..). It is defined as-
> >
> >
> > static inline void *iio_priv(const struct iio_dev *indio_dev)
> > {
> >         return (char *)indio_dev + ALIGN(sizeof(struct iio_dev),
> > 	IIO_ALIGN);
> > }
> >
> > It returns a void pointer and used as struct dev_state = iio_priv(indio_dev).
> > Looks like it is used to store an iio device state private to the file.
> >
> > Could someone help me understand what exactly is happening inside here?
> 
> Probably it would help to look at how the priv pointer is initialized.

Looking at how iio_dev is defined helped :)

struct iio_dev indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip))

> 
> julia
> 
> >
> > Thanks
> > Aishwarya
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170313201511.GA12957%40aishwarya.
> > For more options, visit https://groups.google.com/d/optout.
> >


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Outreachy kernel] [IIO] Help understanding iio_priv(..)
  2017-03-13 20:15 [IIO] Help understanding iio_priv(..) Aishwarya Pant
@ 2017-03-14 12:43 ` Julia Lawall
  2017-03-13 22:09   ` Aishwarya Pant
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2017-03-14 12:43 UTC (permalink / raw)
  To: Aishwarya Pant; +Cc: outreachy-kernel



On Tue, 14 Mar 2017, Aishwarya Pant wrote:

> Hi
>
> I have been looking at the IIO task and came across this function
> iio_priv(..). It is defined as-
>
>
> static inline void *iio_priv(const struct iio_dev *indio_dev)
> {
>         return (char *)indio_dev + ALIGN(sizeof(struct iio_dev),
> 	IIO_ALIGN);
> }
>
> It returns a void pointer and used as struct dev_state = iio_priv(indio_dev).
> Looks like it is used to store an iio device state private to the file.
>
> Could someone help me understand what exactly is happening inside here?

Probably it would help to look at how the priv pointer is initialized.

julia

>
> Thanks
> Aishwarya
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170313201511.GA12957%40aishwarya.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-14 14:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 20:15 [IIO] Help understanding iio_priv(..) Aishwarya Pant
2017-03-14 12:43 ` [Outreachy kernel] " Julia Lawall
2017-03-13 22:09   ` Aishwarya Pant

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.