vvcam_sensor_sysfs.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
  4. *
  5. * Synopsys DesignWare MIPI D-PHY controller driver.
  6. * SysFS components for the platform driver
  7. *
  8. * Author: Luis Oliveira <luis.oliveira@synopsys.com>
  9. */
  10. #include "sensor_common.h"
  11. static ssize_t cam_info_show(struct device *dev,
  12. struct device_attribute *attr, char *buf)
  13. {
  14. struct platform_device *pdev = to_platform_device(dev);
  15. struct vvcam_sensor_driver_dev *pdriver_dev;
  16. struct vvcam_sensor_dev * psensor_dev;
  17. char buffer[15];
  18. pdriver_dev = platform_get_drvdata(pdev);
  19. psensor_dev = (struct vvcam_sensor_dev *)pdriver_dev->private;
  20. printk("<0>""sensor name: %s\n", psensor_dev->sensor_func.sensor_name);
  21. snprintf(buffer,
  22. sizeof(buffer),
  23. "i2c id is :%d\n", psensor_dev->i2c_bus);
  24. return strlcpy(buf, buffer, PAGE_SIZE);
  25. }
  26. static DEVICE_ATTR_RO(cam_info);
  27. int sensor_create_capabilities_sysfs(struct platform_device *pdev)
  28. {
  29. device_create_file(&pdev->dev, &dev_attr_cam_info);
  30. return 0;
  31. }
  32. int sensor_remove_capabilities_sysfs(struct platform_device *pdev)
  33. {
  34. device_remove_file(&pdev->dev, &dev_attr_cam_info);
  35. return 0;
  36. }