Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+58 -45
+1 -1
drivers/char/lp.c
··· 1019 1019 1020 1020 static int __init lp_init(void) 1021 1021 { 1022 - int i, err = 0; 1022 + int i, err; 1023 1023 1024 1024 if (parport_nr[0] == LP_PARPORT_OFF) 1025 1025 return 0;
+2 -2
drivers/misc/atmel-ssc.c
··· 232 232 clk_disable_unprepare(ssc->clk); 233 233 234 234 ssc->irq = platform_get_irq(pdev, 0); 235 - if (!ssc->irq) { 235 + if (ssc->irq < 0) { 236 236 dev_dbg(&pdev->dev, "could not get irq\n"); 237 - return -ENXIO; 237 + return ssc->irq; 238 238 } 239 239 240 240 mutex_lock(&user_lock);
+55 -42
drivers/misc/eeprom/at25.c
··· 79 79 { 80 80 struct at25_data *at25 = priv; 81 81 char *buf = val; 82 + size_t max_chunk = spi_max_transfer_size(at25->spi); 83 + size_t num_msgs = DIV_ROUND_UP(count, max_chunk); 84 + size_t nr_bytes = 0; 85 + unsigned int msg_offset; 86 + size_t msg_count; 82 87 u8 *cp; 83 88 ssize_t status; 84 89 struct spi_transfer t[2]; ··· 97 92 if (unlikely(!count)) 98 93 return -EINVAL; 99 94 100 - cp = at25->command; 95 + msg_offset = (unsigned int)offset; 96 + msg_count = min(count, max_chunk); 97 + while (num_msgs) { 98 + cp = at25->command; 101 99 102 - instr = AT25_READ; 103 - if (at25->chip.flags & EE_INSTR_BIT3_IS_ADDR) 104 - if (offset >= BIT(at25->addrlen * 8)) 105 - instr |= AT25_INSTR_BIT3; 100 + instr = AT25_READ; 101 + if (at25->chip.flags & EE_INSTR_BIT3_IS_ADDR) 102 + if (msg_offset >= BIT(at25->addrlen * 8)) 103 + instr |= AT25_INSTR_BIT3; 106 104 107 - mutex_lock(&at25->lock); 105 + mutex_lock(&at25->lock); 108 106 109 - *cp++ = instr; 107 + *cp++ = instr; 110 108 111 - /* 8/16/24-bit address is written MSB first */ 112 - switch (at25->addrlen) { 113 - default: /* case 3 */ 114 - *cp++ = offset >> 16; 115 - fallthrough; 116 - case 2: 117 - *cp++ = offset >> 8; 118 - fallthrough; 119 - case 1: 120 - case 0: /* can't happen: for better code generation */ 121 - *cp++ = offset >> 0; 109 + /* 8/16/24-bit address is written MSB first */ 110 + switch (at25->addrlen) { 111 + default: /* case 3 */ 112 + *cp++ = msg_offset >> 16; 113 + fallthrough; 114 + case 2: 115 + *cp++ = msg_offset >> 8; 116 + fallthrough; 117 + case 1: 118 + case 0: /* can't happen: for better code generation */ 119 + *cp++ = msg_offset >> 0; 120 + } 121 + 122 + spi_message_init(&m); 123 + memset(t, 0, sizeof(t)); 124 + 125 + t[0].tx_buf = at25->command; 126 + t[0].len = at25->addrlen + 1; 127 + spi_message_add_tail(&t[0], &m); 128 + 129 + t[1].rx_buf = buf + nr_bytes; 130 + t[1].len = msg_count; 131 + spi_message_add_tail(&t[1], &m); 132 + 133 + status = spi_sync(at25->spi, &m); 134 + 135 + mutex_unlock(&at25->lock); 136 + 137 + if (status) 138 + return status; 139 + 140 + --num_msgs; 141 + msg_offset += msg_count; 142 + nr_bytes += msg_count; 122 143 } 123 144 124 - spi_message_init(&m); 125 - memset(t, 0, sizeof(t)); 126 - 127 - t[0].tx_buf = at25->command; 128 - t[0].len = at25->addrlen + 1; 129 - spi_message_add_tail(&t[0], &m); 130 - 131 - t[1].rx_buf = buf; 132 - t[1].len = count; 133 - spi_message_add_tail(&t[1], &m); 134 - 135 - /* 136 - * Read it all at once. 137 - * 138 - * REVISIT that's potentially a problem with large chips, if 139 - * other devices on the bus need to be accessed regularly or 140 - * this chip is clocked very slowly. 141 - */ 142 - status = spi_sync(at25->spi, &m); 143 - dev_dbg(&at25->spi->dev, "read %zu bytes at %d --> %zd\n", 144 - count, offset, status); 145 - 146 - mutex_unlock(&at25->lock); 147 - return status; 145 + dev_dbg(&at25->spi->dev, "read %zu bytes at %d\n", 146 + count, offset); 147 + return 0; 148 148 } 149 149 150 150 /* Read extra registers as ID or serial number */ ··· 200 190 static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count) 201 191 { 202 192 struct at25_data *at25 = priv; 193 + size_t maxsz = spi_max_transfer_size(at25->spi); 203 194 const char *buf = val; 204 195 int status = 0; 205 196 unsigned buf_size; ··· 264 253 segment = buf_size - (offset % buf_size); 265 254 if (segment > count) 266 255 segment = count; 256 + if (segment > maxsz) 257 + segment = maxsz; 267 258 memcpy(cp, buf, segment); 268 259 status = spi_write(at25->spi, bounce, 269 260 segment + at25->addrlen + 1);