Page MenuHomeFreeBSD

[GEOM/disk] Add function to find disk by device softc
AbandonedPublic

Authored by mizhka on May 16 2016, 10:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 26, 9:24 PM
Unknown Object (File)
Sep 12 2025, 4:35 PM
Unknown Object (File)
Sep 9 2025, 5:08 PM
Unknown Object (File)
Sep 5 2025, 8:43 PM
Unknown Object (File)
Sep 5 2025, 6:15 PM
Unknown Object (File)
Aug 12 2025, 5:40 AM
Unknown Object (File)
Jul 14 2025, 9:14 PM
Unknown Object (File)
Jul 6 2025, 11:57 PM

Details

Reviewers
sobomax
adrian
Summary

Hi,

This patch introduces simple function to find disk by device softc.

Use case is geom_flashmap. It provides way to register callback to identify slices on flash device. It passes device_t into callback, but flash size is required to calculate end of memory-mapped flash region. This functions helps to retrieve flash size of any device (CFI, SPI and so on).

Test Plan

Tested on Asus RT-N53 (SPI / mx25l)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

mizhka retitled this revision from to [GEOM/disk] Add function to find disk by device softc.
mizhka updated this object.
mizhka edited the test plan for this revision. (Show Details)
mizhka added reviewers: adrian, sobomax.
mizhka set the repository for this revision to rS FreeBSD src repository - subversion.

Why not just store the disk pointer in the softc?

I see 2 disadvantages of softc->disk reference:

  1. It requires setting of disks for all possible drivers (cfi, mx25l, at45 and etc.).
  2. fetch of disk will require casting+switch logic for all possible drivers.

Proposed method is isolated from driver implementation and softc structure type.