From: Michael Walle <michael@walle.cc>
To: "Vaibhaav Ram T.L" <vaibhaavram.tl@microchip.com>
Cc: gregkh@linuxfoundation.org, arnd@arndb.de,
kumaravel.thiagarajan@microchip.com,
tharunkumar.pasumarthi@microchip.com,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
UNGLinuxDriver@microchip.com
Subject: Re: [PATCH v10 char-misc-next 1/2] misc: microchip: pci1xxxx: Add support to read and write into PCI1XXXX OTP via NVMEM sysfs
Date: Tue, 25 Apr 2023 09:33:40 +0200 [thread overview]
Message-ID: <2265a7467850190ec99ac9ab0aaa7905@walle.cc> (raw)
In-Reply-To: <20230421142643.1784-2-vaibhaavram.tl@microchip.com>
Hi,
> +static int pci1xxxx_otp_read(void *priv_t, unsigned int off,
> + void *buf_t, size_t count)
> +{
> + struct pci1xxxx_otp_eeprom_device *priv = priv_t;
> + void __iomem *rb = priv->reg_base;
> + char *buf = buf_t;
> + u32 regval;
> + u32 byte;
> + int ret;
> + u8 data;
> +
> + if (off >= priv->nvmem_config_otp.size)
> + return -EFAULT;
> +
> + if ((off + count) > priv->nvmem_config_otp.size)
> + count = priv->nvmem_config_otp.size - off;
> +
> + ret = set_sys_lock(priv);
> + if (ret)
> + return ret;
> +
> + for (byte = 0; byte < count; byte++) {
> + otp_device_set_address(priv, (u16)(off + byte));
> + data = readl(rb + MMAP_OTP_OFFSET(OTP_FUNC_CMD_OFFSET));
> + writel(data | OTP_FUNC_RD_BIT,
> + rb + MMAP_OTP_OFFSET(OTP_FUNC_CMD_OFFSET));
> + data = readl(rb + MMAP_OTP_OFFSET(OTP_CMD_GO_OFFSET));
> + writel(data | OTP_CMD_GO_BIT,
> + rb + MMAP_OTP_OFFSET(OTP_CMD_GO_OFFSET));
> +
> + ret = read_poll_timeout(readl, regval,
> + !(regval & OTP_STATUS_BUSY_BIT),
> + STATUS_READ_DELAY_US,
> + STATUS_READ_TIMEOUT_US, true,
> + rb + MMAP_OTP_OFFSET(OTP_STATUS_OFFSET));
> +
> + data = readl(rb + MMAP_OTP_OFFSET(OTP_PASS_FAIL_OFFSET));
> + if (ret < 0 || data & OTP_FAIL_BIT)
> + return -EIO;
Don't you need to release the lock?
> +
> + buf[byte] = readl(rb + MMAP_OTP_OFFSET(OTP_RD_DATA_OFFSET));
> + }
> + release_sys_lock(priv);
> +
> + return byte;
> +}
next parent reply other threads:[~2023-04-25 7:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230421142643.1784-1-vaibhaavram.tl@microchip.com>
[not found] ` <20230421142643.1784-2-vaibhaavram.tl@microchip.com>
2023-04-25 7:33 ` Michael Walle [this message]
2023-04-27 12:42 ` [PATCH v10 char-misc-next 1/2] misc: microchip: pci1xxxx: Add support to read and write into PCI1XXXX OTP via NVMEM sysfs VaibhaavRam.TL
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2265a7467850190ec99ac9ab0aaa7905@walle.cc \
--to=michael@walle.cc \
--cc=UNGLinuxDriver@microchip.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=kumaravel.thiagarajan@microchip.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tharunkumar.pasumarthi@microchip.com \
--cc=vaibhaavram.tl@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).