From: Mark Brown <broonie@kernel.org>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: balbi@kernel.org, linux-usb@vger.kernel.org,
lee.jones@linaro.org, dri-devel@lists.freedesktop.org
Subject: Re: [RFC 1/9] regmap: Add USB support
Date: Mon, 17 Feb 2020 12:11:49 +0000 [thread overview]
Message-ID: <20200217121149.GB9304@sirena.org.uk> (raw)
In-Reply-To: <20200216172117.49832-2-noralf@tronnes.org>
[-- Attachment #1.1: Type: text/plain, Size: 2996 bytes --]
On Sun, Feb 16, 2020 at 06:21:09PM +0100, Noralf Trønnes wrote:
> Add support for regmap over USB for use with the Multifunction USB Device.
> Two endpoints IN/OUT are used. Up to 255 regmaps are supported on one USB
> interface. The register index width is always 32-bit, but the register
> value can be 8, 16 or 32 bits wide. LZ4 compression is supported on bulk
> transfers.
This looks like a custom thing for some particular devices rather than a
thing that will work for any USB device? If that is the case then this
should have a more specific name.
> +++ b/drivers/base/regmap/regmap-usb.c
> @@ -0,0 +1,1026 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Register map access API - USB support
Why is this GPL-2.0-or-later? The rest of the code is just plain old
GPL-2.0.
Please also make the entire comment a C++ one so things look more
intentional.
> +
> + ktime_t start; /* FIXME: Temporary debug/perf aid */
Add tracepoints, most of your debugging stuff looks like you want to use
tracepoints - you can easily work out time differences with them by
postprocessing the log, they get very fine grained timestamps.
> + mutex_lock(®map_usb_interfaces_lock);
> + list_for_each_entry(entry, ®map_usb_interfaces, link)
> + if (entry->interface == interface) {
> + ruif = entry;
> + ruif->refcount++;
> + goto out_unlock;
> + }
> +
You're missing some { } here.
> +static long mud_drm_throughput(ktime_t begin, ktime_t end, size_t len)
> +{
> + long throughput;
> +
> + throughput = ktime_us_delta(end, begin);
> + throughput = throughput ? (len * 1000) / throughput : 0;
> + throughput = throughput * 1000 / 1024;
Please write normal conditional statements to improve legibility.
> +static int regmap_usb_gather_write(void *context,
> + const void *reg, size_t reg_len,
> + const void *val, size_t val_len)
> +{
> + return regmap_usb_transfer(context, false, reg, (void *)val, val_len);
> +}
Why are we casting away a const here? If we really need to modify the
raw data that's being transmitted take a copy.
> +static int regmap_usb_write(void *context, const void *data, size_t count)
> +{
> + struct regmap_usb_context *ctx = context;
> + size_t val_len = count - sizeof(u32);
> + void *val;
> + int ret;
> +
> + /* buffer needs to be properly aligned for DMA use */
> + val = kmemdup(data + sizeof(u32), val_len, GFP_KERNEL);
> + if (!val)
> + return -ENOMEM;
> +
> + ret = regmap_usb_gather_write(ctx, data, sizeof(u32), val, val_len);
> + kfree(val);
> +
> + return ret;
> +}
This looks like you just don't support a straight write operation, if
you need to do this emulation push it up the stack.
> + regmap_usb_debugfs_init(map);
> +
> + return map;
> +}
> +EXPORT_SYMBOL(__devm_regmap_init_usb);
No, this needs to be EXPORT_SYMBOL_GPL - the regmap core is and this
isn't going to be useful without those bits of the code anyway.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
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-17 12:11 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 [this message]
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
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=20200217121149.GB9304@sirena.org.uk \
--to=broonie@kernel.org \
--cc=balbi@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee.jones@linaro.org \
--cc=linux-usb@vger.kernel.org \
--cc=noralf@tronnes.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).