Commit b41362fd authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull char/misc driver fixes from Greg KH:
 "Here are four small char/misc driver fixes for 5.19-rc6 to resolve
  some reported issues. They only affect two drivers:

   - rtsx_usb: fix for of-reported DMA warning error, the driver was
     handling memory buffers in odd ways, it has now been fixed up to be
     much simpler and correct by Shuah.

   - at25 eeprom driver bugfix for reported problem

  All of these have been in linux-next for a week with no reported
  problems"

* tag 'char-misc-5.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  misc: rtsx_usb: set return value in rsp_buf alloc err path
  misc: rtsx_usb: use separate command and response buffers
  misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer
  eeprom: at25: Rework buggy read splitting
parents d9919d43 2cd37c2e
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -631,16 +631,20 @@ static int rtsx_usb_probe(struct usb_interface *intf,

	ucr->pusb_dev = usb_dev;

	ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE,
			GFP_KERNEL, &ucr->iobuf_dma);
	if (!ucr->iobuf)
	ucr->cmd_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
	if (!ucr->cmd_buf)
		return -ENOMEM;

	ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
	if (!ucr->rsp_buf) {
		ret = -ENOMEM;
		goto out_free_cmd_buf;
	}

	usb_set_intfdata(intf, ucr);

	ucr->vendor_id = id->idVendor;
	ucr->product_id = id->idProduct;
	ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf;

	mutex_init(&ucr->dev_mutex);

@@ -668,8 +672,11 @@ static int rtsx_usb_probe(struct usb_interface *intf,

out_init_fail:
	usb_set_intfdata(ucr->pusb_intf, NULL);
	usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
			ucr->iobuf_dma);
	kfree(ucr->rsp_buf);
	ucr->rsp_buf = NULL;
out_free_cmd_buf:
	kfree(ucr->cmd_buf);
	ucr->cmd_buf = NULL;
	return ret;
}

@@ -682,8 +689,12 @@ static void rtsx_usb_disconnect(struct usb_interface *intf)
	mfd_remove_devices(&intf->dev);

	usb_set_intfdata(ucr->pusb_intf, NULL);
	usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
			ucr->iobuf_dma);

	kfree(ucr->cmd_buf);
	ucr->cmd_buf = NULL;

	kfree(ucr->rsp_buf);
	ucr->rsp_buf = NULL;
}

#ifdef CONFIG_PM
+12 −14
Original line number Diff line number Diff line
@@ -80,10 +80,9 @@ static int at25_ee_read(void *priv, unsigned int offset,
	struct at25_data *at25 = priv;
	char *buf = val;
	size_t max_chunk = spi_max_transfer_size(at25->spi);
	size_t num_msgs = DIV_ROUND_UP(count, max_chunk);
	size_t nr_bytes = 0;
	unsigned int msg_offset;
	size_t msg_count;
	unsigned int msg_offset = offset;
	size_t bytes_left = count;
	size_t segment;
	u8			*cp;
	ssize_t			status;
	struct spi_transfer	t[2];
@@ -97,9 +96,8 @@ static int at25_ee_read(void *priv, unsigned int offset,
	if (unlikely(!count))
		return -EINVAL;

	msg_offset = (unsigned int)offset;
	msg_count = min(count, max_chunk);
	while (num_msgs) {
	do {
		segment = min(bytes_left, max_chunk);
		cp = at25->command;

		instr = AT25_READ;
@@ -131,8 +129,8 @@ static int at25_ee_read(void *priv, unsigned int offset,
		t[0].len = at25->addrlen + 1;
		spi_message_add_tail(&t[0], &m);

		t[1].rx_buf = buf + nr_bytes;
		t[1].len = msg_count;
		t[1].rx_buf = buf;
		t[1].len = segment;
		spi_message_add_tail(&t[1], &m);

		status = spi_sync(at25->spi, &m);
@@ -142,10 +140,10 @@ static int at25_ee_read(void *priv, unsigned int offset,
		if (status)
			return status;

		--num_msgs;
		msg_offset += msg_count;
		nr_bytes += msg_count;
	}
		msg_offset += segment;
		buf += segment;
		bytes_left -= segment;
	} while (bytes_left > 0);

	dev_dbg(&at25->spi->dev, "read %zu bytes at %d\n",
		count, offset);
@@ -229,7 +227,7 @@ static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
	do {
		unsigned long	timeout, retries;
		unsigned	segment;
		unsigned	offset = (unsigned) off;
		unsigned	offset = off;
		u8		*cp = bounce;
		int		sr;
		u8		instr;
+0 −2
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ struct rtsx_ucr {
	struct usb_device	*pusb_dev;
	struct usb_interface	*pusb_intf;
	struct usb_sg_request	current_sg;
	unsigned char		*iobuf;
	dma_addr_t		iobuf_dma;

	struct timer_list	sg_timer;
	struct mutex		dev_mutex;