@@ -110,6 +110,20 @@ int cdx_dev_reset(struct device *dev)
110
110
}
111
111
EXPORT_SYMBOL_GPL (cdx_dev_reset );
112
112
113
+ /**
114
+ * reset_cdx_device - Reset a CDX device
115
+ * @dev: CDX device
116
+ * @data: This is always passed as NULL, and is not used in this API,
117
+ * but is required here as the device_for_each_child() API expects
118
+ * the passed function to have this as an argument.
119
+ *
120
+ * Return: -errno on failure, 0 on success.
121
+ */
122
+ static int reset_cdx_device (struct device * dev , void * data )
123
+ {
124
+ return cdx_dev_reset (dev );
125
+ }
126
+
113
127
/**
114
128
* cdx_unregister_device - Unregister a CDX device
115
129
* @dev: CDX device
@@ -343,6 +357,7 @@ static DEVICE_ATTR_WO(remove);
343
357
static ssize_t reset_store (struct device * dev , struct device_attribute * attr ,
344
358
const char * buf , size_t count )
345
359
{
360
+ struct cdx_device * cdx_dev = to_cdx_device (dev );
346
361
bool val ;
347
362
int ret ;
348
363
@@ -352,11 +367,13 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
352
367
if (!val )
353
368
return - EINVAL ;
354
369
355
- ret = cdx_dev_reset (dev );
356
- if (ret )
357
- return ret ;
370
+ if (cdx_dev -> is_bus )
371
+ /* Reset all the devices attached to cdx bus */
372
+ ret = device_for_each_child (dev , NULL , reset_cdx_device );
373
+ else
374
+ ret = cdx_dev_reset (dev );
358
375
359
- return count ;
376
+ return ret < 0 ? ret : count ;
360
377
}
361
378
static DEVICE_ATTR_WO (reset );
362
379
@@ -461,6 +478,7 @@ static const struct attribute_group cdx_dev_group = {
461
478
462
479
static struct attribute * cdx_bus_dev_attrs [] = {
463
480
& dev_attr_enable .attr ,
481
+ & dev_attr_reset .attr ,
464
482
NULL ,
465
483
};
466
484
0 commit comments