misc: microchip: pci1xxxx: Add OTP/EEPROM driver for the pci1xxxx switch
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 48 lines
-----Original Message-----
From: Vaibhaav Ram T.L <[email protected]>
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.(quoted diff) +7
-0+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,(quoted diff) +5
-0+ 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-Quoted 1 line
gp_aux_data\n");
(quoted diff) +10
-0+ + 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-Quoted 1 line
region_start+(quoted diff) +7
-0+ 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-Quoted 1 line
region_start+(quoted diff) +4
-0+ 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");
(quoted diff) +2
-0+ + ret = sysfs_create_bin_file(&aux_dev->dev.kobj,
Quoted 1 line
&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.
Review
Quoted 9 lines
(quoted diff) +5
-0+ 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);(quoted diff) +3
-0+ 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.
Review
Quoted 3 lines
(quoted diff) +3
-0+ + return ret; +}
Thank You.
Regards,
Kumar