Page MenuHomeFreeBSD

ACPI support for USB , mainly hub.
ClosedPublic

Authored by takawata on Jun 13 2019, 3:41 PM.

Details

Summary

ACPI supports USB related features.
This patch will do

  1. detects USB root hub if host controller has ACPI handle.
  2. Enumulate ACPI handles of USB ports and attach to device driver structure.
  3. Evaluate _UPC and _PLD objects under the ACPI objects of USB ports and parse them.

I think this patch is premature for merge, but I want to hear your opinion.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 24871
Build 23612: arc lint + arc unit

Event Timeline

takawata created this revision.Jun 13 2019, 3:41 PM
imp added a comment.Jun 13 2019, 3:47 PM

I've not looked deeply into this, but it seems to my limited understanding in the right direction, though I'll defer to hps@ should his opinion differ.
Just noted a couple of nits, plus there's some minor style issues with some of the code that we can get into once other comments are made to the source.

sys/dev/usb/usb_hub_acpi.c
9

The project template now omits "all rights reserved," and it's preferred that new code not have that unless the author really wants it. It is your choice, though.

#!/bin/sh

#
# This script should be run on every USB C- and H- file before
# commit to enforce correct style.
#

[ -z "$1" ] && (echo "Please specify a filename.") && exit

#
# The "-ta" option is an extension to indent.
# Contact hselasky@freebsd.org to receive a
# patch that adds support for this option to
# indent !
#

#
# sed -E 's/&\(([^, \)]*)\)/\&\1/' |
#

for F in $*
do

echo "Now styling $F"

(cat $F | indent -Toss_mixerinfo -TFILE -Tu_char -Tu_int -Tu_long \
 -TTAILQ_HEAD -TLIST_HEAD -TTAILQ_ENTRY -TLIST_ENTRY \
 -TSTAILQ_HEAD -TSTAILQ_ENTRY \
 -Tu_short -Tfd_set -ta -st -bad -bap -nbbb -nbc -br -nbs \
 -c41 -cd41 -cdb -ce -ci4 -cli0 -d0 -di8 -ndj -ei -nfc1 \
 -nfcb -i8 -ip8 -l79 -lc77 -ldi0 -nlp -npcs -psl -sc \
 -nsob -nv | 
 sed -e "s/_HEAD [(]/_HEAD(/g" |
 sed -e "s/_ENTRY [(]/_ENTRY(/g" |
 sed -e "s/     __packed/ __packed/g" | 
 sed -e "s/     __aligned/ __aligned/g" |
 sed -e "s/^#define /#define    /g") > temp

(diff temp $F > /dev/null) || (cp temp $F)

done

Can you pass the new files through the style script above?

^^^ only .c and .h files

hselasky added inline comments.Jun 13 2019, 4:22 PM
sys/dev/usb/usb_hub_acpi.c
111

remove this commented line

125

/* Found */

154

Spelling error Propritary

takawata updated this revision to Diff 58609.Jun 14 2019, 3:35 AM

Resolve comments.

hselasky added inline comments.Jun 14 2019, 9:55 AM
sys/dev/usb/usb_hub_acpi.c
80

Remove one empty line.

85

Insert an empty line before static UINT32 ...

105

uint8_t nports;

132

Add empty line before static int

146

Indent this line properly.

205

Wrap long line.

253

Can you move the curly bracket at the end of the line to the next line.

262

Address is 64-bit? Use cast when comparing.

devinfo->Address <= (uint64_t)sc->nports)

263

Looks off-by-one:
sc->porthandle[devinfo->Address - 1] = ah;

294

/* success prior than non - acpi hub */

319

Use device_printf() ??

348

This print does not look needed.

415

Remove this empty line.

426

Remove this empty line.

447

Remove one empty line here.

sys/dev/usb/usb_hub_private.h
38

Insert empty line before UHUB_INTR_INTERVAL.

Also use TAB after #define, before UHUB_INTR_INTERVAL.

sys/modules/usb/usb/Makefile
42

Will this build for all platforms? ARM, RISC, MIPS, SPARC ...

takawata updated this revision to Diff 58674.Jun 15 2019, 4:20 PM

Resolve comments.
Fix off-by-one error in acpi_usb_hub_port_probe_cb
Hide verbose outputs under debug flag.

hselasky added inline comments.Jun 17 2019, 6:55 PM
sys/dev/usb/usb_hub_acpi.c
311

Use /**/ comments.

hselasky accepted this revision.Jun 17 2019, 6:58 PM

Fix the last few comments I've added and this is ready to go.

This revision is now accepted and ready to land.Jun 17 2019, 6:58 PM
This revision was automatically updated to reflect the committed changes.