diff mbox series

[v8,3/7] iio: accel: kionix-kx022a: Warn on failed matches and assume compatibility

Message ID 2c69e918cb6dfab663bb62952c554b6b72f58390.1692824815.git.mehdi.djait.k@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series iio: accel: Add support for Kionix/ROHM KX132-1211 accelerometer | expand

Commit Message

Mehdi Djait Aug. 23, 2023, 9:16 p.m. UTC
Avoid error returns on a failure to match and instead just warn with
assumption that we have a correct dt-binding telling us that
some new device with a different ID is backwards compatible.

Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
---
v8:
v7:
v6:
v5:
v4:
- no changes

v3:
- changed from 'unsupported' to 'unknown'
- removed the opening bracket

v2:
- no changes, this patch is introduced in the v2

 drivers/iio/accel/kionix-kx022a.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko Aug. 24, 2023, 11:51 a.m. UTC | #1
On Wed, Aug 23, 2023 at 11:16:37PM +0200, Mehdi Djait wrote:
> Avoid error returns on a failure to match and instead just warn with
> assumption that we have a correct dt-binding telling us that
> some new device with a different ID is backwards compatible.

As we already discussed in the past I think this patch might be
not okay in case a hardware vendor decides to make incompatible
device with non-supported yet ID. It might be even harmful to
the hardware to program register without knowing that this is safe.

That said, I'm neither NAKing nor reviewing this and leave to
maintainers to decide.
Jonathan Cameron Aug. 27, 2023, 5:57 p.m. UTC | #2
On Thu, 24 Aug 2023 14:51:49 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Wed, Aug 23, 2023 at 11:16:37PM +0200, Mehdi Djait wrote:
> > Avoid error returns on a failure to match and instead just warn with
> > assumption that we have a correct dt-binding telling us that
> > some new device with a different ID is backwards compatible.  
> 
> As we already discussed in the past I think this patch might be
> not okay in case a hardware vendor decides to make incompatible
> device with non-supported yet ID. It might be even harmful to
> the hardware to program register without knowing that this is safe.

That only matters if they 'claim' it is compatible. Otherwise the
driver never probes and we are fine.

DT maintainers view was that the job of the kernel was not to defend
against bugs in device tree firmwares or someone binding the driver
to the wrong device by hand.

> 
> That said, I'm neither NAKing nor reviewing this and leave to
> maintainers to decide.
>
diff mbox series

Patch

diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
index ff8aa7b9568e..494e81ba1da9 100644
--- a/drivers/iio/accel/kionix-kx022a.c
+++ b/drivers/iio/accel/kionix-kx022a.c
@@ -1036,10 +1036,8 @@  int kx022a_probe_internal(struct device *dev)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to access sensor\n");
 
-	if (chip_id != KX022A_ID) {
-		dev_err(dev, "unsupported device 0x%x\n", chip_id);
-		return -EINVAL;
-	}
+	if (chip_id != KX022A_ID)
+		dev_warn(dev, "unknown device 0x%x\n", chip_id);
 
 	irq = fwnode_irq_get_byname(fwnode, "INT1");
 	if (irq > 0) {