Merge tag 'char-misc-5.19-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
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
This commit is contained in:
@@ -631,16 +631,20 @@ static int rtsx_usb_probe(struct usb_interface *intf,
|
|||||||
|
|
||||||
ucr->pusb_dev = usb_dev;
|
ucr->pusb_dev = usb_dev;
|
||||||
|
|
||||||
ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE,
|
ucr->cmd_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
|
||||||
GFP_KERNEL, &ucr->iobuf_dma);
|
if (!ucr->cmd_buf)
|
||||||
if (!ucr->iobuf)
|
|
||||||
return -ENOMEM;
|
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);
|
usb_set_intfdata(intf, ucr);
|
||||||
|
|
||||||
ucr->vendor_id = id->idVendor;
|
ucr->vendor_id = id->idVendor;
|
||||||
ucr->product_id = id->idProduct;
|
ucr->product_id = id->idProduct;
|
||||||
ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf;
|
|
||||||
|
|
||||||
mutex_init(&ucr->dev_mutex);
|
mutex_init(&ucr->dev_mutex);
|
||||||
|
|
||||||
@@ -668,8 +672,11 @@ static int rtsx_usb_probe(struct usb_interface *intf,
|
|||||||
|
|
||||||
out_init_fail:
|
out_init_fail:
|
||||||
usb_set_intfdata(ucr->pusb_intf, NULL);
|
usb_set_intfdata(ucr->pusb_intf, NULL);
|
||||||
usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
|
kfree(ucr->rsp_buf);
|
||||||
ucr->iobuf_dma);
|
ucr->rsp_buf = NULL;
|
||||||
|
out_free_cmd_buf:
|
||||||
|
kfree(ucr->cmd_buf);
|
||||||
|
ucr->cmd_buf = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -682,8 +689,12 @@ static void rtsx_usb_disconnect(struct usb_interface *intf)
|
|||||||
mfd_remove_devices(&intf->dev);
|
mfd_remove_devices(&intf->dev);
|
||||||
|
|
||||||
usb_set_intfdata(ucr->pusb_intf, NULL);
|
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
|
#ifdef CONFIG_PM
|
||||||
|
@@ -80,10 +80,9 @@ static int at25_ee_read(void *priv, unsigned int offset,
|
|||||||
struct at25_data *at25 = priv;
|
struct at25_data *at25 = priv;
|
||||||
char *buf = val;
|
char *buf = val;
|
||||||
size_t max_chunk = spi_max_transfer_size(at25->spi);
|
size_t max_chunk = spi_max_transfer_size(at25->spi);
|
||||||
size_t num_msgs = DIV_ROUND_UP(count, max_chunk);
|
unsigned int msg_offset = offset;
|
||||||
size_t nr_bytes = 0;
|
size_t bytes_left = count;
|
||||||
unsigned int msg_offset;
|
size_t segment;
|
||||||
size_t msg_count;
|
|
||||||
u8 *cp;
|
u8 *cp;
|
||||||
ssize_t status;
|
ssize_t status;
|
||||||
struct spi_transfer t[2];
|
struct spi_transfer t[2];
|
||||||
@@ -97,9 +96,8 @@ static int at25_ee_read(void *priv, unsigned int offset,
|
|||||||
if (unlikely(!count))
|
if (unlikely(!count))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
msg_offset = (unsigned int)offset;
|
do {
|
||||||
msg_count = min(count, max_chunk);
|
segment = min(bytes_left, max_chunk);
|
||||||
while (num_msgs) {
|
|
||||||
cp = at25->command;
|
cp = at25->command;
|
||||||
|
|
||||||
instr = AT25_READ;
|
instr = AT25_READ;
|
||||||
@@ -131,8 +129,8 @@ static int at25_ee_read(void *priv, unsigned int offset,
|
|||||||
t[0].len = at25->addrlen + 1;
|
t[0].len = at25->addrlen + 1;
|
||||||
spi_message_add_tail(&t[0], &m);
|
spi_message_add_tail(&t[0], &m);
|
||||||
|
|
||||||
t[1].rx_buf = buf + nr_bytes;
|
t[1].rx_buf = buf;
|
||||||
t[1].len = msg_count;
|
t[1].len = segment;
|
||||||
spi_message_add_tail(&t[1], &m);
|
spi_message_add_tail(&t[1], &m);
|
||||||
|
|
||||||
status = spi_sync(at25->spi, &m);
|
status = spi_sync(at25->spi, &m);
|
||||||
@@ -142,10 +140,10 @@ static int at25_ee_read(void *priv, unsigned int offset,
|
|||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
--num_msgs;
|
msg_offset += segment;
|
||||||
msg_offset += msg_count;
|
buf += segment;
|
||||||
nr_bytes += msg_count;
|
bytes_left -= segment;
|
||||||
}
|
} while (bytes_left > 0);
|
||||||
|
|
||||||
dev_dbg(&at25->spi->dev, "read %zu bytes at %d\n",
|
dev_dbg(&at25->spi->dev, "read %zu bytes at %d\n",
|
||||||
count, offset);
|
count, offset);
|
||||||
@@ -229,7 +227,7 @@ static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
|
|||||||
do {
|
do {
|
||||||
unsigned long timeout, retries;
|
unsigned long timeout, retries;
|
||||||
unsigned segment;
|
unsigned segment;
|
||||||
unsigned offset = (unsigned) off;
|
unsigned offset = off;
|
||||||
u8 *cp = bounce;
|
u8 *cp = bounce;
|
||||||
int sr;
|
int sr;
|
||||||
u8 instr;
|
u8 instr;
|
||||||
|
@@ -54,8 +54,6 @@ struct rtsx_ucr {
|
|||||||
struct usb_device *pusb_dev;
|
struct usb_device *pusb_dev;
|
||||||
struct usb_interface *pusb_intf;
|
struct usb_interface *pusb_intf;
|
||||||
struct usb_sg_request current_sg;
|
struct usb_sg_request current_sg;
|
||||||
unsigned char *iobuf;
|
|
||||||
dma_addr_t iobuf_dma;
|
|
||||||
|
|
||||||
struct timer_list sg_timer;
|
struct timer_list sg_timer;
|
||||||
struct mutex dev_mutex;
|
struct mutex dev_mutex;
|
||||||
|
Reference in New Issue
Block a user