Re: [PATCH v4 14/23] drm/tilcdc: Provide ddc symlink in connector sysfs directory

From: Thomas Zimmermann
Date: Wed Jul 24 2019 - 04:01:18 EST


Hi

Am 23.07.19 um 14:44 schrieb Andrzej Pietrasiewicz:
> Hi Sam,
>
> W dniu 23.07.2019 oÂ11:05, Sam Ravnborg pisze:
>> Hi Andrzej
>>
>> On Thu, Jul 11, 2019 at 01:26:41PM +0200, Andrzej Pietrasiewicz wrote:
>>> Use the ddc pointer provided by the generic connector.
>>>
>>> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxxxx>
>>> ---
>>> Â drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 1 +
>>> Â 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
>>> b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
>>> index 62d014c20988..c373edb95666 100644
>>> --- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
>>> +++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
>>> @@ -219,6 +219,7 @@ static struct drm_connector
>>> *tfp410_connector_create(struct drm_device *dev,
>>> ÂÂÂÂÂ tfp410_connector->mod = mod;
>>> Â ÂÂÂÂÂ connector = &tfp410_connector->base;
>>> +ÂÂÂ connector->ddc = mod->i2c;
>>> Â ÂÂÂÂÂ drm_connector_init(dev, connector, &tfp410_connector_funcs,
>>> ÂÂÂÂÂÂÂÂÂÂÂÂÂ DRM_MODE_CONNECTOR_DVID);
>>
>> When reading this code, it looks strange that we set connector->ddc
>> *before* the call to init the connector.
>> One could risk that drm_connector_init() used memset(..) to clear all
>> fields or so, and it would break this order.
>
> I verified the code of drm_connector_init() and cannot find any memset()
> invocations there. What is your actual concern?

I think this echoes my concern about the implicit order of operation. It
seems too easy to get this wrong. If you don't want to add an additional
interface for setting the ddc field, why not add a dedicated initializer
function that sets the ddc field? Something like this.

int drm_connector_init_with_ddc(connector, funcs, ..., ddc)
{
ret = drm_connector_init(connector, funcs, ...);
if (ret)
return ret;

if (!ddc)
return 0;

connector->ddc = ddc;
/* set up sysfs */

return 0;
}

Best regards
Thomas

> Andrzej
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix ImendÃrffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG NÃrnberg)

Attachment: signature.asc
Description: OpenPGP digital signature