Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp767616imm; Tue, 15 May 2018 08:54:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJobGuAHJ5EYeYTQowMTjUUVgZjBE5O61RVyzL0vr95QR1P05lkCoNvZNjVOnXXDhMvsAm X-Received: by 2002:a63:6196:: with SMTP id v144-v6mr12922442pgb.264.1526399664753; Tue, 15 May 2018 08:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526399664; cv=none; d=google.com; s=arc-20160816; b=SHzo8nx8nfkjAskkh+UsEhKI2/9cudRrvibW6AO8oBnpOwy2JvZLuKT7h41kPL9y6i BnvcnDuDoV+W42J7z056Pf6l4PLK0zO4QzHXdHjZgdM1pusRPFdOm1NsRymHaMhAB7nc unq9DM3HK6EnqoB7aJZ0luGNrqOsU2Dw7CLvvnCDacfvvBaJcHyteBdy1hJYyWeFhnE/ Q8zbnV/t/efNq6khzL5twtUhludeMv9A9Uv6R6CxuDuKLAMqcBAQfpm3qL/PInNfXCpw 3uOyGd8BmHmfat3A2KSxMHBZ5JrSAeIo7OIoLKrpodhVu78e0Af0/oPmut7EOqdMA1eg gVVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=D96p0nwPCmoTGvk2wQrkGavLOIE8cI8CyA9zrmtoEm8=; b=d100nrNwNVdBIxNhrLaWpYezEdr5A9dDwwA0O7BqBf42+1z2KIuucysfdGZMGCVgYN qbdWP2hBLEb5jdyLHe9rU6tv0jjvvEaOmJyaEM35EAG59+5/bzGW9yIxrzvSdbcGc4vC ecBBfNSvXBpIT1Np9vUvmNA/7mi+MtX8pTntQV0oROf2ThTUmaIfAvMsPTMTT/G4vLM6 aZcKPbGCpuNLdqXQAoFFUZIZ6ZU64HGaaWKFtcjXDbmfvhbFWxbH/a68czalaT9sFHMM wN+DHqj9I6qA5/CvGpQCxrf7wy2vw1VYVMef5w/2XIHne4NAbN/bibmo996iQEyXVfMo W3FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10-v6si271035pgq.148.2018.05.15.08.54.10; Tue, 15 May 2018 08:54:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753903AbeEOPXD (ORCPT + 99 others); Tue, 15 May 2018 11:23:03 -0400 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:58365 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752319AbeEOPXB (ORCPT ); Tue, 15 May 2018 11:23:01 -0400 Received: from [192.168.2.10] ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id IbmwfBQiJ8U07Ibn0fJVC2; Tue, 15 May 2018 17:23:00 +0200 Subject: Re: [PATCH v2 1/5] media: cec-notifier: Get notifier by device and connector name To: Neil Armstrong , airlied@linux.ie, hans.verkuil@cisco.com, lee.jones@linaro.org, olof@lixom.net, seanpaul@google.com Cc: sadolfsson@google.com, felixe@google.com, bleung@google.com, darekm@google.com, marcheu@chromium.org, fparent@baylibre.com, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1526395342-15481-1-git-send-email-narmstrong@baylibre.com> <1526395342-15481-2-git-send-email-narmstrong@baylibre.com> From: Hans Verkuil Message-ID: <309fa9b4-0c0b-25af-31a3-84fe5fc00743@xs4all.nl> Date: Tue, 15 May 2018 17:22:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1526395342-15481-2-git-send-email-narmstrong@baylibre.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfPNjx/0/0WMbqV2ITBrCa4SvB7NHM0uiuZUwNYFSyMCyX4bTXaW4WKZUTlUaMhHcBCbhIVoO6nx+OJ9s5Ii3kpcuXi+mgh+2uQqN2nd5UWJFrHgiCemY +8b6d4NMG0/s1YpivU/t7hqYxkfAiNQO701UTM22QGwFx6tcn3tj4DF27TtbMnZipjXxolbPxFgd5dTA9luD4pkUn1wQdPyUaXjA5+vhV2T3GtPXwQp0sM68 FzmPMBhrziFn4N1BZShID4f9Xs0Op+9AUMpkYBvQm3Zf2ZAkfLxRp5XYnEqLXkxTZbKaIlsMKk4qeSUdYFCRCMvQIkkevjZEFbRKWM07AbUYNg8J1dNBpHve rF0g/TtFRTwlNEfT6wHvTlUcK/xwJqNKviP4ZT0Rs6rUenUPqUfaxSemku74olKXpmyZtY3yJMJREs3HzKKMjjtIokBXdK2+x+NKQHVcwGnP4zdgV9AKG6Mk AMYRgoRs8EqO3rSlN0aHR1BRX22oqRqoyqT/hWH1+nSR8GQvBld/2mW7XYek86dsIE0dlx1PnJHI9+uFIWVNDrKPRWBBxYzKwQhwHZijVMixC0kdJPv99uUO p5kjI+7NMD6ByN/BrzqlduhtJM1dlpDDgkQHkzeQXfVBk1BjKW14Hsgyj1kU7YSL3EAJfOoCwCrbiFSv/KAHgx2355yRt1xwTXKFX5/wa70+TJIyTGynQKxN fhqimyJxtmI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/15/2018 04:42 PM, Neil Armstrong wrote: > In non device-tree world, we can need to get the notifier by the driver > name directly and eventually defer probe if not yet created. > > This patch adds a variant of the get function by using the device name > instead and will not create a notifier if not yet created. > > But the i915 driver exposes at least 2 HDMI connectors, this patch also > adds the possibility to add a connector name tied to the notifier device > to form a tuple and associate different CEC controllers for each HDMI > connectors. The patch looks good, but I'm curious about this paragraph above. Was this tested with devices with more than one HDMI output? Or only on laptops with a single physical HDMI output? If there are two or more outputs then I guess it is the HW designer that decides with output gets CEC support? Regards, Hans > > Signed-off-by: Neil Armstrong > --- > drivers/media/cec/cec-notifier.c | 11 ++++++++--- > include/media/cec-notifier.h | 27 ++++++++++++++++++++++++--- > 2 files changed, 32 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/cec/cec-notifier.c b/drivers/media/cec/cec-notifier.c > index 16dffa0..dd2078b 100644 > --- a/drivers/media/cec/cec-notifier.c > +++ b/drivers/media/cec/cec-notifier.c > @@ -21,6 +21,7 @@ struct cec_notifier { > struct list_head head; > struct kref kref; > struct device *dev; > + const char *conn; > struct cec_adapter *cec_adap; > void (*callback)(struct cec_adapter *adap, u16 pa); > > @@ -30,13 +31,14 @@ struct cec_notifier { > static LIST_HEAD(cec_notifiers); > static DEFINE_MUTEX(cec_notifiers_lock); > > -struct cec_notifier *cec_notifier_get(struct device *dev) > +struct cec_notifier *cec_notifier_get_conn(struct device *dev, const char *conn) > { > struct cec_notifier *n; > > mutex_lock(&cec_notifiers_lock); > list_for_each_entry(n, &cec_notifiers, head) { > - if (n->dev == dev) { > + if (n->dev == dev && > + (!conn || !strcmp(n->conn, conn))) { > kref_get(&n->kref); > mutex_unlock(&cec_notifiers_lock); > return n; > @@ -46,6 +48,8 @@ struct cec_notifier *cec_notifier_get(struct device *dev) > if (!n) > goto unlock; > n->dev = dev; > + if (conn) > + n->conn = kstrdup(conn, GFP_KERNEL); > n->phys_addr = CEC_PHYS_ADDR_INVALID; > mutex_init(&n->lock); > kref_init(&n->kref); > @@ -54,7 +58,7 @@ struct cec_notifier *cec_notifier_get(struct device *dev) > mutex_unlock(&cec_notifiers_lock); > return n; > } > -EXPORT_SYMBOL_GPL(cec_notifier_get); > +EXPORT_SYMBOL_GPL(cec_notifier_get_conn); > > static void cec_notifier_release(struct kref *kref) > { > @@ -62,6 +66,7 @@ static void cec_notifier_release(struct kref *kref) > container_of(kref, struct cec_notifier, kref); > > list_del(&n->head); > + kfree(n->conn); > kfree(n); > } > > diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h > index cf0add7..814eeef 100644 > --- a/include/media/cec-notifier.h > +++ b/include/media/cec-notifier.h > @@ -20,8 +20,10 @@ struct cec_notifier; > #if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER) > > /** > - * cec_notifier_get - find or create a new cec_notifier for the given device. > + * cec_notifier_get_conn - find or create a new cec_notifier for the given > + * device and connector tuple. > * @dev: device that sends the events. > + * @conn: the connector name from which the event occurs > * > * If a notifier for device @dev already exists, then increase the refcount > * and return that notifier. > @@ -31,7 +33,8 @@ struct cec_notifier; > * > * Return NULL if the memory could not be allocated. > */ > -struct cec_notifier *cec_notifier_get(struct device *dev); > +struct cec_notifier *cec_notifier_get_conn(struct device *dev, > + const char *conn); > > /** > * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. > @@ -85,7 +88,8 @@ void cec_register_cec_notifier(struct cec_adapter *adap, > struct cec_notifier *notifier); > > #else > -static inline struct cec_notifier *cec_notifier_get(struct device *dev) > +static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, > + const char *conn) > { > /* A non-NULL pointer is expected on success */ > return (struct cec_notifier *)0xdeadfeed; > @@ -121,6 +125,23 @@ static inline void cec_register_cec_notifier(struct cec_adapter *adap, > #endif > > /** > + * cec_notifier_get - find or create a new cec_notifier for the given device. > + * @dev: device that sends the events. > + * > + * If a notifier for device @dev already exists, then increase the refcount > + * and return that notifier. > + * > + * If it doesn't exist, then allocate a new notifier struct and return a > + * pointer to that new struct. > + * > + * Return NULL if the memory could not be allocated. > + */ > +static inline struct cec_notifier *cec_notifier_get(struct device *dev) > +{ > + return cec_notifier_get_conn(dev, NULL); > +} > + > +/** > * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID > * > * @n: the CEC notifier >