diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 070d20e..63f23af 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -271,6 +271,7 @@ static int magn_3d_parse_report(struct platform_device *pdev, int ret = 0; int i; int attr_count = 0; + struct iio_chan_spec *_channels; /* Scan for each usage attribute supported */ for (i = 0; i < MAGN_3D_CHANNEL_MAX; i++) { @@ -300,10 +301,10 @@ static int magn_3d_parse_report(struct platform_device *pdev, return -EINVAL; /* Setup IIO channel array */ - *channels = devm_kcalloc(&pdev->dev, attr_count, + _channels = devm_kcalloc(&pdev->dev, attr_count, sizeof(struct iio_chan_spec), GFP_KERNEL); - if (!*channels) { + if (!_channels) { dev_err(&pdev->dev, "failed to allocate space for iio channels\n"); return -ENOMEM; } @@ -322,14 +323,16 @@ static int magn_3d_parse_report(struct platform_device *pdev, { if (st->magn[i].index >= 0) { /* Setup IIO channel struct */ - *channels[*chan_count] = magn_3d_channels[i]; + _channels[*chan_count] = magn_3d_channels[i]; st->magn_val_addr[i] = &(st->iio_val[*chan_count]); - magn_3d_adjust_channel_bit_mask(*channels, *chan_count, st->magn[i].size); + magn_3d_adjust_channel_bit_mask(_channels, *chan_count, st->magn[i].size); (*chan_count)++; } } + *channels = _channels; + st->scale_precision = hid_sensor_format_scale( HID_USAGE_SENSOR_COMPASS_3D, &st->magn[CHANNEL_SCAN_INDEX_X],