mirror of https://gitee.com/openkylin/linux.git
USB: atm: cxacru: convert to use dev_groups
USB drivers now support the ability for the driver core to handle the creation and removal of device-specific sysfs files in a race-free manner. Take advantage of that by converting the driver to use this by moving the sysfs attributes into a group and assigning the dev_groups pointer to it. Link: https://lore.kernel.org/r/20190806144502.17792-4-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ec935791ec
commit
e605c30977
|
@ -539,6 +539,37 @@ CXACRU_SET_##_action( adsl_config);
|
|||
|
||||
CXACRU_ALL_FILES(INIT);
|
||||
|
||||
static struct attribute *cxacru_attrs[] = {
|
||||
&dev_attr_adsl_config.attr,
|
||||
&dev_attr_adsl_state.attr,
|
||||
&dev_attr_adsl_controller_version.attr,
|
||||
&dev_attr_adsl_headend_environment.attr,
|
||||
&dev_attr_adsl_headend.attr,
|
||||
&dev_attr_modulation.attr,
|
||||
&dev_attr_line_startable.attr,
|
||||
&dev_attr_downstream_hec_errors.attr,
|
||||
&dev_attr_upstream_hec_errors.attr,
|
||||
&dev_attr_downstream_fec_errors.attr,
|
||||
&dev_attr_upstream_fec_errors.attr,
|
||||
&dev_attr_downstream_crc_errors.attr,
|
||||
&dev_attr_upstream_crc_errors.attr,
|
||||
&dev_attr_startup_attempts.attr,
|
||||
&dev_attr_downstream_bits_per_frame.attr,
|
||||
&dev_attr_upstream_bits_per_frame.attr,
|
||||
&dev_attr_transmitter_power.attr,
|
||||
&dev_attr_downstream_attenuation.attr,
|
||||
&dev_attr_upstream_attenuation.attr,
|
||||
&dev_attr_downstream_snr_margin.attr,
|
||||
&dev_attr_upstream_snr_margin.attr,
|
||||
&dev_attr_mac_address.attr,
|
||||
&dev_attr_line_status.attr,
|
||||
&dev_attr_link_status.attr,
|
||||
&dev_attr_upstream_rate.attr,
|
||||
&dev_attr_downstream_rate.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(cxacru);
|
||||
|
||||
/* the following three functions are stolen from drivers/usb/core/message.c */
|
||||
static void cxacru_blocking_completion(struct urb *urb)
|
||||
{
|
||||
|
@ -736,17 +767,6 @@ static int cxacru_card_status(struct cxacru_data *instance)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void cxacru_remove_device_files(struct usbatm_data *usbatm_instance,
|
||||
struct atm_dev *atm_dev)
|
||||
{
|
||||
struct usb_interface *intf = usbatm_instance->usb_intf;
|
||||
|
||||
#define CXACRU_DEVICE_REMOVE_FILE(_name) \
|
||||
device_remove_file(&intf->dev, &dev_attr_##_name);
|
||||
CXACRU_ALL_FILES(REMOVE);
|
||||
#undef CXACRU_DEVICE_REMOVE_FILE
|
||||
}
|
||||
|
||||
static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
|
||||
struct atm_dev *atm_dev)
|
||||
{
|
||||
|
@ -765,13 +785,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define CXACRU_DEVICE_CREATE_FILE(_name) \
|
||||
ret = device_create_file(&intf->dev, &dev_attr_##_name); \
|
||||
if (unlikely(ret)) \
|
||||
goto fail_sysfs;
|
||||
CXACRU_ALL_FILES(CREATE);
|
||||
#undef CXACRU_DEVICE_CREATE_FILE
|
||||
|
||||
/* start ADSL */
|
||||
mutex_lock(&instance->adsl_state_serialize);
|
||||
ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
|
||||
|
@ -804,11 +817,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
|
|||
if (start_polling)
|
||||
cxacru_poll_status(&instance->poll_work.work);
|
||||
return 0;
|
||||
|
||||
fail_sysfs:
|
||||
usb_err(usbatm_instance, "cxacru_atm_start: device_create_file failed (%d)\n", ret);
|
||||
cxacru_remove_device_files(usbatm_instance, atm_dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cxacru_poll_status(struct work_struct *work)
|
||||
|
@ -1332,7 +1340,6 @@ static struct usbatm_driver cxacru_driver = {
|
|||
.heavy_init = cxacru_heavy_init,
|
||||
.unbind = cxacru_unbind,
|
||||
.atm_start = cxacru_atm_start,
|
||||
.atm_stop = cxacru_remove_device_files,
|
||||
.bulk_in = CXACRU_EP_DATA,
|
||||
.bulk_out = CXACRU_EP_DATA,
|
||||
.rx_padding = 3,
|
||||
|
@ -1364,7 +1371,8 @@ static struct usb_driver cxacru_usb_driver = {
|
|||
.name = cxacru_driver_name,
|
||||
.probe = cxacru_usb_probe,
|
||||
.disconnect = usbatm_usb_disconnect,
|
||||
.id_table = cxacru_usb_ids
|
||||
.id_table = cxacru_usb_ids,
|
||||
.dev_groups = cxacru_groups,
|
||||
};
|
||||
|
||||
module_usb_driver(cxacru_usb_driver);
|
||||
|
|
Loading…
Reference in New Issue