Re: [PATCH] iio: proximity: sx_common: Add old register mapping

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

 



Quoting Gwendal Grignou (2022-12-08 10:48:12)
> diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
> index 0e4747ccd3cf7..e8f8c727d2467 100644
> --- a/drivers/iio/proximity/sx9310.c
> +++ b/drivers/iio/proximity/sx9310.c
> @@ -871,6 +873,8 @@ static int sx9324_init_compensation(struct iio_dev *indio_dev)
>                                         20000, 2000000);
>  }
>
> +extern const struct acpi_device_id sx9324_acpi_match[];
> +

Put this extern in common.h?

> @@ -888,7 +892,10 @@ sx9324_get_default_reg(struct device *dev, int idx,
>         int ret, count, ph, pin;
>         const char *res;
>
> +

Remove?

>         memcpy(reg_def, &sx9324_default_regs[idx], sizeof(*reg_def));
> +       sx_common_get_raw_register_config(dev, sx9324_acpi_match, reg_def);
> +
>         switch (reg_def->reg) {
>         case SX9324_REG_AFE_PH0:
>         case SX9324_REG_AFE_PH1:
> @@ -1116,7 +1123,7 @@ static int sx9324_resume(struct device *dev)
>
>  static DEFINE_SIMPLE_DEV_PM_OPS(sx9324_pm_ops, sx9324_suspend, sx9324_resume);
>
> -static const struct acpi_device_id sx9324_acpi_match[] = {
> +const struct acpi_device_id sx9324_acpi_match[] = {
>         { "STH9324", SX9324_WHOAMI_VALUE },
>         { }
>  };
> diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
> index 7fa2213d23baf..95c2df36729e2 100644
> --- a/drivers/iio/proximity/sx9360.c
> +++ b/drivers/iio/proximity/sx9360.c
> @@ -715,6 +715,8 @@ static int sx9360_init_compensation(struct iio_dev *indio_dev)
>                                        20000, 2000000);
>  }
>
> +extern const struct acpi_device_id sx9360_acpi_match[];
> +

Put this extern in common.h?

> diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
> index d70a6b4f0bf86..ce8f99b6fc3d9 100644
> --- a/drivers/iio/proximity/sx_common.c
> +++ b/drivers/iio/proximity/sx_common.c
> @@ -424,6 +424,7 @@ static const struct iio_buffer_setup_ops sx_common_buffer_setup_ops = {
>         .postdisable = sx_common_buffer_postdisable,
>  };
>
> +
>  static void sx_common_regulator_disable(void *_data)
>  {
>         struct sx_common_data *data = _data;

Remove this hunk?

> @@ -431,6 +432,31 @@ static void sx_common_regulator_disable(void *_data)
>         regulator_bulk_disable(ARRAY_SIZE(data->supplies), data->supplies);
>  }
>
> +void sx_common_get_raw_register_config(struct device *dev,
> +               const struct acpi_device_id *acpi_ids,
> +               struct sx_common_reg_default *reg_def)
> +{
> +       const struct acpi_device_id *id;
> +       u32 raw = 0, ret;
> +       char prop[80];
> +
> +       if (!reg_def->property)
> +               return;
> +
> +       for (id = acpi_ids; id->id[0]; id++) {
> +               scnprintf(prop, ARRAY_SIZE(prop), "%s,reg_%s",
> +                               id->id, reg_def->property);
> +               ret = device_property_read_u32(dev, prop, &raw);
> +               if (ret)
> +                       continue;
> +
> +               reg_def->def = raw;
> +               break;
> +       }
> +}
> +EXPORT_SYMBOL_NS_GPL(sx_common_get_raw_register_config, SEMTECH_PROX);
> +
> +

Remove one newline here?

>  #define SX_COMMON_SOFT_RESET                           0xde
>
>  static int sx_common_init_device(struct device *dev, struct iio_dev *indio_dev)
> diff --git a/drivers/iio/proximity/sx_common.h b/drivers/iio/proximity/sx_common.h
> index 5d3edeb75f4e0..ba6472eb9988d 100644
> --- a/drivers/iio/proximity/sx_common.h
> +++ b/drivers/iio/proximity/sx_common.h
> @@ -24,6 +24,7 @@ struct sx_common_data;
>  static_assert(SX_COMMON_MAX_NUM_CHANNELS < BITS_PER_LONG);
>
>  struct sx_common_reg_default {
> +       const char *property;

Can you add it at the end of the struct so we don't have to update all
the lines that don't really change? Or is this to save on alignment?

>         u8 reg;
>         u8 def;
>  };



[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