[PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

2017-05-28 Thread Paolo Cretaro
Fix sparse warning: Using plain integer as NULL pointer

Signed-off-by: Paolo Cretaro 
---
 drivers/iio/adc/meson_saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 81cd39a57fe3..fb3f67a9ae1f 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev 
*indio_dev)
if (!meson_sar_adc_get_fifo_count(indio_dev))
break;
 
-   regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
+   regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
}
 }
 
-- 
2.13.0



Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

2017-05-28 Thread Paolo Cretaro
On 28/05/2017 16:43, Jonathan Cameron wrote:
> On Sun, 28 May 2017 13:24:38 +0200
> Paolo Cretaro  wrote:
> 
>> Fix sparse warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Paolo Cretaro 
> This looks fine to me, but ideally you should always try to include
> the driver author - particularly in the case of patches to a recent
> driver such as this one.
Sure, thanks for pointing this out, I just felt a bit embarrassed to bother
too many people with such a trivial patch.

Paolo
> 
> To that end I've cc'd Martin.
> 
> Jonathan
>> ---
>>  drivers/iio/adc/meson_saradc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
>> index 81cd39a57fe3..fb3f67a9ae1f 100644
>> --- a/drivers/iio/adc/meson_saradc.c
>> +++ b/drivers/iio/adc/meson_saradc.c
>> @@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev 
>> *indio_dev)
>>  if (!meson_sar_adc_get_fifo_count(indio_dev))
>>  break;
>>  
>> -regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
>> +regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
>>  }
>>  }
>>  
> 


[PATCH] vfio/mdev: add static modifier to add_mdev_supported_type

2018-11-13 Thread Paolo Cretaro
Set add_mdev_supported_type as static since it is only used within
mdev_sysfs.c.
This fixes -Wmissing-prototypes gcc warning.

Signed-off-by: Paolo Cretaro 
---
 drivers/vfio/mdev/mdev_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 249472f05509..ce5dd219f2c8 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -92,8 +92,8 @@ static struct kobj_type mdev_type_ktype = {
.release = mdev_type_release,
 };
 
-struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
- struct attribute_group *group)
+static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
+struct attribute_group *group)
 {
struct mdev_type *type;
int ret;
-- 
2.19.1



[PATCH] drivers/char/random.c: add missing include

2018-11-13 Thread Paolo Cretaro
Include linux/hw_random.h header file to silence the following
Wmissing-prototypes gcc warning:
drivers/char/random.c:2346:6: warning: no previous prototype for 
‘add_hwgenerator_randomness’ [-Wmissing-prototypes]

Signed-off-by: Paolo Cretaro 
---
 drivers/char/random.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0a381897e4a5..02c65dd417ae 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -265,6 +265,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
-- 
2.19.1



[PATCH] staging: pi433: use IS_ERR to check kthread_run return value

2017-07-22 Thread Paolo Cretaro
Fix compiler warning: ordered comparison of pointer with integer zero

Signed-off-by: Paolo Cretaro 
---
 drivers/staging/pi433/pi433_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 1bc478a7f49e..79bd19123239 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1152,7 +1152,7 @@ static int pi433_probe(struct spi_device *spi)
device->tx_task_struct = kthread_run(pi433_tx_thread,
 device,
 "pi433_tx_task");
-   if (device->tx_task_struct < 0)
+   if (IS_ERR(device->tx_task_struct))
{
dev_dbg(device->dev, "start of send thread failed");
goto send_thread_failed;
-- 
2.13.3



Re: [PATCH] staging: pi433: use IS_ERR to check kthread_run return value

2017-07-22 Thread Paolo Cretaro
On 22/07/2017 12:27, Paolo Cretaro wrote:
> Fix compiler warning: ordered comparison of pointer with integer zero

Sorry, just noticed a similar patch has been submitted a few days ago,
please ignore this patch.

Paolo

> 
> Signed-off-by: Paolo Cretaro 
> ---
>  drivers/staging/pi433/pi433_if.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/pi433/pi433_if.c 
> b/drivers/staging/pi433/pi433_if.c
> index 1bc478a7f49e..79bd19123239 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -1152,7 +1152,7 @@ static int pi433_probe(struct spi_device *spi)
>   device->tx_task_struct = kthread_run(pi433_tx_thread,
>device,
>"pi433_tx_task");
> - if (device->tx_task_struct < 0)
> + if (IS_ERR(device->tx_task_struct))
>   {
>   dev_dbg(device->dev, "start of send thread failed");
>   goto send_thread_failed;
> 


[PATCH] staging: vboxvideo: remove unused variables

2017-07-22 Thread Paolo Cretaro
Fix compiler warnings:
vbox_mode.c:57:15: warning: variable ‘crtc_id’ set but not used
vbox_mode.c:581:25: warning: variable ‘vbox_connector’ set but not used

Signed-off-by: Paolo Cretaro 
---
 drivers/staging/vboxvideo/vbox_mode.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/vboxvideo/vbox_mode.c 
b/drivers/staging/vboxvideo/vbox_mode.c
index f2b85f3256fa..a7eea70a3804 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -54,14 +54,12 @@ static void vbox_do_modeset(struct drm_crtc *crtc,
struct vbox_crtc *vbox_crtc = to_vbox_crtc(crtc);
struct vbox_private *vbox;
int width, height, bpp, pitch;
-   unsigned int crtc_id;
u16 flags;
s32 x_offset, y_offset;
 
vbox = crtc->dev->dev_private;
width = mode->hdisplay ? mode->hdisplay : 640;
height = mode->vdisplay ? mode->vdisplay : 480;
-   crtc_id = vbox_crtc->crtc_id;
bpp = crtc->enabled ? CRTC_FB(crtc)->format->cpp[0] * 8 : 32;
pitch = crtc->enabled ? CRTC_FB(crtc)->pitches[0] : width * bpp / 8;
x_offset = vbox->single_framebuffer ? crtc->x : vbox_crtc->x_hint;
@@ -578,9 +576,6 @@ static int vbox_mode_valid(struct drm_connector *connector,
 
 static void vbox_connector_destroy(struct drm_connector *connector)
 {
-   struct vbox_connector *vbox_connector;
-
-   vbox_connector = to_vbox_connector(connector);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
kfree(connector);
-- 
2.13.3



[PATCH] iio: cros_ec: Remove unused variable

2017-09-14 Thread Paolo Cretaro
Fix gcc warning:
cros_ec_baro.c:130:25: warning: variable ‘ec_device’ set but not used

Signed-off-by: Paolo Cretaro 
---
 drivers/iio/pressure/cros_ec_baro.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/pressure/cros_ec_baro.c 
b/drivers/iio/pressure/cros_ec_baro.c
index 48b2a30f57ae..5fd32ad6c64d 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -127,7 +127,6 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
 {
struct device *dev = &pdev->dev;
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
-   struct cros_ec_device *ec_device;
struct iio_dev *indio_dev;
struct cros_ec_baro_state *state;
struct iio_chan_spec *channel;
@@ -137,7 +136,6 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
dev_warn(dev, "No CROS EC device found.\n");
return -EINVAL;
}
-   ec_device = ec_dev->ec_dev;
 
indio_dev = devm_iio_device_alloc(dev, sizeof(*state));
if (!indio_dev)
-- 
2.14.1



[PATCH] iio: adc: mxs-lradc: fix non-static symbol warnings

2017-05-31 Thread Paolo Cretaro
Fix sparse warning "symbol foo was not declared. Should it be static?"
for the following symbols:
mx23_lradc_adc_irq_names
mx28_lradc_adc_irq_names
iio_dev_attr_in_voltage0_scale_available
iio_dev_attr_in_voltage1_scale_available
iio_dev_attr_in_voltage2_scale_available
iio_dev_attr_in_voltage3_scale_available
iio_dev_attr_in_voltage4_scale_available
iio_dev_attr_in_voltage5_scale_available
iio_dev_attr_in_voltage6_scale_available
iio_dev_attr_in_voltage7_scale_available
iio_dev_attr_in_voltage10_scale_available
iio_dev_attr_in_voltage11_scale_available
iio_dev_attr_in_voltage12_scale_available
iio_dev_attr_in_voltage13_scale_available
iio_dev_attr_in_voltage14_scale_available
iio_dev_attr_in_voltage15_scale_available

Signed-off-by: Paolo Cretaro 
---
 drivers/iio/adc/mxs-lradc-adc.c | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c
index b0c7d8ee5cb8..3f955c1c14a0 100644
--- a/drivers/iio/adc/mxs-lradc-adc.c
+++ b/drivers/iio/adc/mxs-lradc-adc.c
@@ -48,7 +48,7 @@
 
 #define VREF_MV_BASE 1850
 
-const char *mx23_lradc_adc_irq_names[] = {
+static const char *mx23_lradc_adc_irq_names[] = {
"mxs-lradc-channel0",
"mxs-lradc-channel1",
"mxs-lradc-channel2",
@@ -57,7 +57,7 @@ const char *mx23_lradc_adc_irq_names[] = {
"mxs-lradc-channel5",
 };
 
-const char *mx28_lradc_adc_irq_names[] = {
+static const char *mx28_lradc_adc_irq_names[] = {
"mxs-lradc-thresh0",
"mxs-lradc-thresh1",
"mxs-lradc-channel0",
@@ -344,20 +344,20 @@ static ssize_t mxs_lradc_adc_show_scale_avail(struct 
device *dev,
IIO_DEVICE_ATTR(in_voltage##ch##_scale_available, 0444,\
mxs_lradc_adc_show_scale_avail, NULL, ch)
 
-SHOW_SCALE_AVAILABLE_ATTR(0);
-SHOW_SCALE_AVAILABLE_ATTR(1);
-SHOW_SCALE_AVAILABLE_ATTR(2);
-SHOW_SCALE_AVAILABLE_ATTR(3);
-SHOW_SCALE_AVAILABLE_ATTR(4);
-SHOW_SCALE_AVAILABLE_ATTR(5);
-SHOW_SCALE_AVAILABLE_ATTR(6);
-SHOW_SCALE_AVAILABLE_ATTR(7);
-SHOW_SCALE_AVAILABLE_ATTR(10);
-SHOW_SCALE_AVAILABLE_ATTR(11);
-SHOW_SCALE_AVAILABLE_ATTR(12);
-SHOW_SCALE_AVAILABLE_ATTR(13);
-SHOW_SCALE_AVAILABLE_ATTR(14);
-SHOW_SCALE_AVAILABLE_ATTR(15);
+static SHOW_SCALE_AVAILABLE_ATTR(0);
+static SHOW_SCALE_AVAILABLE_ATTR(1);
+static SHOW_SCALE_AVAILABLE_ATTR(2);
+static SHOW_SCALE_AVAILABLE_ATTR(3);
+static SHOW_SCALE_AVAILABLE_ATTR(4);
+static SHOW_SCALE_AVAILABLE_ATTR(5);
+static SHOW_SCALE_AVAILABLE_ATTR(6);
+static SHOW_SCALE_AVAILABLE_ATTR(7);
+static SHOW_SCALE_AVAILABLE_ATTR(10);
+static SHOW_SCALE_AVAILABLE_ATTR(11);
+static SHOW_SCALE_AVAILABLE_ATTR(12);
+static SHOW_SCALE_AVAILABLE_ATTR(13);
+static SHOW_SCALE_AVAILABLE_ATTR(14);
+static SHOW_SCALE_AVAILABLE_ATTR(15);
 
 static struct attribute *mxs_lradc_adc_attributes[] = {
&iio_dev_attr_in_voltage0_scale_available.dev_attr.attr,
-- 
2.13.0



Re: [PATCH] iio: adc: meson-saradc: use NULL instead of 0 for pointer

2017-06-06 Thread Paolo Cretaro

Il 04/06/2017 15:32, Martin Blumenstingl ha scritto:

Hi Paolo, Hi Jonathan,

On Sat, Jun 3, 2017 at 10:52 AM, Jonathan Cameron  wrote:

On Sun, 28 May 2017 23:17:57 +0200
Martin Blumenstingl  wrote:


Hi Paolo, Hi Jonathan,

On Sun, May 28, 2017 at 4:43 PM, Jonathan Cameron  wrote:

On Sun, 28 May 2017 13:24:38 +0200
Paolo Cretaro  wrote:


Fix sparse warning: Using plain integer as NULL pointer

Signed-off-by: Paolo Cretaro 

This looks fine to me, but ideally you should always try to include
the driver author - particularly in the case of patches to a recent
driver such as this one.

To that end I've cc'd Martin.

thanks for spotting this (and providing a patch to fix it)
this looks good to me, so:
Acked-by: Martin Blumenstingl 

if you can wait until next weekend then I can also test this on real hardware.

I've applied it to the togreg branch of iio.git but as that always goes out
as testing for at least a few days first (which I will happily rebase) give
me a shout if anything goes wrong!

I have tested this on actual hardware and it seems that there's a bug
in the meson-saradc driver (before and after this patch):
if there are still "old" values in the FIFO then the driver currently
crashes because regmap_read (regmap_mmio_read in case of the
meson-saradc driver to be precise) de-references the "value" pointer
(the parameter which we're trying to clean up here) -> this leads to a
NULL de-reference. this happens regardless of whether we are passing
"0" or "NULL"

I posted a patch which fixes the crash - and as a bonus this should
also fix the sparse warning reported by Paolo:
http://lists.infradead.org/pipermail/linux-amlogic/2017-June/003863.html

Nice, thanks!

Paolo



Jonathan



Jonathan

---
  drivers/iio/adc/meson_saradc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 81cd39a57fe3..fb3f67a9ae1f 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -481,7 +481,7 @@ static void meson_sar_adc_clear_fifo(struct iio_dev 
*indio_dev)
   if (!meson_sar_adc_get_fifo_count(indio_dev))
   break;

- regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
+ regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, NULL);
   }
  }





Regards,
Martin




[PATCH] iio: cros_ec: Remove unused variables

2017-11-18 Thread Paolo Cretaro
Fix gcc warnings about variable 'ec_device' being set but not used
in these files:
common/cros_ec_sensors/cros_ec_sensors.c:194:25
light/cros_ec_light_prox.c:184:25

Signed-off-by: Paolo Cretaro 
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 2 --
 drivers/iio/light/cros_ec_light_prox.c   | 2 --
 2 files changed, 4 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c 
b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index ed8063f2da99..7d30c59da3e2 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -191,7 +191,6 @@ static int cros_ec_sensors_probe(struct platform_device 
*pdev)
 {
struct device *dev = &pdev->dev;
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
-   struct cros_ec_device *ec_device;
struct iio_dev *indio_dev;
struct cros_ec_sensors_state *state;
struct iio_chan_spec *channel;
@@ -201,7 +200,6 @@ static int cros_ec_sensors_probe(struct platform_device 
*pdev)
dev_warn(&pdev->dev, "No CROS EC device found.\n");
return -EINVAL;
}
-   ec_device = ec_dev->ec_dev;
 
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*state));
if (!indio_dev)
diff --git a/drivers/iio/light/cros_ec_light_prox.c 
b/drivers/iio/light/cros_ec_light_prox.c
index b2a46b390d5c..acfad4aeb27a 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -181,7 +181,6 @@ static int cros_ec_light_prox_probe(struct platform_device 
*pdev)
 {
struct device *dev = &pdev->dev;
struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent);
-   struct cros_ec_device *ec_device;
struct iio_dev *indio_dev;
struct cros_ec_light_prox_state *state;
struct iio_chan_spec *channel;
@@ -191,7 +190,6 @@ static int cros_ec_light_prox_probe(struct platform_device 
*pdev)
dev_warn(dev, "No CROS EC device found.\n");
return -EINVAL;
}
-   ec_device = ec_dev->ec_dev;
 
indio_dev = devm_iio_device_alloc(dev, sizeof(*state));
if (!indio_dev)
-- 
2.15.0