diff mbox series

[v2,27/28] media: ov2680: Read and log sensor revision during probe

Message ID 20230615141349.172363-28-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show
Series media: ov2680: Bugfixes + ACPI + selection(crop-tgt) API support | expand

Commit Message

Hans de Goede June 15, 2023, 2:13 p.m. UTC
Read and log sensor revision during probe.

Since this means that the driver will now already log a message on
successful probe drop the "ov2680 init correctly" log message.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/media/i2c/ov2680.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Andy Shevchenko June 15, 2023, 2:43 p.m. UTC | #1
On Thu, Jun 15, 2023 at 04:13:48PM +0200, Hans de Goede wrote:
> Read and log sensor revision during probe.
> 
> Since this means that the driver will now already log a message on
> successful probe drop the "ov2680 init correctly" log message.

...

> -	ret = cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, NULL);
> +	cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, &ret);
> +	cci_read(sensor->regmap, OV2680_REG_SC_CMMN_SUB_ID, &rev, &ret);
>  	if (ret < 0) {
>  		dev_err(sensor->dev, "failed to read chip id\n");
>  		return -ENODEV;

Even in the original code I don't see justification why the error code should
be shadowed.
Hans de Goede June 16, 2023, 5:30 p.m. UTC | #2
Hi,

On 6/15/23 16:43, Andy Shevchenko wrote:
> On Thu, Jun 15, 2023 at 04:13:48PM +0200, Hans de Goede wrote:
>> Read and log sensor revision during probe.
>>
>> Since this means that the driver will now already log a message on
>> successful probe drop the "ov2680 init correctly" log message.
> 
> ...
> 
>> -	ret = cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, NULL);
>> +	cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, &ret);
>> +	cci_read(sensor->regmap, OV2680_REG_SC_CMMN_SUB_ID, &rev, &ret);
>>  	if (ret < 0) {
>>  		dev_err(sensor->dev, "failed to read chip id\n");
>>  		return -ENODEV;
> 
> Even in the original code I don't see justification why the error code should
> be shadowed.


Ack, I've squashed a fix for this into this patch (since it is already
making significant changes to ov2680_check_id() anways),

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 4b8561dc3111..b1107fd984a4 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -33,6 +33,7 @@ 
 #define OV2680_REG_SOFT_RESET			CCI_REG8(0x0103)
 
 #define OV2680_REG_CHIP_ID			CCI_REG16(0x300a)
+#define OV2680_REG_SC_CMMN_SUB_ID		CCI_REG8(0x302a)
 #define OV2680_REG_PLL_MULTIPLIER		CCI_REG16(0x3081)
 
 #define OV2680_REG_EXPOSURE_PK			CCI_REG24(0x3500)
@@ -941,10 +942,11 @@  static int ov2680_get_regulators(struct ov2680_dev *sensor)
 
 static int ov2680_check_id(struct ov2680_dev *sensor)
 {
-	u64 chip_id;
-	int ret;
+	u64 chip_id, rev;
+	int ret = 0;
 
-	ret = cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, NULL);
+	cci_read(sensor->regmap, OV2680_REG_CHIP_ID, &chip_id, &ret);
+	cci_read(sensor->regmap, OV2680_REG_SC_CMMN_SUB_ID, &rev, &ret);
 	if (ret < 0) {
 		dev_err(sensor->dev, "failed to read chip id\n");
 		return -ENODEV;
@@ -956,6 +958,9 @@  static int ov2680_check_id(struct ov2680_dev *sensor)
 		return -ENODEV;
 	}
 
+	dev_info(sensor->dev, "sensor_revision id = 0x%llx, rev= %lld\n",
+		 chip_id, rev & 0x0f);
+
 	return 0;
 }
 
@@ -1094,8 +1099,6 @@  static int ov2680_probe(struct i2c_client *client)
 	pm_runtime_use_autosuspend(&client->dev);
 	pm_runtime_put_autosuspend(&client->dev);
 
-	dev_info(dev, "ov2680 init correctly\n");
-
 	return 0;
 
 err_pm_runtime: