From: "Noralf Trønnes" <noralf@tronnes.org>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: balbi@kernel.org, Greg KH <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org,
broonie@kernel.org, lee.jones@linaro.org
Subject: Re: [RFC 8/9] drm/client: Add drm_client_init_from_id() and drm_client_modeset_set()
Date: Sun, 23 Feb 2020 18:43:52 +0100 [thread overview]
Message-ID: <393a8dcf-e01b-715c-551b-5108e42ebefc@tronnes.org> (raw)
In-Reply-To: <20200217093836.GH2363188@phenom.ffwll.local>
Den 17.02.2020 10.38, skrev Daniel Vetter:
> On Sun, Feb 16, 2020 at 06:21:16PM +0100, Noralf Trønnes wrote:
>> drm_client_init_from_id() provides a way for clients to add a client based
>> on the minor. drm_client_modeset_set() provides a way to set the modeset
>> for clients that handles connectors and display mode on their own.
>>
>> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
>> ---
>> drivers/gpu/drm/drm_client.c | 37 ++++++++++++++++++++
>> drivers/gpu/drm/drm_client_modeset.c | 52 ++++++++++++++++++++++++++++
>> include/drm/drm_client.h | 4 +++
>> 3 files changed, 93 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
>> index d9a2e3695525..dbd73fe8d987 100644
>> --- a/drivers/gpu/drm/drm_client.c
>> +++ b/drivers/gpu/drm/drm_client.c
>> @@ -112,6 +112,43 @@ int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
>> }
>> EXPORT_SYMBOL(drm_client_init);
>>
>> +/**
>> + * drm_client_init_from_id - Initialise a DRM client
>> + * @minor_id: DRM minor id
>> + * @client: DRM client
>> + * @name: Client name
>> + * @funcs: DRM client functions (optional)
>> + *
>> + * This function looks up the drm_device using the minor id and initializes the client.
>> + * It also registeres the client to avoid a possible race with DRM device unregister.
>
> I think another sentence here would be good, explaining that this is for
> drivers outside of drm to expose a specific drm driver in some fashion,
> and just outright mention your use-case as an example.
>
> I'm also not sure whether lookup-by-minor is the greatest thing for
> kernel-internal lookups like this, maybe Greg has some idea?
>
What alternatives do you see? Parent device name?
I did a scan to see what others are doing, and most have a consumer name
lookup on the struct device (Device Tree or lookup tables):
struct reset_control *__reset_control_get(struct device *dev, const char
*id,
int index, bool shared,
bool optional, bool acquired);
struct iio_channel *iio_channel_get(struct device *dev,
const char *consumer_channel);
struct regulator *__must_check regulator_get(struct device *dev,
const char *id);
struct pwm_device *pwm_get(struct device *dev, const char *con_id)
struct gpio_desc *__must_check gpiod_get(struct device *dev,
const char *con_id,
enum gpiod_flags flags);
SPI and I2C use the bus index as lookup:
extern struct i2c_adapter *i2c_get_adapter(int nr);
extern struct spi_controller *spi_busnum_to_master(u16 busnum);
Noralf.
>> + *
>> + * See drm_client_init() and drm_client_register().
>> + *
>> + * Returns:
>> + * Zero on success or negative error code on failure.
>> + */
>> +int drm_client_init_from_id(unsigned int minor_id, struct drm_client_dev *client,
>> + const char *name, const struct drm_client_funcs *funcs)
>> +{
>> + struct drm_minor *minor;
>> + int ret;
>> +
>> + minor = drm_minor_acquire(minor_id);
>> + if (IS_ERR(minor))
>> + return PTR_ERR(minor);
>> +
>> + mutex_lock(&minor->dev->clientlist_mutex);
>> + ret = drm_client_init(minor->dev, client, name, funcs);
>> + if (!ret)
>> + list_add(&client->list, &minor->dev->clientlist);
>> + mutex_unlock(&minor->dev->clientlist_mutex);
>> +
>> + drm_minor_release(minor);
>> +
>> + return ret;
>> +}
>> +EXPORT_SYMBOL(drm_client_init_from_id);
>> +
>> /**
>> * drm_client_register - Register client
>> * @client: DRM client
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-02-23 17:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-16 17:21 [RFC 0/9] Regmap over USB for Multifunction USB Device (gpio, display, ...) Noralf Trønnes
2020-02-16 17:21 ` [RFC 1/9] regmap: Add USB support Noralf Trønnes
2020-02-17 12:11 ` Mark Brown
2020-02-17 21:33 ` Noralf Trønnes
2020-02-17 21:39 ` Mark Brown
2020-02-17 22:15 ` Noralf Trønnes
2020-02-17 22:44 ` Mark Brown
2020-02-16 17:21 ` [RFC 2/9] mfd: Add driver for Multifunction USB Device Noralf Trønnes
2020-02-27 9:09 ` Lee Jones
2020-02-29 13:26 ` Noralf Trønnes
2020-02-29 16:02 ` Alan Stern
2020-02-16 17:21 ` [RFC 3/9] usb: gadget: function: Add Multifunction USB Device support Noralf Trønnes
2020-02-16 17:21 ` [RFC 4/9] pinctrl: Add Multifunction USB Device pinctrl driver Noralf Trønnes
2020-02-16 17:21 ` [RFC 5/9] usb: gadget: function: mud: Add gpio support Noralf Trønnes
2020-02-16 17:21 ` [RFC 6/9] regmap: Speed up _regmap_raw_write_impl() for large buffers Noralf Trønnes
2020-02-17 12:15 ` Mark Brown
2020-02-16 17:21 ` [RFC 7/9] drm: Add Multifunction USB Device display driver Noralf Trønnes
2020-02-16 17:21 ` [RFC 8/9] drm/client: Add drm_client_init_from_id() and drm_client_modeset_set() Noralf Trønnes
2020-02-17 9:38 ` Daniel Vetter
2020-02-23 17:43 ` Noralf Trønnes [this message]
2020-02-23 20:59 ` Daniel Vetter
2020-02-16 17:21 ` [RFC 9/9] usb: gadget: function: mud: Add display support Noralf Trønnes
2020-02-17 9:40 ` [RFC 0/9] Regmap over USB for Multifunction USB Device (gpio, display, ...) Daniel Vetter
2020-02-17 10:32 ` Neil Armstrong
2020-02-17 14:05 ` Noralf Trønnes
2020-02-18 20:57 ` Andy Shevchenko
2020-02-18 21:31 ` Noralf Trønnes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=393a8dcf-e01b-715c-551b-5108e42ebefc@tronnes.org \
--to=noralf@tronnes.org \
--cc=balbi@kernel.org \
--cc=broonie@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).