/drivers/net/wimax/i2400m/sysfs.c

http://github.com/mirrors/linux · C · 65 lines · 42 code · 9 blank · 14 comment · 9 complexity · 1ee69571c0a199e4fd90f63bb64916e8 MD5 · raw file

  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Intel Wireless WiMAX Connection 2400m
  4. * Sysfs interfaces to show driver and device information
  5. *
  6. * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
  7. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  8. */
  9. #include <linux/netdevice.h>
  10. #include <linux/etherdevice.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/device.h>
  13. #include "i2400m.h"
  14. #define D_SUBMODULE sysfs
  15. #include "debug-levels.h"
  16. /*
  17. * Set the idle timeout (msecs)
  18. *
  19. * FIXME: eventually this should be a common WiMAX stack method, but
  20. * would like to wait to see how other devices manage it.
  21. */
  22. static
  23. ssize_t i2400m_idle_timeout_store(struct device *dev,
  24. struct device_attribute *attr,
  25. const char *buf, size_t size)
  26. {
  27. ssize_t result;
  28. struct i2400m *i2400m = net_dev_to_i2400m(to_net_dev(dev));
  29. unsigned val;
  30. result = -EINVAL;
  31. if (sscanf(buf, "%u\n", &val) != 1)
  32. goto error_no_unsigned;
  33. if (val != 0 && (val < 100 || val > 300000 || val % 100 != 0)) {
  34. dev_err(dev, "idle_timeout: %u: invalid msecs specification; "
  35. "valid values are 0, 100-300000 in 100 increments\n",
  36. val);
  37. goto error_bad_value;
  38. }
  39. result = i2400m_set_idle_timeout(i2400m, val);
  40. if (result >= 0)
  41. result = size;
  42. error_no_unsigned:
  43. error_bad_value:
  44. return result;
  45. }
  46. static
  47. DEVICE_ATTR_WO(i2400m_idle_timeout);
  48. static
  49. struct attribute *i2400m_dev_attrs[] = {
  50. &dev_attr_i2400m_idle_timeout.attr,
  51. NULL,
  52. };
  53. struct attribute_group i2400m_dev_attr_group = {
  54. .name = NULL, /* we want them in the same directory */
  55. .attrs = i2400m_dev_attrs,
  56. };