Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43e69758 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: solo6x10: get rid of an address space warning



Instead of using an ancillary function to avoid duplicating
a small portion of code that copies data either to kernelspace
or between userspace-kernelspace, duplicate the code,
as it prevents static analyzers to complain about it:

	drivers/media/pci/solo6x10/solo6x10-g723.c:260:46: warning: cast removes address space of expression

The hole idea of using __user is to make sure that the code is
doing the right thing with address space, so there's no
sense on use casting.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 70ae6a04
Loading
Loading
Loading
Loading
+24 −15
Original line number Diff line number Diff line
@@ -223,9 +223,9 @@ static snd_pcm_uframes_t snd_solo_pcm_pointer(struct snd_pcm_substream *ss)
	return idx * G723_FRAMES_PER_PAGE;
}

static int __snd_solo_pcm_copy(struct snd_pcm_substream *ss,
			       unsigned long pos, void *dst,
			       unsigned long count, bool in_kernel)
static int snd_solo_pcm_copy_user(struct snd_pcm_substream *ss, int channel,
				  unsigned long pos, void __user *dst,
				  unsigned long count)
{
	struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
	struct solo_dev *solo_dev = solo_pcm->solo_dev;
@@ -242,10 +242,7 @@ static int __snd_solo_pcm_copy(struct snd_pcm_substream *ss,
		if (err)
			return err;

		if (in_kernel)
			memcpy(dst, solo_pcm->g723_buf, G723_PERIOD_BYTES);
		else if (copy_to_user((void __user *)dst,
				      solo_pcm->g723_buf, G723_PERIOD_BYTES))
		if (copy_to_user(dst, solo_pcm->g723_buf, G723_PERIOD_BYTES))
			return -EFAULT;
		dst += G723_PERIOD_BYTES;
	}
@@ -253,18 +250,30 @@ static int __snd_solo_pcm_copy(struct snd_pcm_substream *ss,
	return 0;
}

static int snd_solo_pcm_copy_user(struct snd_pcm_substream *ss, int channel,
				  unsigned long pos, void __user *dst,
				  unsigned long count)
{
	return __snd_solo_pcm_copy(ss, pos, (void *)dst, count, false);
}

static int snd_solo_pcm_copy_kernel(struct snd_pcm_substream *ss, int channel,
				    unsigned long pos, void *dst,
				    unsigned long count)
{
	return __snd_solo_pcm_copy(ss, pos, dst, count, true);
	struct solo_snd_pcm *solo_pcm = snd_pcm_substream_chip(ss);
	struct solo_dev *solo_dev = solo_pcm->solo_dev;
	int err, i;

	for (i = 0; i < (count / G723_FRAMES_PER_PAGE); i++) {
		int page = (pos / G723_FRAMES_PER_PAGE) + i;

		err = solo_p2m_dma_t(solo_dev, 0, solo_pcm->g723_dma,
				     SOLO_G723_EXT_ADDR(solo_dev) +
				     (page * G723_PERIOD_BLOCK) +
				     (ss->number * G723_PERIOD_BYTES),
				     G723_PERIOD_BYTES, 0, 0);
		if (err)
			return err;

		memcpy(dst, solo_pcm->g723_buf, G723_PERIOD_BYTES);
		dst += G723_PERIOD_BYTES;
	}

	return 0;
}

static const struct snd_pcm_ops snd_solo_pcm_ops = {