mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
Char/Misc driver fixes for 5.19-rc3
Here are some small char/misc driver fixes for 5.19-rc3 that resolve some reported issues. They include: - mei driver fixes - comedi driver fix - rtsx build warning fix - fsl-mc-bus driver fix All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCYqw0eA8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+ymH0wCggIbJo3/FVzs98oMUfx4bGdnu49kAniZpSOrn r7dKZ9o8wk11bvsqEEzn =KEHD -----END PGP SIGNATURE----- Merge tag 'char-misc-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc driver fixes from Greg KH: "Here are some small char/misc driver fixes for 5.19-rc3 that resolve some reported issues. They include: - mei driver fixes - comedi driver fix - rtsx build warning fix - fsl-mc-bus driver fix All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: eeprom: at25: Split reads into chunks and cap write size misc: atmel-ssc: Fix IRQ check in ssc_probe char: lp: remove redundant initialization of err
This commit is contained in:
commit
f0ec9c65a8
3 changed files with 58 additions and 45 deletions
|
@ -1019,7 +1019,7 @@ static struct parport_driver lp_driver = {
|
||||||
|
|
||||||
static int __init lp_init(void)
|
static int __init lp_init(void)
|
||||||
{
|
{
|
||||||
int i, err = 0;
|
int i, err;
|
||||||
|
|
||||||
if (parport_nr[0] == LP_PARPORT_OFF)
|
if (parport_nr[0] == LP_PARPORT_OFF)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -232,9 +232,9 @@ static int ssc_probe(struct platform_device *pdev)
|
||||||
clk_disable_unprepare(ssc->clk);
|
clk_disable_unprepare(ssc->clk);
|
||||||
|
|
||||||
ssc->irq = platform_get_irq(pdev, 0);
|
ssc->irq = platform_get_irq(pdev, 0);
|
||||||
if (!ssc->irq) {
|
if (ssc->irq < 0) {
|
||||||
dev_dbg(&pdev->dev, "could not get irq\n");
|
dev_dbg(&pdev->dev, "could not get irq\n");
|
||||||
return -ENXIO;
|
return ssc->irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&user_lock);
|
mutex_lock(&user_lock);
|
||||||
|
|
|
@ -79,6 +79,11 @@ 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 num_msgs = DIV_ROUND_UP(count, max_chunk);
|
||||||
|
size_t nr_bytes = 0;
|
||||||
|
unsigned int msg_offset;
|
||||||
|
size_t msg_count;
|
||||||
u8 *cp;
|
u8 *cp;
|
||||||
ssize_t status;
|
ssize_t status;
|
||||||
struct spi_transfer t[2];
|
struct spi_transfer t[2];
|
||||||
|
@ -92,54 +97,59 @@ static int at25_ee_read(void *priv, unsigned int offset,
|
||||||
if (unlikely(!count))
|
if (unlikely(!count))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
cp = at25->command;
|
msg_offset = (unsigned int)offset;
|
||||||
|
msg_count = min(count, max_chunk);
|
||||||
|
while (num_msgs) {
|
||||||
|
cp = at25->command;
|
||||||
|
|
||||||
instr = AT25_READ;
|
instr = AT25_READ;
|
||||||
if (at25->chip.flags & EE_INSTR_BIT3_IS_ADDR)
|
if (at25->chip.flags & EE_INSTR_BIT3_IS_ADDR)
|
||||||
if (offset >= BIT(at25->addrlen * 8))
|
if (msg_offset >= BIT(at25->addrlen * 8))
|
||||||
instr |= AT25_INSTR_BIT3;
|
instr |= AT25_INSTR_BIT3;
|
||||||
|
|
||||||
mutex_lock(&at25->lock);
|
mutex_lock(&at25->lock);
|
||||||
|
|
||||||
*cp++ = instr;
|
*cp++ = instr;
|
||||||
|
|
||||||
/* 8/16/24-bit address is written MSB first */
|
/* 8/16/24-bit address is written MSB first */
|
||||||
switch (at25->addrlen) {
|
switch (at25->addrlen) {
|
||||||
default: /* case 3 */
|
default: /* case 3 */
|
||||||
*cp++ = offset >> 16;
|
*cp++ = msg_offset >> 16;
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case 2:
|
case 2:
|
||||||
*cp++ = offset >> 8;
|
*cp++ = msg_offset >> 8;
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case 1:
|
case 1:
|
||||||
case 0: /* can't happen: for better code generation */
|
case 0: /* can't happen: for better code generation */
|
||||||
*cp++ = offset >> 0;
|
*cp++ = msg_offset >> 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
spi_message_init(&m);
|
||||||
|
memset(t, 0, sizeof(t));
|
||||||
|
|
||||||
|
t[0].tx_buf = at25->command;
|
||||||
|
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;
|
||||||
|
spi_message_add_tail(&t[1], &m);
|
||||||
|
|
||||||
|
status = spi_sync(at25->spi, &m);
|
||||||
|
|
||||||
|
mutex_unlock(&at25->lock);
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
--num_msgs;
|
||||||
|
msg_offset += msg_count;
|
||||||
|
nr_bytes += msg_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
spi_message_init(&m);
|
dev_dbg(&at25->spi->dev, "read %zu bytes at %d\n",
|
||||||
memset(t, 0, sizeof(t));
|
count, offset);
|
||||||
|
return 0;
|
||||||
t[0].tx_buf = at25->command;
|
|
||||||
t[0].len = at25->addrlen + 1;
|
|
||||||
spi_message_add_tail(&t[0], &m);
|
|
||||||
|
|
||||||
t[1].rx_buf = buf;
|
|
||||||
t[1].len = count;
|
|
||||||
spi_message_add_tail(&t[1], &m);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read it all at once.
|
|
||||||
*
|
|
||||||
* REVISIT that's potentially a problem with large chips, if
|
|
||||||
* other devices on the bus need to be accessed regularly or
|
|
||||||
* this chip is clocked very slowly.
|
|
||||||
*/
|
|
||||||
status = spi_sync(at25->spi, &m);
|
|
||||||
dev_dbg(&at25->spi->dev, "read %zu bytes at %d --> %zd\n",
|
|
||||||
count, offset, status);
|
|
||||||
|
|
||||||
mutex_unlock(&at25->lock);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read extra registers as ID or serial number */
|
/* Read extra registers as ID or serial number */
|
||||||
|
@ -190,6 +200,7 @@ ATTRIBUTE_GROUPS(sernum);
|
||||||
static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
|
static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
|
||||||
{
|
{
|
||||||
struct at25_data *at25 = priv;
|
struct at25_data *at25 = priv;
|
||||||
|
size_t maxsz = spi_max_transfer_size(at25->spi);
|
||||||
const char *buf = val;
|
const char *buf = val;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
unsigned buf_size;
|
unsigned buf_size;
|
||||||
|
@ -253,6 +264,8 @@ static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
|
||||||
segment = buf_size - (offset % buf_size);
|
segment = buf_size - (offset % buf_size);
|
||||||
if (segment > count)
|
if (segment > count)
|
||||||
segment = count;
|
segment = count;
|
||||||
|
if (segment > maxsz)
|
||||||
|
segment = maxsz;
|
||||||
memcpy(cp, buf, segment);
|
memcpy(cp, buf, segment);
|
||||||
status = spi_write(at25->spi, bounce,
|
status = spi_write(at25->spi, bounce,
|
||||||
segment + at25->addrlen + 1);
|
segment + at25->addrlen + 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue