| .. | .. |
|---|
| 230 | 230 | |
|---|
| 231 | 231 | static ssize_t cxacru_sysfs_showattr_u32(u32 value, char *buf) |
|---|
| 232 | 232 | { |
|---|
| 233 | | - return snprintf(buf, PAGE_SIZE, "%u\n", value); |
|---|
| 233 | + return sprintf(buf, "%u\n", value); |
|---|
| 234 | 234 | } |
|---|
| 235 | 235 | |
|---|
| 236 | 236 | static ssize_t cxacru_sysfs_showattr_s8(s8 value, char *buf) |
|---|
| 237 | 237 | { |
|---|
| 238 | | - return snprintf(buf, PAGE_SIZE, "%d\n", value); |
|---|
| 238 | + return sprintf(buf, "%d\n", value); |
|---|
| 239 | 239 | } |
|---|
| 240 | 240 | |
|---|
| 241 | 241 | static ssize_t cxacru_sysfs_showattr_dB(s16 value, char *buf) |
|---|
| .. | .. |
|---|
| 255 | 255 | static char *str[] = { "no", "yes" }; |
|---|
| 256 | 256 | |
|---|
| 257 | 257 | 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]); |
|---|
| 260 | 260 | } |
|---|
| 261 | 261 | |
|---|
| 262 | 262 | static ssize_t cxacru_sysfs_showattr_LINK(u32 value, char *buf) |
|---|
| .. | .. |
|---|
| 264 | 264 | static char *str[] = { NULL, "not connected", "connected", "lost" }; |
|---|
| 265 | 265 | |
|---|
| 266 | 266 | 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]); |
|---|
| 269 | 269 | } |
|---|
| 270 | 270 | |
|---|
| 271 | 271 | static ssize_t cxacru_sysfs_showattr_LINE(u32 value, char *buf) |
|---|
| .. | .. |
|---|
| 275 | 275 | "waiting", "initialising" |
|---|
| 276 | 276 | }; |
|---|
| 277 | 277 | 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]); |
|---|
| 280 | 280 | } |
|---|
| 281 | 281 | |
|---|
| 282 | 282 | static ssize_t cxacru_sysfs_showattr_MODU(u32 value, char *buf) |
|---|
| .. | .. |
|---|
| 288 | 288 | "ITU-T G.992.2 (G.LITE)" |
|---|
| 289 | 289 | }; |
|---|
| 290 | 290 | 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]); |
|---|
| 293 | 293 | } |
|---|
| 294 | 294 | |
|---|
| 295 | 295 | /* |
|---|
| .. | .. |
|---|
| 309 | 309 | if (instance == NULL || instance->usbatm->atm_dev == NULL) |
|---|
| 310 | 310 | return -ENODEV; |
|---|
| 311 | 311 | |
|---|
| 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); |
|---|
| 314 | 313 | } |
|---|
| 315 | 314 | |
|---|
| 316 | 315 | static ssize_t adsl_state_show(struct device *dev, |
|---|
| .. | .. |
|---|
| 326 | 325 | |
|---|
| 327 | 326 | value = instance->card_info[CXINF_LINE_STARTABLE]; |
|---|
| 328 | 327 | 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]); |
|---|
| 331 | 330 | } |
|---|
| 332 | 331 | |
|---|
| 333 | 332 | static ssize_t adsl_state_store(struct device *dev, |
|---|
| .. | .. |
|---|
| 408 | 407 | case CXPOLL_STOPPING: |
|---|
| 409 | 408 | /* abort stop request */ |
|---|
| 410 | 409 | instance->poll_state = CXPOLL_POLLING; |
|---|
| 411 | | - /* fall through */ |
|---|
| 410 | + fallthrough; |
|---|
| 412 | 411 | case CXPOLL_POLLING: |
|---|
| 413 | 412 | case CXPOLL_SHUTDOWN: |
|---|
| 414 | 413 | /* don't start polling */ |
|---|
| .. | .. |
|---|
| 538 | 537 | CXACRU_SET_##_action( adsl_config); |
|---|
| 539 | 538 | |
|---|
| 540 | 539 | 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); |
|---|
| 541 | 571 | |
|---|
| 542 | 572 | /* the following three functions are stolen from drivers/usb/core/message.c */ |
|---|
| 543 | 573 | static void cxacru_blocking_completion(struct urb *urb) |
|---|
| .. | .. |
|---|
| 736 | 766 | return 0; |
|---|
| 737 | 767 | } |
|---|
| 738 | 768 | |
|---|
| 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 | | - |
|---|
| 750 | 769 | static int cxacru_atm_start(struct usbatm_data *usbatm_instance, |
|---|
| 751 | 770 | struct atm_dev *atm_dev) |
|---|
| 752 | 771 | { |
|---|
| .. | .. |
|---|
| 765 | 784 | return ret; |
|---|
| 766 | 785 | } |
|---|
| 767 | 786 | |
|---|
| 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 | | - |
|---|
| 775 | 787 | /* start ADSL */ |
|---|
| 776 | 788 | mutex_lock(&instance->adsl_state_serialize); |
|---|
| 777 | 789 | ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); |
|---|
| .. | .. |
|---|
| 789 | 801 | case CXPOLL_STOPPING: |
|---|
| 790 | 802 | /* abort stop request */ |
|---|
| 791 | 803 | instance->poll_state = CXPOLL_POLLING; |
|---|
| 792 | | - /* fall through */ |
|---|
| 804 | + fallthrough; |
|---|
| 793 | 805 | case CXPOLL_POLLING: |
|---|
| 794 | 806 | case CXPOLL_SHUTDOWN: |
|---|
| 795 | 807 | /* don't start polling */ |
|---|
| .. | .. |
|---|
| 804 | 816 | if (start_polling) |
|---|
| 805 | 817 | cxacru_poll_status(&instance->poll_work.work); |
|---|
| 806 | 818 | 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; |
|---|
| 812 | 819 | } |
|---|
| 813 | 820 | |
|---|
| 814 | 821 | static void cxacru_poll_status(struct work_struct *work) |
|---|
| .. | .. |
|---|
| 1332 | 1339 | .heavy_init = cxacru_heavy_init, |
|---|
| 1333 | 1340 | .unbind = cxacru_unbind, |
|---|
| 1334 | 1341 | .atm_start = cxacru_atm_start, |
|---|
| 1335 | | - .atm_stop = cxacru_remove_device_files, |
|---|
| 1336 | 1342 | .bulk_in = CXACRU_EP_DATA, |
|---|
| 1337 | 1343 | .bulk_out = CXACRU_EP_DATA, |
|---|
| 1338 | 1344 | .rx_padding = 3, |
|---|
| .. | .. |
|---|
| 1364 | 1370 | .name = cxacru_driver_name, |
|---|
| 1365 | 1371 | .probe = cxacru_usb_probe, |
|---|
| 1366 | 1372 | .disconnect = usbatm_usb_disconnect, |
|---|
| 1367 | | - .id_table = cxacru_usb_ids |
|---|
| 1373 | + .id_table = cxacru_usb_ids, |
|---|
| 1374 | + .dev_groups = cxacru_groups, |
|---|
| 1368 | 1375 | }; |
|---|
| 1369 | 1376 | |
|---|
| 1370 | 1377 | module_usb_driver(cxacru_usb_driver); |
|---|