Message ID | 20220715122903.332535-16-nuno.sa@analog.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | make iio inkern interface firmware agnostic | expand |
On Fri, Jul 15, 2022 at 2:30 PM Nuno Sá <nuno.sa@analog.com> wrote: > > Just cosmetics. No functional change intended... Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > Signed-off-by: Nuno Sá <nuno.sa@analog.com> > --- > drivers/iio/inkern.c | 64 ++++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 32 deletions(-) > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c > index fab951546086..0c9b1561af31 100644 > --- a/drivers/iio/inkern.c > +++ b/drivers/iio/inkern.c > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) > int i = 0, ret = 0; > struct iio_map_internal *mapi; > > - if (maps == NULL) > + if (!maps) > return 0; > > mutex_lock(&iio_map_list_lock); > - while (maps[i].consumer_dev_name != NULL) { > + while (maps[i].consumer_dev_name) { > mapi = kzalloc(sizeof(*mapi), GFP_KERNEL); > - if (mapi == NULL) { > + if (!mapi) { > ret = -ENOMEM; > goto error_ret; > } > @@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) > } > EXPORT_SYMBOL_GPL(iio_map_array_register); > > - > /* > * Remove all map entries associated with the given iio device > */ > @@ -157,7 +156,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel, > return err; > > idev = bus_find_device_by_fwnode(&iio_bus_type, iiospec.fwnode); > - if (idev == NULL) { > + if (!idev) { > fwnode_handle_put(iiospec.fwnode); > return -EPROBE_DEFER; > } > @@ -190,7 +189,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode, > return ERR_PTR(-EINVAL); > > channel = kzalloc(sizeof(*channel), GFP_KERNEL); > - if (channel == NULL) > + if (!channel) > return ERR_PTR(-ENOMEM); > > err = __fwnode_iio_channel_get(channel, fwnode, index); > @@ -307,7 +306,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev) > > /* NULL terminated array to save passing size */ > chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); > - if (chans == NULL) > + if (!chans) > return ERR_PTR(-ENOMEM); > > /* Search for FW matches */ > @@ -332,7 +331,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name, > struct iio_channel *channel; > int err; > > - if (name == NULL && channel_name == NULL) > + if (!(name || channel_name)) > return ERR_PTR(-ENODEV); > > /* first find matching entry the channel map */ > @@ -347,11 +346,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name, > break; > } > mutex_unlock(&iio_map_list_lock); > - if (c == NULL) > + if (!c) > return ERR_PTR(-ENODEV); > > channel = kzalloc(sizeof(*channel), GFP_KERNEL); > - if (channel == NULL) { > + if (!channel) { > err = -ENOMEM; > goto error_no_mem; > } > @@ -363,7 +362,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name, > iio_chan_spec_from_name(channel->indio_dev, > c->map->adc_channel_label); > > - if (channel->channel == NULL) { > + if (!channel->channel) { > err = -EINVAL; > goto error_no_chan; > } > @@ -455,7 +454,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) > int mapind = 0; > int i, ret; > > - if (dev == NULL) > + if (!dev) > return ERR_PTR(-EINVAL); > > chans = fwnode_iio_channel_get_all(dev); > @@ -483,7 +482,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) > > /* NULL terminated array to save passing size */ > chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); > - if (chans == NULL) { > + if (!chans) { > ret = -ENOMEM; > goto error_ret; > } > @@ -497,7 +496,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) > chans[mapind].channel = > iio_chan_spec_from_name(chans[mapind].indio_dev, > c->map->adc_channel_label); > - if (chans[mapind].channel == NULL) { > + if (!chans[mapind].channel) { > ret = -EINVAL; > goto error_free_chans; > } > @@ -559,14 +558,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev) > EXPORT_SYMBOL_GPL(devm_iio_channel_get_all); > > static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, > - enum iio_chan_info_enum info) > + enum iio_chan_info_enum info) > { > int unused; > int vals[INDIO_MAX_RAW_ELEMENTS]; > int ret; > int val_len = 2; > > - if (val2 == NULL) > + if (!val2) > val2 = &unused; > > if (!iio_channel_has_info(chan->channel, info)) > @@ -578,9 +577,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, > vals, &val_len, info); > *val = vals[0]; > *val2 = vals[1]; > - } else > + } else { > ret = chan->indio_dev->info->read_raw(chan->indio_dev, > chan->channel, val, val2, info); > + } > > return ret; > } > @@ -591,7 +591,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val) > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -610,7 +610,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val) > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -624,7 +624,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val) > EXPORT_SYMBOL_GPL(iio_read_channel_average_raw); > > static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, > - int raw, int *processed, unsigned int scale) > + int raw, int *processed, > + unsigned int scale) > { > int scale_type, scale_val, scale_val2; > int offset_type, offset_val, offset_val2; > @@ -657,7 +658,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, > } > > scale_type = iio_channel_read(chan, &scale_val, &scale_val2, > - IIO_CHAN_INFO_SCALE); > + IIO_CHAN_INFO_SCALE); > if (scale_type < 0) { > /* > * If no channel scaling is available apply consumer scale to > @@ -702,19 +703,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, > } > > int iio_convert_raw_to_processed(struct iio_channel *chan, int raw, > - int *processed, unsigned int scale) > + int *processed, unsigned int scale) > { > struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev); > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > > ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed, > - scale); > + scale); > err_unlock: > mutex_unlock(&iio_dev_opaque->info_exist_lock); > > @@ -729,7 +730,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2, > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -755,7 +756,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val, > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -833,7 +834,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan, > int type; > > ret = iio_read_avail_channel_attribute(chan, vals, &type, length, > - IIO_CHAN_INFO_RAW); > + IIO_CHAN_INFO_RAW); > > if (ret >= 0 && type != IIO_VAL_INT) > /* raw values are assumed to be IIO_VAL_INT */ > @@ -917,7 +918,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type) > /* Need to verify underlying driver has not gone away */ > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -944,7 +945,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2, > int ret; > > mutex_lock(&iio_dev_opaque->info_exist_lock); > - if (chan->indio_dev->info == NULL) { > + if (!chan->indio_dev->info) { > ret = -ENODEV; > goto err_unlock; > } > @@ -978,9 +979,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan) > } > EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count); > > -static const struct iio_chan_spec_ext_info *iio_lookup_ext_info( > - const struct iio_channel *chan, > - const char *attr) > +static const struct iio_chan_spec_ext_info * > +iio_lookup_ext_info(const struct iio_channel *chan, const char *attr) > { > const struct iio_chan_spec_ext_info *ext_info; > > -- > 2.37.1 >
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index fab951546086..0c9b1561af31 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) int i = 0, ret = 0; struct iio_map_internal *mapi; - if (maps == NULL) + if (!maps) return 0; mutex_lock(&iio_map_list_lock); - while (maps[i].consumer_dev_name != NULL) { + while (maps[i].consumer_dev_name) { mapi = kzalloc(sizeof(*mapi), GFP_KERNEL); - if (mapi == NULL) { + if (!mapi) { ret = -ENOMEM; goto error_ret; } @@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) } EXPORT_SYMBOL_GPL(iio_map_array_register); - /* * Remove all map entries associated with the given iio device */ @@ -157,7 +156,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel, return err; idev = bus_find_device_by_fwnode(&iio_bus_type, iiospec.fwnode); - if (idev == NULL) { + if (!idev) { fwnode_handle_put(iiospec.fwnode); return -EPROBE_DEFER; } @@ -190,7 +189,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode, return ERR_PTR(-EINVAL); channel = kzalloc(sizeof(*channel), GFP_KERNEL); - if (channel == NULL) + if (!channel) return ERR_PTR(-ENOMEM); err = __fwnode_iio_channel_get(channel, fwnode, index); @@ -307,7 +306,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev) /* NULL terminated array to save passing size */ chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); - if (chans == NULL) + if (!chans) return ERR_PTR(-ENOMEM); /* Search for FW matches */ @@ -332,7 +331,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name, struct iio_channel *channel; int err; - if (name == NULL && channel_name == NULL) + if (!(name || channel_name)) return ERR_PTR(-ENODEV); /* first find matching entry the channel map */ @@ -347,11 +346,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name, break; } mutex_unlock(&iio_map_list_lock); - if (c == NULL) + if (!c) return ERR_PTR(-ENODEV); channel = kzalloc(sizeof(*channel), GFP_KERNEL); - if (channel == NULL) { + if (!channel) { err = -ENOMEM; goto error_no_mem; } @@ -363,7 +362,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name, iio_chan_spec_from_name(channel->indio_dev, c->map->adc_channel_label); - if (channel->channel == NULL) { + if (!channel->channel) { err = -EINVAL; goto error_no_chan; } @@ -455,7 +454,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) int mapind = 0; int i, ret; - if (dev == NULL) + if (!dev) return ERR_PTR(-EINVAL); chans = fwnode_iio_channel_get_all(dev); @@ -483,7 +482,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) /* NULL terminated array to save passing size */ chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); - if (chans == NULL) { + if (!chans) { ret = -ENOMEM; goto error_ret; } @@ -497,7 +496,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) chans[mapind].channel = iio_chan_spec_from_name(chans[mapind].indio_dev, c->map->adc_channel_label); - if (chans[mapind].channel == NULL) { + if (!chans[mapind].channel) { ret = -EINVAL; goto error_free_chans; } @@ -559,14 +558,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev) EXPORT_SYMBOL_GPL(devm_iio_channel_get_all); static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, - enum iio_chan_info_enum info) + enum iio_chan_info_enum info) { int unused; int vals[INDIO_MAX_RAW_ELEMENTS]; int ret; int val_len = 2; - if (val2 == NULL) + if (!val2) val2 = &unused; if (!iio_channel_has_info(chan->channel, info)) @@ -578,9 +577,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, vals, &val_len, info); *val = vals[0]; *val2 = vals[1]; - } else + } else { ret = chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel, val, val2, info); + } return ret; } @@ -591,7 +591,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val) int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -610,7 +610,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val) int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -624,7 +624,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val) EXPORT_SYMBOL_GPL(iio_read_channel_average_raw); static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, - int raw, int *processed, unsigned int scale) + int raw, int *processed, + unsigned int scale) { int scale_type, scale_val, scale_val2; int offset_type, offset_val, offset_val2; @@ -657,7 +658,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, } scale_type = iio_channel_read(chan, &scale_val, &scale_val2, - IIO_CHAN_INFO_SCALE); + IIO_CHAN_INFO_SCALE); if (scale_type < 0) { /* * If no channel scaling is available apply consumer scale to @@ -702,19 +703,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, } int iio_convert_raw_to_processed(struct iio_channel *chan, int raw, - int *processed, unsigned int scale) + int *processed, unsigned int scale) { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev); int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed, - scale); + scale); err_unlock: mutex_unlock(&iio_dev_opaque->info_exist_lock); @@ -729,7 +730,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2, int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -755,7 +756,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val, int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -833,7 +834,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan, int type; ret = iio_read_avail_channel_attribute(chan, vals, &type, length, - IIO_CHAN_INFO_RAW); + IIO_CHAN_INFO_RAW); if (ret >= 0 && type != IIO_VAL_INT) /* raw values are assumed to be IIO_VAL_INT */ @@ -917,7 +918,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type) /* Need to verify underlying driver has not gone away */ mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -944,7 +945,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2, int ret; mutex_lock(&iio_dev_opaque->info_exist_lock); - if (chan->indio_dev->info == NULL) { + if (!chan->indio_dev->info) { ret = -ENODEV; goto err_unlock; } @@ -978,9 +979,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan) } EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count); -static const struct iio_chan_spec_ext_info *iio_lookup_ext_info( - const struct iio_channel *chan, - const char *attr) +static const struct iio_chan_spec_ext_info * +iio_lookup_ext_info(const struct iio_channel *chan, const char *attr) { const struct iio_chan_spec_ext_info *ext_info;
Just cosmetics. No functional change intended... Signed-off-by: Nuno Sá <nuno.sa@analog.com> --- drivers/iio/inkern.c | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-)