Re: [PATCH v2 1/4] iio: chemical: scd30: add core driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 31 May 2020 10:58:40 +0100
Jonathan Cameron <jic23@xxxxxxxxxx> wrote:

> On Sat, 30 May 2020 23:36:27 +0200
> Tomasz Duszynski <tomasz.duszynski@xxxxxxxxxxx> wrote:
> 
> > Add Sensirion SCD30 carbon dioxide core driver.
> > 
> > Signed-off-by: Tomasz Duszynski <tomasz.duszynski@xxxxxxxxxxx>  
> 
> Hi Tomasz
> 
> A few things inline.  Includes the alignment issue on 
> x86_32 that I fell into whilst trying to fix timestamp
> alignment issues.  Suggested resolution inline for that.
> 
> Thanks,
> 
> Jonathan
> 

Update below after looking at the way this works with the serial dev.

> > +int scd30_probe(struct device *dev, int irq, const char *name, void *priv,
> > +		scd30_command_t command)
> > +{
> > +	static const unsigned long scd30_scan_masks[] = { 0x07, 0x00 };
> > +	struct scd30_state *state;
> > +	struct iio_dev *indio_dev;
> > +	int ret;
> > +	u16 val;
> > +
> > +	indio_dev = devm_iio_device_alloc(dev, sizeof(*state));
> > +	if (!indio_dev)
> > +		return -ENOMEM;
> > +
> > +	state = iio_priv(indio_dev);
> > +	state->dev = dev;  
> 
> Doesn't seem to be used.
> 
> > +	state->priv = priv;  
> 
> What's this for?  At least at first glance I can't find it being used
> anywhere.

Ah. Used in the serial module.  Maybe add a comment to the structure definition
about that.

As is the dev etc.  Is it possible to use the 

> 
> > +	state->irq = irq;
> > +	state->pressure_comp = SCD30_PRESSURE_COMP_DEFAULT;
> > +	state->meas_interval = SCD30_MEAS_INTERVAL_DEFAULT;
> > +	state->command = command;
> > +	mutex_init(&state->lock);
> > +	init_completion(&state->meas_ready);
> > +
> > +	dev_set_drvdata(dev, indio_dev);
> > +
> > +	indio_dev->dev.parent = dev;  
> 
> Side note that there is a series moving this into the core under revision at
> the moment.  Hopefully I'll remember to fix this up when applying your patch
> if that one has gone in ahead of it.
> 
> > +	indio_dev->info = &scd30_info;
> > +	indio_dev->name = name;
> > +	indio_dev->channels = scd30_channels;
> > +	indio_dev->num_channels = ARRAY_SIZE(scd30_channels);
> > +	indio_dev->modes = INDIO_DIRECT_MODE;
> > +	indio_dev->available_scan_masks = scd30_scan_masks;
> > +
> > +	state->vdd = devm_regulator_get(dev, "vdd");
> > +	if (IS_ERR(state->vdd)) {
> > +		if (PTR_ERR(state->vdd) == -EPROBE_DEFER)
> > +			return -EPROBE_DEFER;
> > +
> > +		dev_err(dev, "failed to get regulator\n");
> > +		return PTR_ERR(state->vdd);
> > +	}
> > +
> > +	ret = regulator_enable(state->vdd);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = devm_add_action_or_reset(dev, scd30_disable_regulator, state);
> > +	if (ret)
> > +		return ret;
> > +  
...



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux