From: <VaibhaavRam.TL@microchip.com>
To: <michael@walle.cc>
Cc: <gregkh@linuxfoundation.org>, <linux-gpio@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <UNGLinuxDriver@microchip.com>,
<arnd@arndb.de>
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: Thu, 27 Apr 2023 12:42:07 +0000 [thread overview]
Message-ID: <50d10f649ac1314f07d53db89fe76c39e2764486.camel@microchip.com> (raw)
In-Reply-To: <2265a7467850190ec99ac9ab0aaa7905@walle.cc>
On Tue, 2023-04-25 at 09:33 +0200, Michael Walle wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> 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?
Yes, release_sys_lock should be done. Will fix in next version of patch
>
> > +
> > + buf[byte] = readl(rb +
> > MMAP_OTP_OFFSET(OTP_RD_DATA_OFFSET));
> > + }
> > + release_sys_lock(priv);
> > +
> > + return byte;
> > +}
>
prev parent reply other threads:[~2023-04-27 12:42 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 ` [PATCH v10 char-misc-next 1/2] misc: microchip: pci1xxxx: Add support to read and write into PCI1XXXX OTP via NVMEM sysfs Michael Walle
2023-04-27 12:42 ` VaibhaavRam.TL [this message]
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=50d10f649ac1314f07d53db89fe76c39e2764486.camel@microchip.com \
--to=vaibhaavram.tl@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
/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).