Messages in this thread | | | From | <> | Subject | RE: [PATCH v6 char-misc-next] misc: microchip: pci1xxxx: Add OTP/EEPROM driver for the pci1xxxx switch | Date | Thu, 2 Mar 2023 06:18:33 +0000 |
| |
> -----Original Message----- > From: Vaibhaav Ram T.L <vaibhaavram.tl@microchip.com> > Sent: Tuesday, February 28, 2023 11:34 PM > Microchip's pci1xxxx is an unmanaged PCIe3.1a switch for consumer, > industrial, and automotive applications. This switch integrates OTP and > EEPROM to enable customization of the part in the field. This patch provides > the OTP/EEPROM driver to support the same. > > +static int otp_eeprom_create_device(struct auxiliary_device *aux_dev) { > + struct auxiliary_device_wrapper *aux_dev_wrapper; > + struct pci1xxxx_otp_eeprom_device *priv; > + struct gp_aux_data_type *pdata; > + int ret; > + > + aux_dev_wrapper = container_of(aux_dev, struct > auxiliary_device_wrapper, > + aux_dev); > + pdata = &aux_dev_wrapper->gp_aux_data; > + if (!pdata) > + return dev_err_probe(&aux_dev->dev, -EINVAL, > + "Invalid data in aux_dev_wrapper- > >gp_aux_data\n"); > + > + priv = devm_kzalloc(&aux_dev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return dev_err_probe(&aux_dev->dev, -ENOMEM, > + "Memory Allocation Failed\n"); > + > + priv->pdev = aux_dev; > + dev_set_drvdata(&aux_dev->dev, priv); > + > + if (!devm_request_mem_region(&aux_dev->dev, pdata- > >region_start + > + PERI_PF3_SYSTEM_REG_ADDR_BASE, > + PERI_PF3_SYSTEM_REG_LENGTH, > + aux_dev->name)) > + return dev_err_probe(&aux_dev->dev, -ENOMEM, > + "can't request otpeeprom region\n"); > + > + priv->reg_base = devm_ioremap(&aux_dev->dev, pdata- > >region_start + > + PERI_PF3_SYSTEM_REG_ADDR_BASE, > + PERI_PF3_SYSTEM_REG_LENGTH); > + if (!priv->reg_base) > + return dev_err_probe(&aux_dev->dev, -ENOMEM, > "ioremap failed\n"); > + > + ret = sysfs_create_bin_file(&aux_dev->dev.kobj, > &pci1xxxx_eeprom_attr); Check whether EEPROM is present and accessible as expected before enumerating. Enumerate OTP first as it is always present before checking for EEPROM. > + if (ret) > + return dev_err_probe(&aux_dev->dev, ret, > + "sysfs_create_bin_file eeprom failed\n"); > + > + ret = sysfs_create_bin_file(&aux_dev->dev.kobj, > &pci1xxxx_otp_attr); > + if (ret) > + return dev_err_probe(&aux_dev->dev, ret, > + "sysfs_create_bin_file otp failed\n"); Test the error handling - if the function fails here what happens to the previously created Sysfs file. > + > + return ret; > +}
Thank You.
Regards, Kumar
| |