Changeset View
Standalone View
sys/dev/asmc/asmc.c
| Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | #define ASMC_LIGHT_FUNCS_10BYTE \ | ||||
| .smc_light_right = NULL, \ | .smc_light_right = NULL, \ | ||||
| .smc_light_control = asmc_mbp_sysctl_light_control | .smc_light_control = asmc_mbp_sysctl_light_control | ||||
| #define ASMC_LIGHT_FUNCS_DISABLED \ | #define ASMC_LIGHT_FUNCS_DISABLED \ | ||||
| .smc_light_left = NULL, \ | .smc_light_left = NULL, \ | ||||
| .smc_light_right = NULL, \ | .smc_light_right = NULL, \ | ||||
| .smc_light_control = NULL | .smc_light_control = NULL | ||||
| #define ASMC_TEMPS_FUNCS_DISABLED \ | |||||
| .smc_temps = {}, \ | |||||
| .smc_tempnames = {}, \ | |||||
| .smc_tempdescs = {}, \ | |||||
| static const struct asmc_model asmc_models[] = { | static const struct asmc_model asmc_models[] = { | ||||
| { | { | ||||
| "MacBook1,1", "Apple SMC MacBook Core Duo", | "MacBook1,1", "Apple SMC MacBook Core Duo", | ||||
| ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS_DISABLED, | ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS_DISABLED, | ||||
| ASMC_MB_TEMPS, ASMC_MB_TEMPNAMES, ASMC_MB_TEMPDESCS | ASMC_MB_TEMPS, ASMC_MB_TEMPNAMES, ASMC_MB_TEMPDESCS | ||||
| }, | }, | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | /* Idem for the Mac Pro 2013 (cylinder) */ | ||||
| ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS | ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS | ||||
| }, | }, | ||||
| { | { | ||||
| "MacBookAir7,2", "Apple SMC MacBook Air 13-inch (Early 2015)", | "MacBookAir7,2", "Apple SMC MacBook Air 13-inch (Early 2015)", | ||||
| ASMC_SMS_FUNCS_DISABLED, | ASMC_SMS_FUNCS_DISABLED, | ||||
| ASMC_FAN_FUNCS2, | ASMC_FAN_FUNCS2, | ||||
| ASMC_LIGHT_FUNCS, | ASMC_LIGHT_FUNCS, | ||||
| ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS | ASMC_MBA7_TEMPS, ASMC_MBA7_TEMPNAMES, ASMC_MBA7_TEMPDESCS | ||||
| } | |||||
| }; | |||||
| static const struct asmc_model asmc_generic_models[] = { | |||||
| { | |||||
| .smc_model = "MacBookAir", | |||||
| .smc_desc = NULL, | |||||
| ASMC_SMS_FUNCS_DISABLED, | |||||
| ASMC_FAN_FUNCS2, | |||||
| ASMC_LIGHT_FUNCS, | |||||
| ASMC_TEMPS_FUNCS_DISABLED, | |||||
| }, | }, | ||||
| { NULL, NULL } | { | ||||
| .smc_model = "MacBookPro", | |||||
| .smc_desc = NULL, | |||||
| ASMC_SMS_FUNCS_DISABLED, | |||||
| ASMC_FAN_FUNCS2, | |||||
| ASMC_LIGHT_FUNCS, | |||||
| ASMC_TEMPS_FUNCS_DISABLED, | |||||
| }, | |||||
| { | |||||
| .smc_model = "MacPro", | |||||
| .smc_desc = NULL, | |||||
| ASMC_SMS_FUNCS_DISABLED, | |||||
| ASMC_FAN_FUNCS2, | |||||
| ASMC_LIGHT_FUNCS_DISABLED, | |||||
| ASMC_TEMPS_FUNCS_DISABLED, | |||||
| }, | |||||
| { | |||||
| .smc_model = "Macmini", | |||||
| .smc_desc = NULL, | |||||
| ASMC_SMS_FUNCS_DISABLED, | |||||
| ASMC_FAN_FUNCS2, | |||||
| ASMC_LIGHT_FUNCS_DISABLED, | |||||
| ASMC_TEMPS_FUNCS_DISABLED, | |||||
| } | |||||
| }; | }; | ||||
| #undef ASMC_SMS_FUNCS | #undef ASMC_SMS_FUNCS | ||||
| #undef ASMC_SMS_FUNCS_DISABLED | #undef ASMC_SMS_FUNCS_DISABLED | ||||
| #undef ASMC_FAN_FUNCS | #undef ASMC_FAN_FUNCS | ||||
| #undef ASMC_FAN_FUNCS2 | #undef ASMC_FAN_FUNCS2 | ||||
| #undef ASMC_LIGHT_FUNCS | #undef ASMC_LIGHT_FUNCS | ||||
| Show All 36 Lines | |||||
| static const struct asmc_model * | static const struct asmc_model * | ||||
| asmc_match(device_t dev) | asmc_match(device_t dev) | ||||
| { | { | ||||
| int i; | int i; | ||||
| char *model; | char *model; | ||||
| model = kern_getenv("smbios.system.product"); | model = kern_getenv("smbios.system.product"); | ||||
| if (model == NULL) | if (model == NULL) | ||||
| return (NULL); | return (NULL); | ||||
kib: This might be `goto out;` as well. | |||||
Done Inline ActionsIt's not strictly required since the only resource needing to be free'd (model_name) hasn't been properly allocated, but I'll do it for the sake of consistency. ngie: It's not strictly required since the only resource needing to be free'd (`model_name`) hasn't… | |||||
| for (i = 0; asmc_models[i].smc_model; i++) { | for (i = 0; i < nitems(asmc_models); i++) { | ||||
| if (!strncmp(model, asmc_models[i].smc_model, strlen(model))) { | if (strncmp(model, asmc_models[i].smc_model, strlen(model)) == 0) { | ||||
| freeenv(model); | freeenv(model); | ||||
| return (&asmc_models[i]); | return (&asmc_models[i]); | ||||
| } | } | ||||
| } | } | ||||
| for (i = 0; i < nitems(asmc_generic_models); i++) { | |||||
| const char *generic_smc_model = asmc_generic_models[i].smc_model; | |||||
| if (strncmp(model, generic_smc_model, strlen(generic_smc_model)) | |||||
Done Inline ActionsThere should be blank line before this. kib: There should be blank line before this. | |||||
| == 0) { | |||||
| device_printf(dev, | |||||
| "generic model found for: %s; please submit output " | |||||
| "from `sysctl dev.asmc.0` to bugs.FreeBSD.org\n", | |||||
| model); | |||||
Done Inline ActionsThis is anything but terse. All this stuff belongs to either comment above, or to the man page. kib: This is anything but terse. All this stuff belongs to either comment above, or to the man page. | |||||
Done Inline Actions
Yeah. I have mixed feelings about outputting information like this, so I agree: your comment is valid. Would you propose saying something like this to the manpage? DIAGNOSTICS .Pp .Bl -diag .It "asmc0: generic model detected" Model specific quirks not applied for a given model. Partial SMC support is enabled and some features might not function properly. ngie: > This is anything but terse. All this stuff belongs to either comment above, or to the man… | |||||
Done Inline ActionsPS This is a classic example of me trying to be helpful to end-users and encourage data gathering to improve the driver. ngie: PS This is a classic example of me trying to be helpful to end-users and encourage data… | |||||
Not Done Inline Actions@ziaee : do you have any thoughts on the manpage suggestion in the thread? DIAGNOSTICS .Pp .Bl -diag .It "asmc0: generic model detected" Model specific quirks not applied. Partial SMC support is enabled. Some features, e.g., sensors, fans, lights, etc, might not function properly. ngie: @ziaee : do you have any thoughts on the manpage suggestion in the thread?
This seems a bit… | |||||
| freeenv(model); | freeenv(model); | ||||
| return (&asmc_generic_models[i]); | |||||
| } | |||||
| } | |||||
| freeenv(model); | |||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| static int | static int | ||||
| asmc_probe(device_t dev) | asmc_probe(device_t dev) | ||||
| { | { | ||||
| const struct asmc_model *model; | const struct asmc_model *model; | ||||
| const char *device_desc; | |||||
| int rv; | int rv; | ||||
| if (resource_disabled("asmc", 0)) | if (resource_disabled("asmc", 0)) | ||||
| return (ENXIO); | return (ENXIO); | ||||
| rv = ACPI_ID_PROBE(device_get_parent(dev), dev, asmc_ids, NULL); | rv = ACPI_ID_PROBE(device_get_parent(dev), dev, asmc_ids, NULL); | ||||
| if (rv > 0) | if (rv > 0) | ||||
| return (rv); | return (rv); | ||||
| model = asmc_match(dev); | model = asmc_match(dev); | ||||
| if (!model) { | if (model == NULL) { | ||||
| device_printf(dev, "model not recognized\n"); | device_printf(dev, "model not recognized\n"); | ||||
| return (ENXIO); | return (ENXIO); | ||||
| } | } | ||||
| device_set_desc(dev, model->smc_desc); | device_desc = model->smc_desc == NULL ? | ||||
| model->smc_model : model->smc_desc; | |||||
| device_set_desc(dev, device_desc); | |||||
| return (rv); | return (rv); | ||||
| } | } | ||||
| static int | static int | ||||
| asmc_attach(device_t dev) | asmc_attach(device_t dev) | ||||
| { | { | ||||
| int i, j; | int i, j; | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | asmc_attach(device_t dev) | ||||
| /* | /* | ||||
| * dev.asmc.n.temp tree. | * dev.asmc.n.temp tree. | ||||
| */ | */ | ||||
| sc->sc_temp_tree = SYSCTL_ADD_NODE(sysctlctx, | sc->sc_temp_tree = SYSCTL_ADD_NODE(sysctlctx, | ||||
| SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "temp", | SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "temp", | ||||
| CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Temperature sensors"); | CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "Temperature sensors"); | ||||
| for (i = 0; model->smc_temps[i]; i++) { | for (i = 0; nitems(model->smc_temps); i++) { | ||||
| SYSCTL_ADD_PROC(sysctlctx, | SYSCTL_ADD_PROC(sysctlctx, | ||||
| SYSCTL_CHILDREN(sc->sc_temp_tree), | SYSCTL_CHILDREN(sc->sc_temp_tree), | ||||
| OID_AUTO, model->smc_tempnames[i], | OID_AUTO, model->smc_tempnames[i], | ||||
| CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, | CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE, | ||||
| dev, i, asmc_temp_sysctl, "I", | dev, i, asmc_temp_sysctl, "I", | ||||
| model->smc_tempdescs[i]); | model->smc_tempdescs[i]); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 996 Lines • Show Last 20 Lines | |||||
This might be goto out; as well.