public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Brugger <mbrugger@suse.com>
To: Charles Mirabile <cmirabil@redhat.com>, linux-kernel@vger.kernel.org
Cc: Miguel Ojeda <ojeda@kernel.org>,
	Serge Schneider <serge@raspberrypi.org>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Nicolas Saenz Julienne <nsaenzju@redhat.com>,
	linux-rpi-kernel@lists.infradead.org,
	fedora-rpi@googlegroups.com, Mwesigwa Guma <mguma@redhat.com>,
	Joel Savitz <jsavitz@redhat.com>
Subject: Re: [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver
Date: Wed, 3 Nov 2021 17:47:37 +0100	[thread overview]
Message-ID: <704e71ce-e6c6-6492-8f20-47e4fad8cc39@suse.com> (raw)
In-Reply-To: <20211029215516.801593-4-cmirabil@redhat.com>



On 29/10/2021 23:55, Charles Mirabile wrote:
> This patch implements control of the 8x8 RGB LED matrix display.
> 
> Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
> Signed-off-by: Mwesigwa Guma <mguma@redhat.com>
> Signed-off-by: Joel Savitz <jsavitz@redhat.com>
> ---
>   drivers/auxdisplay/Kconfig            |   7 +
>   drivers/auxdisplay/Makefile           |   1 +
>   drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++++++++++
>   3 files changed, 266 insertions(+)
>   create mode 100644 drivers/auxdisplay/sensehat-display.c
> 
[....]
> diff --git a/drivers/auxdisplay/sensehat-display.c b/drivers/auxdisplay/sensehat-display.c
> new file mode 100644
> index 000000000000..5980ad23fd4f
> --- /dev/null
> +++ b/drivers/auxdisplay/sensehat-display.c
[...]
> +
> +static ssize_t
> +sensehat_display_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos)
> +{
> +	struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev);
> +	struct sensehat_display *sensehat_display = &sensehat->display;
> +	u8 temp[VMEM_SIZE];
> +
> +	if (*f_pos >= VMEM_SIZE)
> +		return -EFBIG;
> +	if (*f_pos + count > VMEM_SIZE)
> +		count = VMEM_SIZE - *f_pos;
> +	if (copy_from_user(temp, buf, count))
> +		return -EFAULT;
> +	if (mutex_lock_interruptible(&sensehat_display->rw_mtx))
> +		return -ERESTARTSYS;
> +	memcpy(sensehat_display->vmem + *f_pos, temp, count);

So we copy from buf into temp, from temp into vmem and then we 'transform' vmem 
into the representation of pixel_data.

As you are implementing the user-space interface, couldn't we just change the 
pixel representation there and get rid of the transformation?

> +	sensehat_update_display(sensehat);
> +	*f_pos += count;
> +	mutex_unlock(&sensehat_display->rw_mtx);
> +	return count;
> +}
> +
> +static long sensehat_display_ioctl(struct file *filp, unsigned int cmd,
> +			     unsigned long arg)
> +{
> +	struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev);
> +	struct sensehat_display *sensehat_display = &sensehat->display;
> +	void __user *user_ptr = (void __user *)arg;
> +	u8 temp[GAMMA_SIZE];
> +	int ret;
> +
> +	if (mutex_lock_interruptible(&sensehat_display->rw_mtx))
> +		return -ERESTARTSYS;
> +	switch (cmd) {
> +	case SENSEDISP_IOGET_GAMMA:
> +		if (copy_to_user(user_ptr, sensehat_display->gamma, GAMMA_SIZE)) {
> +			ret = -EFAULT;
> +			goto out_unlock;
> +		}
> +		ret = 0;
> +		goto out_unlock;
> +	case SENSEDISP_IOSET_GAMMA:
> +		if (copy_from_user(temp, user_ptr, GAMMA_SIZE)) {
> +			ret = -EFAULT;
> +			goto out_unlock;
> +		}
> +		ret = 0;
> +		goto out_update;

That's just a 'break;' correct?

Regards,
Matthias


  parent reply	other threads:[~2021-11-03 16:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 21:55 [PATCH 0/5] Raspberry Pi Sense HAT driver Charles Mirabile
2021-10-29 21:55 ` [PATCH 1/5] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver Charles Mirabile
2021-10-30  8:02   ` kernel test robot
2021-10-30 17:20   ` Thomas Weißschuh
2021-11-03 16:33   ` Matthias Brugger
2021-11-03 16:53     ` nsaenzju
2021-10-29 21:55 ` [PATCH 2/5] drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver Charles Mirabile
2021-10-29 22:03   ` Randy Dunlap
2021-10-30 14:02   ` kernel test robot
2021-10-29 21:55 ` [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver Charles Mirabile
2021-10-30 22:12   ` kernel test robot
2021-11-03 16:47   ` Matthias Brugger [this message]
2021-10-29 21:55 ` [PATCH 4/5] Documentation: bindings/mfd: sensehat: Raspberry Pi Sense HAT device tree binding Charles Mirabile
2021-11-02 12:51   ` Rob Herring
2021-10-29 21:55 ` [PATCH 5/5] MAINTAINERS: Add sensehat driver authors to MAINTAINERS Charles Mirabile
2021-10-31 16:38 ` [PATCH 0/5] Raspberry Pi Sense HAT driver Miguel Ojeda
2021-11-01 14:18   ` Joel Savitz
2021-11-20 10:55 ` Stefan Wahren

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=704e71ce-e6c6-6492-8f20-47e4fad8cc39@suse.com \
    --to=mbrugger@suse.com \
    --cc=cmirabil@redhat.com \
    --cc=fedora-rpi@googlegroups.com \
    --cc=jsavitz@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=mguma@redhat.com \
    --cc=nsaenzju@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=serge@raspberrypi.org \
    --cc=stefan.wahren@i2se.com \
    /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