Skip to contentSkip to conversation

drm: encoder_slave: some updates

PATCH In review Wolfram Sang 2 participants 6 messages Mar 16, 2020 – May 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm: encoder_slave: some updates

While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.

Based on linux-next and only build tested.

Wolfram Sang (2):
drm: encoder_slave: fix refcouting error for modules
drm: encoder_slave: use new I2C API

 drivers/gpu/drm/drm_encoder_slave.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/2 drm: encoder_slave: fix refcouting error for modules

module_put() balances try_module_get(), not request_module(). Fix the error path to match that.

Fixes 2066facca4c7 ("drm/kms: slave encoder interface.")
---
 drivers/gpu/drm/drm_encoder_slave.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_encoder_slave.c +3 -2
index cf804389f5ec..d50a7884e69e 100644
@@ -84,7 +84,7 @@ int drm_i2c_encoder_init(struct drm_device *dev,
 
 	err = encoder_drv->encoder_init(client, dev, encoder);
 	if (err)
-		goto fail_unregister;
+		goto fail_module_put;
 
 	if (info->platform_data)
 		encoder->slave_funcs->set_config(&encoder->base,
@@ -92,9 +92,10 @@ int drm_i2c_encoder_init(struct drm_device *dev,
 
 	return 0;
 
+fail_module_put:
+	module_put(module);
 fail_unregister:
 	i2c_unregister_device(client);
-	module_put(module);
 fail:
 	return err;
 }
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/2 drm: encoder_slave: use new I2C API

In reply to Wolfram Sang

i2c_new_client() is deprecated, use the replacement i2c_new_client_device(). Also, we have a helper to check if a driver is bound. Use it to simplify the code. Note that this changes the errno for a failed device creation from ENOMEM to ENODEV. No callers currently interpret this errno, though, so we use this condensed error check.

---
 drivers/gpu/drm/drm_encoder_slave.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_encoder_slave.c +2 -8
index d50a7884e69e..e464429d32df 100644
@@ -61,13 +61,8 @@ int drm_i2c_encoder_init(struct drm_device *dev,
 
 	request_module("%s%s", I2C_MODULE_PREFIX, info->type);
 
-	client = i2c_new_device(adap, info);
-	if (!client) {
-		err = -ENOMEM;
-		goto fail;
-	}
-
-	if (!client->dev.driver) {
+	client = i2c_new_client_device(adap, info);
+	if (!i2c_client_has_driver(client)) {
 		err = -ENODEV;
 		goto fail_unregister;
 	}
@@ -96,7 +91,6 @@ int drm_i2c_encoder_init(struct drm_device *dev,
 	module_put(module);
 fail_unregister:
 	i2c_unregister_device(client);
-fail:
 	return err;
 }
 EXPORT_SYMBOL(drm_i2c_encoder_init);
Signature · 1 line
2.20.1
#3 lore raw
In reply to Wolfram Sang
Quoted 4 lines · Wolfram Sang

While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.

Quoted 8 lines

Based on linux-next and only build tested.

Wolfram Sang (2):
drm: encoder_slave: fix refcouting error for modules
drm: encoder_slave: use new I2C API

 drivers/gpu/drm/drm_encoder_slave.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Is there someone I should add to the CC list maybe?

Reviewed-by
#4 lore raw

Hi Wolfram,

Quoted 8 lines · Wolfram Sang
Quoted 6 lines · Wolfram Sang

While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.

Based on linux-next and only build tested.

Quoted 9 lines
Quoted 6 lines

Wolfram Sang (2):
drm: encoder_slave: fix refcouting error for modules
drm: encoder_slave: use new I2C API

 drivers/gpu/drm/drm_encoder_slave.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Is there someone I should add to the CC list maybe?

The series is:

Unless someone beats me to it, I'll commit them to drm-misc later today.

-Emil

#5 lore raw
Quoted 20 lines · Emil Velikov

Hi Wolfram,

Quoted 15 lines · Wolfram Sang
Quoted 12 lines · Wolfram Sang

While converting I2C users to new APIs, I found a refcounting problem in the encoder_slave implementation. This series fixes it and converts to the new API.

Based on linux-next and only build tested.

Wolfram Sang (2):
drm: encoder_slave: fix refcouting error for modules
drm: encoder_slave: use new I2C API

 drivers/gpu/drm/drm_encoder_slave.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Quoted 7 lines
Quoted 2 lines

Is there someone I should add to the CC list maybe?

The series is:

Unless someone beats me to it, I'll commit them to drm-misc later today.

And after a short delay, pushed to drm-misc-next.
Thanks for the patches Wolfram.

-Emil