Re: [PATCH v2 2/5] mtd: spinand: add OTP support
From: Martin Kurbanov
Date: Mon Oct 14 2024 - 08:28:17 EST
Hi Miquel,
On 10/1/24 12:12, Miquel Raynal wrote:
>> +/**
>> + * spinand_set_mtd_otp_ops() - Set up OTP methods
>> + * @spinand: the spinand device
>> + *
>> + * Set up OTP methods.
>> + */
>> +void spinand_set_mtd_otp_ops(struct spinand_device *spinand)
>> +{
>> + struct mtd_info *mtd = spinand_to_mtd(spinand);
>> +
>> + if (!spinand->otp->ops)
>
> Could we use something else as check? It feels odd to check for otp ops
> and then just ignore the fact that they are here. Maybe check npages or
> otp_size() ?
A developer may not specify OTP callbacks:
SPINAND_OTP_INFO(otp_pages, NULL /* OTP ops */)
Or do you mean that it is better to check in each function
spinand_mtd_otp_{info,read,write,lock}? E.g.:
static int spinand_mtd_otp_erase(struct mtd_info *mtd, loff_t ofs, size_t len)
{
struct spinand_device *spinand = mtd_to_spinand(mtd);
const struct spinand_otp_ops *ops = spinand->otp->ops;
int ret;
if (!ops || !ops->erase)
return -EOPNOTSUPP;
--
Best Regards,
Martin Kurbanov