forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/usb/misc/cypress_cy7c63.c
....@@ -183,6 +183,7 @@
183183 {
184184 return read_port(dev, attr, buf, 0, CYPRESS_READ_PORT_ID0);
185185 }
186
+static DEVICE_ATTR_RW(port0);
186187
187188 /* attribute callback handler (read) */
188189 static ssize_t port1_show(struct device *dev,
....@@ -190,11 +191,14 @@
190191 {
191192 return read_port(dev, attr, buf, 1, CYPRESS_READ_PORT_ID1);
192193 }
193
-
194
-static DEVICE_ATTR_RW(port0);
195
-
196194 static DEVICE_ATTR_RW(port1);
197195
196
+static struct attribute *cypress_attrs[] = {
197
+ &dev_attr_port0.attr,
198
+ &dev_attr_port1.attr,
199
+ NULL,
200
+};
201
+ATTRIBUTE_GROUPS(cypress);
198202
199203 static int cypress_probe(struct usb_interface *interface,
200204 const struct usb_device_id *id)
....@@ -212,25 +216,10 @@
212216 /* save our data pointer in this interface device */
213217 usb_set_intfdata(interface, dev);
214218
215
- /* create device attribute files */
216
- retval = device_create_file(&interface->dev, &dev_attr_port0);
217
- if (retval)
218
- goto error;
219
- retval = device_create_file(&interface->dev, &dev_attr_port1);
220
- if (retval)
221
- goto error;
222
-
223219 /* let the user know that the device is now attached */
224220 dev_info(&interface->dev,
225221 "Cypress CY7C63xxx device now attached\n");
226222 return 0;
227
-
228
-error:
229
- device_remove_file(&interface->dev, &dev_attr_port0);
230
- device_remove_file(&interface->dev, &dev_attr_port1);
231
- usb_set_intfdata(interface, NULL);
232
- usb_put_dev(dev->udev);
233
- kfree(dev);
234223
235224 error_mem:
236225 return retval;
....@@ -242,9 +231,6 @@
242231
243232 dev = usb_get_intfdata(interface);
244233
245
- /* remove device attribute files */
246
- device_remove_file(&interface->dev, &dev_attr_port0);
247
- device_remove_file(&interface->dev, &dev_attr_port1);
248234 /* the intfdata can be set to NULL only after the
249235 * device files have been removed */
250236 usb_set_intfdata(interface, NULL);
....@@ -262,6 +248,7 @@
262248 .probe = cypress_probe,
263249 .disconnect = cypress_disconnect,
264250 .id_table = cypress_table,
251
+ .dev_groups = cypress_groups,
265252 };
266253
267254 module_usb_driver(cypress_driver);