forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/usb/atm/cxacru.c
....@@ -230,12 +230,12 @@
230230
231231 static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf)
232232 {
233
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
233
+ return sprintf(buf, "%u\n", value);
234234 }
235235
236236 static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf)
237237 {
238
- return snprintf(buf, PAGE_SIZE, "%d\n", value);
238
+ return sprintf(buf, "%d\n", value);
239239 }
240240
241241 static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf)
....@@ -255,8 +255,8 @@
255255 static char *str[] = { "no", "yes" };
256256
257257 if (unlikely(value >= ARRAY_SIZE(str)))
258
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
259
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
258
+ return sprintf(buf, "%u\n", value);
259
+ return sprintf(buf, "%s\n", str[value]);
260260 }
261261
262262 static ssize_t cxacru_sysfs_showattr_LINK(u32 value, char *buf)
....@@ -264,8 +264,8 @@
264264 static char *str[] = { NULL, "not connected", "connected", "lost" };
265265
266266 if (unlikely(value >= ARRAY_SIZE(str) || str[value] == NULL))
267
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
268
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
267
+ return sprintf(buf, "%u\n", value);
268
+ return sprintf(buf, "%s\n", str[value]);
269269 }
270270
271271 static ssize_t cxacru_sysfs_showattr_LINE(u32 value, char *buf)
....@@ -275,8 +275,8 @@
275275 "waiting", "initialising"
276276 };
277277 if (unlikely(value >= ARRAY_SIZE(str)))
278
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
279
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
278
+ return sprintf(buf, "%u\n", value);
279
+ return sprintf(buf, "%s\n", str[value]);
280280 }
281281
282282 static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf)
....@@ -288,8 +288,8 @@
288288 "ITU-T G.992.2 (G.LITE)"
289289 };
290290 if (unlikely(value >= ARRAY_SIZE(str)))
291
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
292
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
291
+ return sprintf(buf, "%u\n", value);
292
+ return sprintf(buf, "%s\n", str[value]);
293293 }
294294
295295 /*
....@@ -309,8 +309,7 @@
309309 if (instance == NULL || instance->usbatm->atm_dev == NULL)
310310 return -ENODEV;
311311
312
- return snprintf(buf, PAGE_SIZE, "%pM\n",
313
- instance->usbatm->atm_dev->esi);
312
+ return sprintf(buf, "%pM\n", instance->usbatm->atm_dev->esi);
314313 }
315314
316315 static ssize_t adsl_state_show(struct device *dev,
....@@ -326,8 +325,8 @@
326325
327326 value = instance->card_info[CXINF_LINE_STARTABLE];
328327 if (unlikely(value >= ARRAY_SIZE(str)))
329
- return snprintf(buf, PAGE_SIZE, "%u\n", value);
330
- return snprintf(buf, PAGE_SIZE, "%s\n", str[value]);
328
+ return sprintf(buf, "%u\n", value);
329
+ return sprintf(buf, "%s\n", str[value]);
331330 }
332331
333332 static ssize_t adsl_state_store(struct device *dev,
....@@ -408,7 +407,7 @@
408407 case CXPOLL_STOPPING:
409408 /* abort stop request */
410409 instance->poll_state = CXPOLL_POLLING;
411
- /* fall through */
410
+ fallthrough;
412411 case CXPOLL_POLLING:
413412 case CXPOLL_SHUTDOWN:
414413 /* don't start polling */
....@@ -538,6 +537,37 @@
538537 CXACRU_SET_##_action( adsl_config);
539538
540539 CXACRU_ALL_FILES(INIT);
540
+
541
+static struct attribute *cxacru_attrs[] = {
542
+ &dev_attr_adsl_config.attr,
543
+ &dev_attr_adsl_state.attr,
544
+ &dev_attr_adsl_controller_version.attr,
545
+ &dev_attr_adsl_headend_environment.attr,
546
+ &dev_attr_adsl_headend.attr,
547
+ &dev_attr_modulation.attr,
548
+ &dev_attr_line_startable.attr,
549
+ &dev_attr_downstream_hec_errors.attr,
550
+ &dev_attr_upstream_hec_errors.attr,
551
+ &dev_attr_downstream_fec_errors.attr,
552
+ &dev_attr_upstream_fec_errors.attr,
553
+ &dev_attr_downstream_crc_errors.attr,
554
+ &dev_attr_upstream_crc_errors.attr,
555
+ &dev_attr_startup_attempts.attr,
556
+ &dev_attr_downstream_bits_per_frame.attr,
557
+ &dev_attr_upstream_bits_per_frame.attr,
558
+ &dev_attr_transmitter_power.attr,
559
+ &dev_attr_downstream_attenuation.attr,
560
+ &dev_attr_upstream_attenuation.attr,
561
+ &dev_attr_downstream_snr_margin.attr,
562
+ &dev_attr_upstream_snr_margin.attr,
563
+ &dev_attr_mac_address.attr,
564
+ &dev_attr_line_status.attr,
565
+ &dev_attr_link_status.attr,
566
+ &dev_attr_upstream_rate.attr,
567
+ &dev_attr_downstream_rate.attr,
568
+ NULL,
569
+};
570
+ATTRIBUTE_GROUPS(cxacru);
541571
542572 /* the following three functions are stolen from drivers/usb/core/message.c */
543573 static void cxacru_blocking_completion(struct urb *urb)
....@@ -736,17 +766,6 @@
736766 return 0;
737767 }
738768
739
-static void cxacru_remove_device_files(struct usbatm_data *usbatm_instance,
740
- struct atm_dev *atm_dev)
741
-{
742
- struct usb_interface *intf = usbatm_instance->usb_intf;
743
-
744
- #define CXACRU_DEVICE_REMOVE_FILE(_name) \
745
- device_remove_file(&intf->dev, &dev_attr_##_name);
746
- CXACRU_ALL_FILES(REMOVE);
747
- #undef CXACRU_DEVICE_REMOVE_FILE
748
-}
749
-
750769 static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
751770 struct atm_dev *atm_dev)
752771 {
....@@ -765,13 +784,6 @@
765784 return ret;
766785 }
767786
768
- #define CXACRU_DEVICE_CREATE_FILE(_name) \
769
- ret = device_create_file(&intf->dev, &dev_attr_##_name); \
770
- if (unlikely(ret)) \
771
- goto fail_sysfs;
772
- CXACRU_ALL_FILES(CREATE);
773
- #undef CXACRU_DEVICE_CREATE_FILE
774
-
775787 /* start ADSL */
776788 mutex_lock(&instance->adsl_state_serialize);
777789 ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
....@@ -789,7 +801,7 @@
789801 case CXPOLL_STOPPING:
790802 /* abort stop request */
791803 instance->poll_state = CXPOLL_POLLING;
792
- /* fall through */
804
+ fallthrough;
793805 case CXPOLL_POLLING:
794806 case CXPOLL_SHUTDOWN:
795807 /* don't start polling */
....@@ -804,11 +816,6 @@
804816 if (start_polling)
805817 cxacru_poll_status(&instance->poll_work.work);
806818 return 0;
807
-
808
-fail_sysfs:
809
- usb_err(usbatm_instance, "cxacru_atm_start: device_create_file failed (%d)\n", ret);
810
- cxacru_remove_device_files(usbatm_instance, atm_dev);
811
- return ret;
812819 }
813820
814821 static void cxacru_poll_status(struct work_struct *work)
....@@ -1332,7 +1339,6 @@
13321339 .heavy_init = cxacru_heavy_init,
13331340 .unbind = cxacru_unbind,
13341341 .atm_start = cxacru_atm_start,
1335
- .atm_stop = cxacru_remove_device_files,
13361342 .bulk_in = CXACRU_EP_DATA,
13371343 .bulk_out = CXACRU_EP_DATA,
13381344 .rx_padding = 3,
....@@ -1364,7 +1370,8 @@
13641370 .name = cxacru_driver_name,
13651371 .probe = cxacru_usb_probe,
13661372 .disconnect = usbatm_usb_disconnect,
1367
- .id_table = cxacru_usb_ids
1373
+ .id_table = cxacru_usb_ids,
1374
+ .dev_groups = cxacru_groups,
13681375 };
13691376
13701377 module_usb_driver(cxacru_usb_driver);