+void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match*impl_match)
+{
+ struct device *dev;
+ struct arm_cspmu_impl_match *match;
+
+ match = arm_cspmu_impl_match_get(impl_match->pmiidr_val);
+
+ WARN_ON(!match);
+
+ if (match) {
+ /* Unbind the driver from all matching backend devices. */
+dev_release:
+ dev = driver_find_device(&arm_cspmu_driver.driver, NULL,
+ match, arm_cspmu_match_device);
+ if (dev) {
+ device_release_driver(dev);
+ goto dev_release;
+ }
minor nit: We could simply do :
static int arm_cspmu_release_driver(struct device *dev, void *data)
{
struct arm_cspmu *cspmu =
platform_get_drvdata(to_platform_device(dev));
if (cspmu && cspmu->impl.match == match)
device_release_driver(dev);
return 0;
}
ret = driver_for_each_device(&driver, NULL, match,
arm_csmpu_release_driver);
It doesn’t seem to work for me.
Is it safe to release while iterating via driver_for_each_device ?