In preparation to handle device reference counting inside of the sink drivers, add a return code to the sink::disable() operation so that proper action can be taken if a sink has not been disabled.
Unified · Split
| @@ -317,7 +317,7 @@ static void etb_disable_hw(struct etb_drvdata *drvdata) · 316 unmodified lines | ||
| 317 | 317 | coresight_disclaim_device(drvdata->base); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | −static void etb_disable(struct coresight_device *csdev) | |
| 320 | +static int etb_disable(struct coresight_device *csdev) | |
| 321 | 321 | { |
| 322 | 322 | struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
| 323 | 323 | unsigned long flags; |
| @@ -332,6 +332,7 @@ static void etb_disable(struct coresight_device *csdev) · 8 unmodified lines | ||
| 332 | 332 | spin_unlock_irqrestore(&drvdata->spinlock, flags); |
| 333 | 333 | |
| 334 | 334 | dev_dbg(drvdata->dev, "ETB disabled\n"); |
| 335 | + return 0; | |
| 335 | 336 | } |
| 336 | 337 | |
| 337 | 338 | static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, |
| @@ -273,7 +273,7 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev, · 272 unmodified lines | ||
| 273 | 273 | return 0; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | −static void tmc_disable_etf_sink(struct coresight_device *csdev) | |
| 276 | +static int tmc_disable_etf_sink(struct coresight_device *csdev) | |
| 277 | 277 | { |
| 278 | 278 | unsigned long flags; |
| 279 | 279 | struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
| @@ -281,7 +281,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev) · 1 unmodified line | ||
| 281 | 281 | spin_lock_irqsave(&drvdata->spinlock, flags); |
| 282 | 282 | if (drvdata->reading) { |
| 283 | 283 | spin_unlock_irqrestore(&drvdata->spinlock, flags); |
| 284 | − return; | |
| 284 | + return -EBUSY; | |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /* Disable the TMC only if it needs to */ |
| @@ -293,6 +293,7 @@ static void tmc_disable_etf_sink(struct coresight_device *csdev) · 5 unmodified lines | ||
| 293 | 293 | spin_unlock_irqrestore(&drvdata->spinlock, flags); |
| 294 | 294 | |
| 295 | 295 | dev_dbg(drvdata->dev, "TMC-ETB/ETF disabled\n"); |
| 296 | + return 0; | |
| 296 | 297 | } |
| 297 | 298 | |
| 298 | 299 | static int tmc_enable_etf_link(struct coresight_device *csdev, |
| @@ -1393,7 +1393,7 @@ static int tmc_enable_etr_sink(struct coresight_device *csdev, · 1392 unmodified lines | ||
| 1393 | 1393 | return -EINVAL; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | −static void tmc_disable_etr_sink(struct coresight_device *csdev) | |
| 1396 | +static int tmc_disable_etr_sink(struct coresight_device *csdev) | |
| 1397 | 1397 | { |
| 1398 | 1398 | unsigned long flags; |
| 1399 | 1399 | struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
| @@ -1401,7 +1401,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev) · 1 unmodified line | ||
| 1401 | 1401 | spin_lock_irqsave(&drvdata->spinlock, flags); |
| 1402 | 1402 | if (drvdata->reading) { |
| 1403 | 1403 | spin_unlock_irqrestore(&drvdata->spinlock, flags); |
| 1404 | − return; | |
| 1404 | + return -EBUSY; | |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | 1407 | /* Disable the TMC only if it needs to */ |
| @@ -1413,6 +1413,7 @@ static void tmc_disable_etr_sink(struct coresight_device *csdev) · 5 unmodified lines | ||
| 1413 | 1413 | spin_unlock_irqrestore(&drvdata->spinlock, flags); |
| 1414 | 1414 | |
| 1415 | 1415 | dev_dbg(drvdata->dev, "TMC-ETR disabled\n"); |
| 1416 | + return 0; | |
| 1416 | 1417 | } |
| 1417 | 1418 | |
| 1418 | 1419 | static const struct coresight_ops_sink tmc_etr_sink_ops = { |
| @@ -94,13 +94,14 @@ static void tpiu_disable_hw(struct tpiu_drvdata *drvdata) · 93 unmodified lines | ||
| 94 | 94 | CS_LOCK(drvdata->base); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | −static void tpiu_disable(struct coresight_device *csdev) | |
| 97 | +static int tpiu_disable(struct coresight_device *csdev) | |
| 98 | 98 | { |
| 99 | 99 | struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); |
| 100 | 100 | |
| 101 | 101 | tpiu_disable_hw(drvdata); |
| 102 | 102 | |
| 103 | 103 | dev_dbg(drvdata->dev, "TPIU disabled\n"); |
| 104 | + return 0; | |
| 104 | 105 | } |
| 105 | 106 | |
| 106 | 107 | static const struct coresight_ops_sink tpiu_sink_ops = { |
| @@ -239,9 +239,13 @@ static int coresight_enable_sink(struct coresight_device *csdev, · 238 unmodified lines | ||
| 239 | 239 | |
| 240 | 240 | static void coresight_disable_sink(struct coresight_device *csdev) |
| 241 | 241 | { |
| 242 | + int ret; | |
| 243 | + | |
| 242 | 244 | if (atomic_dec_return(csdev->refcnt) == 0) { |
| 243 | 245 | if (sink_ops(csdev)->disable) { |
| 244 | − sink_ops(csdev)->disable(csdev); | |
| 246 | + ret = sink_ops(csdev)->disable(csdev); | |
| 247 | + if (ret) | |
| 248 | + return; | |
| 245 | 249 | csdev->enable = false; |
| 246 | 250 | } |
| 247 | 251 | } |
| @@ -192,7 +192,7 @@ struct coresight_device { · 191 unmodified lines | ||
| 192 | 192 | */ |
| 193 | 193 | struct coresight_ops_sink { |
| 194 | 194 | int (*enable)(struct coresight_device *csdev, u32 mode, void *data); |
| 195 | − void (*disable)(struct coresight_device *csdev); | |
| 195 | + int (*disable)(struct coresight_device *csdev); | |
| 196 | 196 | void *(*alloc_buffer)(struct coresight_device *csdev, int cpu, |
| 197 | 197 | void **pages, int nr_pages, bool overwrite); |
| 198 | 198 | void (*free_buffer)(void *config); |