[no subject]

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

 



> +
> +	__be16 fifo_buf[ADXL380_FIFO_SAMPLES];
This one is used for regmap_no_inc_read() so if you drop
the __aligned() markings above this will need one.

> +};


> +static int adxl380_set_odr(struct adxl380_state *st, u8 odr)
> +{
> +	int ret;
> +
> +	guard(mutex)(&st->lock);
> +
> +	ret = adxl380_set_measure_en(st, false);
> +	if (ret)
> +		return ret;
> +
> +	ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
> +				 ADXL380_TRIG_CFG_DEC_2X_MSK,
> +				 FIELD_PREP(ADXL380_TRIG_CFG_DEC_2X_MSK, (odr & 1)));
> +	if (ret)
> +		return ret;
> +
> +	ret = regmap_update_bits(st->regmap, ADXL380_TRIG_CFG_REG,
> +				 ADXL380_TRIG_CFG_SINC_RATE_MSK,
> +				 FIELD_PREP(ADXL380_TRIG_CFG_SINC_RATE_MSK, (odr >> 1)));
Brackets around (odr >> 1) don't add anythign and make long lines
even longer.



...

> +
> +static ssize_t adxl380_get_fifo_enabled(struct device *dev,
> +					struct device_attribute *attr,
> +					char *buf)
> +{
> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> +	struct adxl380_state *st = iio_priv(indio_dev);
> +	int ret;
> +	unsigned int reg_val;
> +
> +	ret = regmap_read(st->regmap, ADXL380_DIG_EN_REG, &reg_val);
> +	if (ret)
> +		return ret;
> +
> +	return sysfs_emit(buf, "%lu\n", FIELD_GET(ADXL380_FIFO_EN_MSK, reg_val));
Long line that should be wrapped.
> +}
> +
> +static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
> +static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
> +static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
> +		       adxl380_get_fifo_watermark, NULL, 0);
> +static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
> +		       adxl380_get_fifo_enabled, NULL, 0);
> +
> +static const struct iio_dev_attr *adxl380_fifo_attributes[] = {
> +	&iio_dev_attr_hwfifo_watermark_min,
> +	&iio_dev_attr_hwfifo_watermark_max,
> +	&iio_dev_attr_hwfifo_watermark,
> +	&iio_dev_attr_hwfifo_enabled,
> +	NULL,

No comma on null terminators as we never add anything after them.

> +};

...

> +static int adxl380_config_irq(struct iio_dev *indio_dev)
> +{
> +	struct adxl380_state *st = iio_priv(indio_dev);
> +	unsigned long irq_flag;
> +	struct irq_data *desc;
> +	u32 irq_type;
> +	u8 polarity;
> +	int ret;
> +
> +	desc = irq_get_irq_data(st->irq);
> +	if (!desc)
> +		return dev_err_probe(st->dev, -EINVAL, "Could not find IRQ %d\n", st->irq);
> +
> +	irq_type = irqd_get_trigger_type(desc);
> +	if (irq_type == IRQ_TYPE_LEVEL_HIGH) {
> +		polarity = 0;
> +		irq_flag = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
> +	} else if (irq_type == IRQ_TYPE_LEVEL_LOW) {
> +		polarity = 1;
> +		irq_flag = IRQF_TRIGGER_LOW | IRQF_ONESHOT;
> +	} else {
> +		return dev_err_probe(st->dev, -EINVAL,
> +				     "Invalid interrupt 0x%x. Only level interrupts supported\n",
> +			irq_type);

Odd indentation.  

> +	}
> +
> +	ret = regmap_update_bits(st->regmap, ADXL380_INT0_REG,
> +				 ADXL380_INT0_POL_MSK,
> +				 FIELD_PREP(ADXL380_INT0_POL_MSK, polarity));
> +	if (ret)
> +		return ret;
> +
> +	return devm_request_threaded_irq(st->dev, st->irq, NULL,
> +					 adxl380_irq_handler, irq_flag,
> +					 indio_dev->name, indio_dev);
> +}
>
> +
> +int adxl380_probe(struct device *dev, struct regmap *regmap,
> +		  const struct adxl380_chip_info *chip_info)
> +{

...

> +	st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT0");
> +	if (st->irq  > 0) {

one space only before >

> +		st->int_map[0] = ADXL380_INT0_MAP0_REG;
> +		st->int_map[1] = ADXL380_INT0_MAP1_REG;
> +	} else {
> +		st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1");
> +		if (st->irq  > 0)

one space only before >

> +			return dev_err_probe(dev, -ENODEV,
> +					     "no interrupt name specified");
> +		st->int_map[0] = ADXL380_INT1_MAP0_REG;
> +		st->int_map[1] = ADXL380_INT1_MAP1_REG;
> +	}
> +
> +	ret = adxl380_setup(indio_dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_iio_kfifo_buffer_setup_ext(st->dev, indio_dev,
> +					      &adxl380_buffer_ops,
> +					      adxl380_fifo_attributes);
> +	if (ret)
> +		return ret;
> +
> +	return devm_iio_device_register(dev, indio_dev);
> +}



> diff --git a/drivers/iio/accel/adxl380_i2c.c b/drivers/iio/accel/adxl380_i2c.c
> new file mode 100644
> index 000000000000..dad3b39a5125
> --- /dev/null
> +++ b/drivers/iio/accel/adxl380_i2c.c
> @@ -0,0 +1,64 @@

...

> +static const struct i2c_device_id adxl380_i2c_id[] = {
> +	{ "adxl380", (kernel_ulong_t)&adxl380_chip_info},
> +	{ "adxl382", (kernel_ulong_t)&adxl382_chip_info},

space before }

> +	{}
As below - be consistent. 
> +};
> +MODULE_DEVICE_TABLE(i2c, adxl380_i2c_id);
> +
> +static const struct of_device_id adxl380_of_match[] = {
> +	{ .compatible = "adi,adxl380", .data = &adxl380_chip_info},
> +	{ .compatible = "adi,adxl382", .data = &adxl382_chip_info},
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, adxl380_of_match);

> diff --git a/drivers/iio/accel/adxl380_spi.c b/drivers/iio/accel/adxl380_spi.c
> new file mode 100644
> index 000000000000..c244ae328714
> --- /dev/null
> +++ b/drivers/iio/accel/adxl380_spi.c
> @@ -0,0 +1,66 @@

> +
> +static const struct spi_device_id adxl380_spi_id[] = {
> +	{ "adxl380", (kernel_ulong_t)&adxl380_chip_info },
> +	{ "adxl382", (kernel_ulong_t)&adxl382_chip_info },
> +	{}

Spacing should be consistent.  I'd have { } as below.

> +};
> +MODULE_DEVICE_TABLE(spi, adxl380_spi_id);
> +
> +static const struct of_device_id adxl380_of_match[] = {
> +	{ .compatible = "adi,adxl380", .data = &adxl380_chip_info },
> +	{ .compatible = "adi,adxl382", .data = &adxl382_chip_info },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, adxl380_of_match);






[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux