Page MenuHomeFreeBSD

Avoid naming collisions between linuxkpi's struct device and FreeBSD's struct device
AcceptedPublic

Authored by kmacy on May 27 2016, 12:40 AM.

Details

Summary

Almost all of FreeBSD already refers to its native device structure as device_t. However, the underlying structure has the same name as linux's. This leads to bugs that the compiler can't catch when FreeBSD native drivers interface with linuxkpi based drivers and it makes it impossible to debug because only one struct device can be referred to when debugging core dumps. This patch renames FreeBSD's otherwise opaque struct device to struct device_ and fixes all of the straggling callers to use device_t.

The cxgbe iwarp code appears to be confused between the two device types.

Test Plan

None applicable. Compiled with LINT and buildworld.

Diff Detail

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

Event Timeline

kmacy retitled this revision from to Avoid naming collisions between linuxkpi's struct device and FreeBSD's struct device .
kmacy updated this object.
kmacy edited the test plan for this revision. (Show Details)
kmacy added reviewers: adrian, scottl, dumbbell.
kmacy set the repository for this revision to rS FreeBSD src repository - subversion.
kmacy added a reviewer: np.

Following the style of the rest of the typedefs in types.h, it should be __device and not device_ ?

Not sure if that applies. Actually using an __foo would look really odd.
Nonetheless, it just needs to be something other than device. I don't care
what it is.

Since devices are on a linked list, could we call it device_entry or something like that device_ looks odd to me :-)

That seems weird to me but kind of makes sense. Once it's done it's part of
the kbi for 11. So make sure others are ok with it.

sbruno edited edge metadata.

You may fire when ready.

This revision is now accepted and ready to land.May 29 2016, 5:15 PM
kmacy edited edge metadata.
kmacy added a subscriber: antoine.

Evidently device_t is a super popular name in ports. I've updated the patch so that the the one structure (pcpu) referenced by buildworld uses struct device_ * instead of device_t.

This revision now requires review to proceed.Jun 5 2016, 6:58 PM
kmacy edited edge metadata.

fix oversight in last update
thanks @antoine

Since the goal here is to take 'struct device' out of the public FreeBSD kernel API, it should be renamed to "_device" instead of "device_"

Did you try to compile a kernel WITH_OFED=YES. It will include the infiniband (CXGBE) parts.

Did you try to compile a kernel WITH_OFED=YES. It will include the infiniband (CXGBE) parts.

No, I didn't. I will :-)

This revision is now accepted and ready to land.May 24 2017, 6:15 PM
This revision is now accepted and ready to land.Apr 11 2018, 12:07 AM