diff mbox

[v2,06/13] iio: health: max30102: Add check for part ID

Message ID 1509133543-4597-7-git-send-email-pmeerw@pmeerw.net
State New, archived
Headers show

Commit Message

Peter Meerwald-Stadler Oct. 27, 2017, 7:45 p.m. UTC
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/health/max30102.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Matt Ranostay Nov. 19, 2017, 8:38 p.m. UTC | #1
On Fri, Oct 27, 2017 at 12:45 PM, Peter Meerwald-Stadler
<pmeerw@pmeerw.net> wrote:
> Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>


Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> ---
>  drivers/iio/health/max30102.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
> index 389a483..c43957e 100644
> --- a/drivers/iio/health/max30102.c
> +++ b/drivers/iio/health/max30102.c
> @@ -32,6 +32,7 @@
>
>  #define MAX30102_REGMAP_NAME   "max30102_regmap"
>  #define MAX30102_DRV_NAME      "max30102"
> +#define MAX30102_PART_NUMBER   0x15
>
>  #define MAX30102_REG_INT_STATUS                        0x00
>  #define MAX30102_REG_INT_STATUS_PWR_RDY                BIT(0)
> @@ -83,6 +84,9 @@
>  #define MAX30102_REG_TEMP_INTEGER              0x1f
>  #define MAX30102_REG_TEMP_FRACTION             0x20
>
> +#define MAX30102_REG_REV_ID                    0xfe
> +#define MAX30102_REG_PART_ID                   0xff
> +
>  struct max30102_data {
>         struct i2c_client *client;
>         struct iio_dev *indio_dev;
> @@ -391,6 +395,7 @@ static int max30102_probe(struct i2c_client *client,
>         struct iio_buffer *buffer;
>         struct iio_dev *indio_dev;
>         int ret;
> +       unsigned int reg;
>
>         indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
>         if (!indio_dev)
> @@ -424,6 +429,19 @@ static int max30102_probe(struct i2c_client *client,
>                 return PTR_ERR(data->regmap);
>         }
>
> +       /* check part ID */
> +       ret = regmap_read(data->regmap, MAX30102_REG_PART_ID, &reg);
> +       if (ret)
> +               return ret;
> +       if (reg != MAX30102_PART_NUMBER)
> +               return -ENODEV;
> +
> +       /* show revision ID */
> +       ret = regmap_read(data->regmap, MAX30102_REG_REV_ID, &reg);
> +       if (ret)
> +               return ret;
> +       dev_dbg(&client->dev, "max3010x revision %02x\n", reg);
> +
>         ret = max30102_set_powermode(data, false);
>         if (ret)
>                 return ret;
> --
> 2.7.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Cameron Nov. 25, 2017, 2:11 p.m. UTC | #2
On Sun, 19 Nov 2017 12:38:50 -0800
Matt Ranostay <matt.ranostay@konsulko.com> wrote:

> On Fri, Oct 27, 2017 at 12:45 PM, Peter Meerwald-Stadler
> <pmeerw@pmeerw.net> wrote:
> > Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
> > Cc: Matt Ranostay <matt.ranostay@konsulko.com>  
> 
> 
> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
> 
Applied.
> > ---
> >  drivers/iio/health/max30102.c | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
> > index 389a483..c43957e 100644
> > --- a/drivers/iio/health/max30102.c
> > +++ b/drivers/iio/health/max30102.c
> > @@ -32,6 +32,7 @@
> >
> >  #define MAX30102_REGMAP_NAME   "max30102_regmap"
> >  #define MAX30102_DRV_NAME      "max30102"
> > +#define MAX30102_PART_NUMBER   0x15
> >
> >  #define MAX30102_REG_INT_STATUS                        0x00
> >  #define MAX30102_REG_INT_STATUS_PWR_RDY                BIT(0)
> > @@ -83,6 +84,9 @@
> >  #define MAX30102_REG_TEMP_INTEGER              0x1f
> >  #define MAX30102_REG_TEMP_FRACTION             0x20
> >
> > +#define MAX30102_REG_REV_ID                    0xfe
> > +#define MAX30102_REG_PART_ID                   0xff
> > +
> >  struct max30102_data {
> >         struct i2c_client *client;
> >         struct iio_dev *indio_dev;
> > @@ -391,6 +395,7 @@ static int max30102_probe(struct i2c_client *client,
> >         struct iio_buffer *buffer;
> >         struct iio_dev *indio_dev;
> >         int ret;
> > +       unsigned int reg;
> >
> >         indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> >         if (!indio_dev)
> > @@ -424,6 +429,19 @@ static int max30102_probe(struct i2c_client *client,
> >                 return PTR_ERR(data->regmap);
> >         }
> >
> > +       /* check part ID */
> > +       ret = regmap_read(data->regmap, MAX30102_REG_PART_ID, &reg);
> > +       if (ret)
> > +               return ret;
> > +       if (reg != MAX30102_PART_NUMBER)
> > +               return -ENODEV;
> > +
> > +       /* show revision ID */
> > +       ret = regmap_read(data->regmap, MAX30102_REG_REV_ID, &reg);
> > +       if (ret)
> > +               return ret;
> > +       dev_dbg(&client->dev, "max3010x revision %02x\n", reg);
> > +
> >         ret = max30102_set_powermode(data, false);
> >         if (ret)
> >                 return ret;
> > --
> > 2.7.4
> >  

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c
index 389a483..c43957e 100644
--- a/drivers/iio/health/max30102.c
+++ b/drivers/iio/health/max30102.c
@@ -32,6 +32,7 @@ 
 
 #define MAX30102_REGMAP_NAME	"max30102_regmap"
 #define MAX30102_DRV_NAME	"max30102"
+#define MAX30102_PART_NUMBER	0x15
 
 #define MAX30102_REG_INT_STATUS			0x00
 #define MAX30102_REG_INT_STATUS_PWR_RDY		BIT(0)
@@ -83,6 +84,9 @@ 
 #define MAX30102_REG_TEMP_INTEGER		0x1f
 #define MAX30102_REG_TEMP_FRACTION		0x20
 
+#define MAX30102_REG_REV_ID			0xfe
+#define MAX30102_REG_PART_ID			0xff
+
 struct max30102_data {
 	struct i2c_client *client;
 	struct iio_dev *indio_dev;
@@ -391,6 +395,7 @@  static int max30102_probe(struct i2c_client *client,
 	struct iio_buffer *buffer;
 	struct iio_dev *indio_dev;
 	int ret;
+	unsigned int reg;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
@@ -424,6 +429,19 @@  static int max30102_probe(struct i2c_client *client,
 		return PTR_ERR(data->regmap);
 	}
 
+	/* check part ID */
+	ret = regmap_read(data->regmap, MAX30102_REG_PART_ID, &reg);
+	if (ret)
+		return ret;
+	if (reg != MAX30102_PART_NUMBER)
+		return -ENODEV;
+
+	/* show revision ID */
+	ret = regmap_read(data->regmap, MAX30102_REG_REV_ID, &reg);
+	if (ret)
+		return ret;
+	dev_dbg(&client->dev, "max3010x revision %02x\n", reg);
+
 	ret = max30102_set_powermode(data, false);
 	if (ret)
 		return ret;