lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <20250706105302.6ba58b3c@jic23-huawei> Date: Sun, 6 Jul 2025 10:53:02 +0100 From: Jonathan Cameron <jic23@...nel.org> To: David Lechner <dlechner@...libre.com> Cc: Nuno Sá <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org Subject: Re: [PATCH v2] iio: pressure: dlhl60d: drop use of chip info array On Sat, 28 Jun 2025 13:15:10 -0500 David Lechner <dlechner@...libre.com> wrote: > Change the dlhl60d driver to use individual chip info structures instead > of an array. This reduces the verbosity of the code. Also, the data is > now const as it should have been in the first place. Applied with tweaked patch title to Use separate structures rather than an array for chip info. > > Signed-off-by: David Lechner <dlechner@...libre.com> > --- > Changes in v2: > - Changed the patch to drop the chip info array. > - Link to v1: https://lore.kernel.org/r/20250628-iio-const-data-24-v1-1-353b97281534@baylibre.com > --- > drivers/iio/pressure/dlhl60d.c | 47 +++++++++++++++++++----------------------- > 1 file changed, 21 insertions(+), 26 deletions(-) > > diff --git a/drivers/iio/pressure/dlhl60d.c b/drivers/iio/pressure/dlhl60d.c > index 48afe5c94000b44eb324d7631f3c0db8e3d0079e..6a13cf2eaf50187d4cbd94cd93b1d14ad4de8b26 100644 > --- a/drivers/iio/pressure/dlhl60d.c > +++ b/drivers/iio/pressure/dlhl60d.c > @@ -32,35 +32,31 @@ > /* DLH timings */ > #define DLH_SINGLE_DUT_MS 5 > > -enum dhl_ids { > - dlhl60d, > - dlhl60g, > -}; > - > struct dlh_info { > + const char *name; /* chip name */ > u8 osdig; /* digital offset factor */ > unsigned int fss; /* full scale span (inch H2O) */ > }; > > struct dlh_state { > struct i2c_client *client; > - struct dlh_info info; > + const struct dlh_info *info; > bool use_interrupt; > struct completion completion; > u8 rx_buf[DLH_NUM_READ_BYTES]; > }; > > -static struct dlh_info dlh_info_tbl[] = { > - [dlhl60d] = { > - .osdig = 2, > - .fss = 120, > - }, > - [dlhl60g] = { > - .osdig = 10, > - .fss = 60, > - }, > +static const struct dlh_info dlhl60d_info = { > + .name = "dlhl60d", > + .osdig = 2, > + .fss = 120, > }; > > +static const struct dlh_info dlhl60g_info = { > + .name = "dlhl60g", > + .osdig = 10, > + .fss = 60, > +}; > > static int dlh_cmd_start_single(struct dlh_state *st) > { > @@ -170,7 +166,7 @@ static int dlh_read_raw(struct iio_dev *indio_dev, > case IIO_CHAN_INFO_SCALE: > switch (channel->type) { > case IIO_PRESSURE: > - tmp = div_s64(125LL * st->info.fss * 24909 * 100, > + tmp = div_s64(125LL * st->info->fss * 24909 * 100, > 1 << DLH_NUM_PR_BITS); > tmp = div_s64_rem(tmp, 1000000000LL, &rem); > *value = tmp; > @@ -188,8 +184,8 @@ static int dlh_read_raw(struct iio_dev *indio_dev, > case IIO_CHAN_INFO_OFFSET: > switch (channel->type) { > case IIO_PRESSURE: > - *value = -125 * st->info.fss * 24909; > - *value2 = 100 * st->info.osdig * 100000; > + *value = -125 * st->info->fss * 24909; > + *value2 = 100 * st->info->osdig * 100000; > return IIO_VAL_FRACTIONAL; > > case IIO_TEMP: > @@ -281,7 +277,6 @@ static irqreturn_t dlh_interrupt(int irq, void *private) > > static int dlh_probe(struct i2c_client *client) > { > - const struct i2c_device_id *id = i2c_client_get_device_id(client); > struct dlh_state *st; > struct iio_dev *indio_dev; > int ret; > @@ -302,11 +297,11 @@ static int dlh_probe(struct i2c_client *client) > i2c_set_clientdata(client, indio_dev); > > st = iio_priv(indio_dev); > - st->info = dlh_info_tbl[id->driver_data]; > + st->info = i2c_get_match_data(client); > st->client = client; > st->use_interrupt = false; > > - indio_dev->name = id->name; > + indio_dev->name = st->info->name; > indio_dev->info = &dlh_info; > indio_dev->modes = INDIO_DIRECT_MODE; > indio_dev->channels = dlh_channels; > @@ -316,7 +311,7 @@ static int dlh_probe(struct i2c_client *client) > ret = devm_request_threaded_irq(&client->dev, client->irq, > dlh_interrupt, NULL, > IRQF_TRIGGER_RISING | IRQF_ONESHOT, > - id->name, indio_dev); > + st->info->name, indio_dev); > if (ret) { > dev_err(&client->dev, "failed to allocate threaded irq"); > return ret; > @@ -341,15 +336,15 @@ static int dlh_probe(struct i2c_client *client) > } > > static const struct of_device_id dlh_of_match[] = { > - { .compatible = "asc,dlhl60d" }, > - { .compatible = "asc,dlhl60g" }, > + { .compatible = "asc,dlhl60d", .data = &dlhl60d_info }, > + { .compatible = "asc,dlhl60g", .data = &dlhl60g_info }, > { } > }; > MODULE_DEVICE_TABLE(of, dlh_of_match); > > static const struct i2c_device_id dlh_id[] = { > - { "dlhl60d", dlhl60d }, > - { "dlhl60g", dlhl60g }, > + { "dlhl60d", (kernel_ulong_t)&dlhl60d_info }, > + { "dlhl60g", (kernel_ulong_t)&dlhl60g_info }, > { } > }; > MODULE_DEVICE_TABLE(i2c, dlh_id); > > --- > base-commit: 14071b9cf2d751ff9bc8b5e43fa94fbf08aceea1 > change-id: 20250628-iio-const-data-24-4ace82a87bfd > > Best regards,
Powered by blists - more mailing lists