Message ID | 20200514131710.84201-4-alexandru.ardelean@analog.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iio: core: wrap IIO device into an iio_dev_opaque object | expand |
On Thu, 14 May 2020 16:17:05 +0300 Alexandru Ardelean <alexandru.ardelean@analog.com> wrote: > Since there will be some changes to how iio_priv_to_dev() is implemented, > it could be that the helper becomes a bit slower, as it will be hidden away > in the IIO core. > > For this driver, the IIO device can be passed directly as a parameter to > the at91_ts_sample() function, thus making it immune to the change of > iio_priv_to_dev(). > The function gets called in an interrupt context. > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> I wonder. Should we just pass the struct device? It's only used for error printing I think, so we could make that explicit. I'm not that bothered either way though. Jonathan > --- > drivers/iio/adc/at91_adc.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > index 0368b6dc6d60..5999defe47cd 100644 > --- a/drivers/iio/adc/at91_adc.c > +++ b/drivers/iio/adc/at91_adc.c > @@ -287,13 +287,12 @@ static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev) > } > } > > -static int at91_ts_sample(struct at91_adc_state *st) > +static int at91_ts_sample(struct iio_dev *idev, struct at91_adc_state *st) > { > unsigned int xscale, yscale, reg, z1, z2; > unsigned int x, y, pres, xpos, ypos; > unsigned int rxp = 1; > unsigned int factor = 1000; > - struct iio_dev *idev = iio_priv_to_dev(st); > > unsigned int xyz_mask_bits = st->res; > unsigned int xyz_mask = (1 << xyz_mask_bits) - 1; > @@ -449,7 +448,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private) > > if (status & AT91_ADC_ISR_PENS) { > /* validate data by pen contact */ > - at91_ts_sample(st); > + at91_ts_sample(idev, st); > } else { > /* triggered by event that is no pen contact, just read > * them to clean the interrupt and discard all.
On Sat, 2020-05-16 at 18:17 +0100, Jonathan Cameron wrote: > [External] > > On Thu, 14 May 2020 16:17:05 +0300 > Alexandru Ardelean <alexandru.ardelean@analog.com> wrote: > > > Since there will be some changes to how iio_priv_to_dev() is implemented, > > it could be that the helper becomes a bit slower, as it will be hidden away > > in the IIO core. > > > > For this driver, the IIO device can be passed directly as a parameter to > > the at91_ts_sample() function, thus making it immune to the change of > > iio_priv_to_dev(). > > The function gets called in an interrupt context. > > > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > I wonder. Should we just pass the struct device? It's only used for > error printing I think, so we could make that explicit. I was also thinking that for this series, [for some drivers] it would make sense to put a reference to indio_dev on the state-struct; and just return it. I'll see about it. I am feeling that sometimes these IIO core cleanups end up being more than I want to do. But I'll try to see about it. Maybe I can make time or delegate some of this. My personal interest with them, is to reduce my complaints during reviews. People starting to write IIO drivers: well, I can see their frustration [on their faces] when I complain that they shouldn't use something, and they copied it from somewhere. > > I'm not that bothered either way though. > > Jonathan > > > --- > > drivers/iio/adc/at91_adc.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > > index 0368b6dc6d60..5999defe47cd 100644 > > --- a/drivers/iio/adc/at91_adc.c > > +++ b/drivers/iio/adc/at91_adc.c > > @@ -287,13 +287,12 @@ static void handle_adc_eoc_trigger(int irq, struct > > iio_dev *idev) > > } > > } > > > > -static int at91_ts_sample(struct at91_adc_state *st) > > +static int at91_ts_sample(struct iio_dev *idev, struct at91_adc_state *st) > > { > > unsigned int xscale, yscale, reg, z1, z2; > > unsigned int x, y, pres, xpos, ypos; > > unsigned int rxp = 1; > > unsigned int factor = 1000; > > - struct iio_dev *idev = iio_priv_to_dev(st); > > > > unsigned int xyz_mask_bits = st->res; > > unsigned int xyz_mask = (1 << xyz_mask_bits) - 1; > > @@ -449,7 +448,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void > > *private) > > > > if (status & AT91_ADC_ISR_PENS) { > > /* validate data by pen contact */ > > - at91_ts_sample(st); > > + at91_ts_sample(idev, st); > > } else { > > /* triggered by event that is no pen contact, just read > > * them to clean the interrupt and discard all.
On Mon, 18 May 2020 08:32:11 +0000 "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> wrote: > On Sat, 2020-05-16 at 18:17 +0100, Jonathan Cameron wrote: > > [External] > > > > On Thu, 14 May 2020 16:17:05 +0300 > > Alexandru Ardelean <alexandru.ardelean@analog.com> wrote: > > > > > Since there will be some changes to how iio_priv_to_dev() is implemented, > > > it could be that the helper becomes a bit slower, as it will be hidden away > > > in the IIO core. > > > > > > For this driver, the IIO device can be passed directly as a parameter to > > > the at91_ts_sample() function, thus making it immune to the change of > > > iio_priv_to_dev(). > > > The function gets called in an interrupt context. > > > > > > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> > > I wonder. Should we just pass the struct device? It's only used for > > error printing I think, so we could make that explicit. > > I was also thinking that for this series, [for some drivers] it would make sense > to put a reference to indio_dev on the state-struct; and just return it. > I'll see about it. > I am feeling that sometimes these IIO core cleanups end up being more than I > want to do. But I'll try to see about it. Maybe I can make time or delegate some > of this. Absolutely understood. No problem if you don't have time / energy to do this stuff. I very much appreciate it when you do, but I know how unrewarding it can be! > > My personal interest with them, is to reduce my complaints during reviews. > People starting to write IIO drivers: well, I can see their frustration [on > their faces] when I complain that they shouldn't use something, and they copied > it from somewhere. > That's more or less the only reason I write IIO patches currently! Though I get to mostly avoid seeing the faces of those who fall into the traps of old code we should have tidied up years ago :( Not gotten near any of new hardware pile of IIO hardware in a long time. Plenty of other new hardware, but not IIO stuff! Jonathan > > > > > I'm not that bothered either way though. > > > > Jonathan > > > > > --- > > > drivers/iio/adc/at91_adc.c | 5 ++--- > > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c > > > index 0368b6dc6d60..5999defe47cd 100644 > > > --- a/drivers/iio/adc/at91_adc.c > > > +++ b/drivers/iio/adc/at91_adc.c > > > @@ -287,13 +287,12 @@ static void handle_adc_eoc_trigger(int irq, struct > > > iio_dev *idev) > > > } > > > } > > > > > > -static int at91_ts_sample(struct at91_adc_state *st) > > > +static int at91_ts_sample(struct iio_dev *idev, struct at91_adc_state *st) > > > { > > > unsigned int xscale, yscale, reg, z1, z2; > > > unsigned int x, y, pres, xpos, ypos; > > > unsigned int rxp = 1; > > > unsigned int factor = 1000; > > > - struct iio_dev *idev = iio_priv_to_dev(st); > > > > > > unsigned int xyz_mask_bits = st->res; > > > unsigned int xyz_mask = (1 << xyz_mask_bits) - 1; > > > @@ -449,7 +448,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void > > > *private) > > > > > > if (status & AT91_ADC_ISR_PENS) { > > > /* validate data by pen contact */ > > > - at91_ts_sample(st); > > > + at91_ts_sample(idev, st); > > > } else { > > > /* triggered by event that is no pen contact, just read > > > * them to clean the interrupt and discard all.
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 0368b6dc6d60..5999defe47cd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -287,13 +287,12 @@ static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev) } } -static int at91_ts_sample(struct at91_adc_state *st) +static int at91_ts_sample(struct iio_dev *idev, struct at91_adc_state *st) { unsigned int xscale, yscale, reg, z1, z2; unsigned int x, y, pres, xpos, ypos; unsigned int rxp = 1; unsigned int factor = 1000; - struct iio_dev *idev = iio_priv_to_dev(st); unsigned int xyz_mask_bits = st->res; unsigned int xyz_mask = (1 << xyz_mask_bits) - 1; @@ -449,7 +448,7 @@ static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private) if (status & AT91_ADC_ISR_PENS) { /* validate data by pen contact */ - at91_ts_sample(st); + at91_ts_sample(idev, st); } else { /* triggered by event that is no pen contact, just read * them to clean the interrupt and discard all.
Since there will be some changes to how iio_priv_to_dev() is implemented, it could be that the helper becomes a bit slower, as it will be hidden away in the IIO core. For this driver, the IIO device can be passed directly as a parameter to the at91_ts_sample() function, thus making it immune to the change of iio_priv_to_dev(). The function gets called in an interrupt context. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> --- drivers/iio/adc/at91_adc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)