/** * pinmux_free_gpio() - release a pin from GPIO muxing * @pctldev: the pin controller device for the pin * @pin: the affected currently GPIO-muxed in pin * @range: applicable GPIO range */ void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin, struct pinctrl_gpio_range *range) { const char *owner; owner = pin_free(pctldev, pin, range); kfree(owner); }
void pinmux_disable_setting(struct pinctrl_setting const *setting) { struct pinctrl_dev *pctldev = setting->pctldev; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; int ret = 0; const unsigned *pins = NULL; unsigned num_pins = 0; int i; struct pin_desc *desc; if (pctlops->get_group_pins) ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, &num_pins); if (ret) { const char *gname; /* errors only affect debug data, so just warn */ gname = pctlops->get_group_name(pctldev, setting->data.mux.group); dev_warn(pctldev->dev, "could not get pins for group %s\n", gname); num_pins = 0; } /* Flag the descs that no setting is active */ for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } if (desc->mux_setting == &(setting->data.mux)) { desc->mux_setting = NULL; /* And release the pin */ pin_free(pctldev, pins[i], NULL); } else { const char *gname; gname = pctlops->get_group_name(pctldev, setting->data.mux.group); dev_warn(pctldev->dev, "not freeing pin %d (%s) as part of " "deactivating group %s - it is already " "used for some other setting", pins[i], desc->name, gname); } } }
void pinmux_disable_setting(struct pinctrl_setting const *setting) { struct pinctrl_dev *pctldev = setting->pctldev; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinmux_ops *ops = pctldev->desc->pmxops; int ret; const unsigned *pins; unsigned num_pins; int i; struct pin_desc *desc; ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, &num_pins); if (ret) { /* errors only affect debug data, so just warn */ dev_warn(pctldev->dev, "could not get pins for group selector %d\n", setting->data.mux.group); num_pins = 0; } /* Flag the descs that no setting is active */ for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } desc->mux_setting = NULL; } /* And release the pins */ for (i = 0; i < num_pins; i++) pin_free(pctldev, pins[i], NULL); if (ops->disable) ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group); }
void pinmux_disable_setting(struct pinctrl_setting const *setting) { struct pinctrl_dev *pctldev = setting->pctldev; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinmux_ops *ops = pctldev->desc->pmxops; int ret; const unsigned *pins; unsigned num_pins; int i; struct pin_desc *desc; ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, &num_pins); if (ret) { dev_warn(pctldev->dev, "could not get pins for group selector %d\n", setting->data.mux.group); num_pins = 0; } for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } desc->mux_setting = NULL; } for (i = 0; i < num_pins; i++) pin_free(pctldev, pins[i], NULL); if (ops->disable) ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group); }
/******************************************************************* * Main * * This sets up the parameters and then calls the FM. * *******************************************************************/ int main( int argc, char *argv[]) { pcm_context_t *ctxp; pin_flist_t *flistp = NULL; pin_flist_t *a_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *acct_pdp = NULL; poid_t *srvc_pdp = NULL; u_int opcode; int64 database; void *vp; char logfile[256]; char *c_ptr = (char *)NULL; char *program; int32 err; pin_errbuf_t ebuf; PIN_ERR_CLEAR_ERR(&ebuf); /* * Logging initialization */ program = basename(argv[0]); PIN_ERR_SET_PROGRAM(program); PIN_ERR_SET_LEVEL(PIN_ERR_LEVEL_WARNING); strcpy(logfile, "default.pinlog"); pin_conf(program, "logfile", PIN_FLDT_STR, (caddr_t *)&(c_ptr), &err); if (c_ptr != (char *)NULL) { pin_strlcpy(logfile, c_ptr, sizeof(logfile)); pin_free(c_ptr); c_ptr = (char *)NULL; } PIN_ERR_SET_LOGFILE(logfile); /* * Check the input. */ if (argc != 3) { usage(argv[0]); PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_ERROR, "bad # of arguments"); exit(1); } /* * Initialize PCM connection. */ PCM_CONNECT(&ctxp, &database, &ebuf); if (PIN_ERR_IS_ERR(&ebuf)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "pcm_connect error", &ebuf); exit(2); } /* * Create the poid prototype. */ srvc_pdp = PIN_POID_CREATE(database, argv[1], 0, &ebuf); /* * Look up the account. */ flistp = PIN_FLIST_CREATE(&ebuf); vp = (void *)srvc_pdp; PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID, vp, &ebuf); vp = (void *)argv[2]; PIN_FLIST_FLD_SET(flistp, PIN_FLD_LOGIN, vp, &ebuf); opcode = PCM_OP_ACT_FIND; PCM_OP(ctxp, opcode, 0, flistp, &a_flistp, &ebuf); /* * Did we find anything? */ acct_pdp = PIN_FLIST_FLD_GET(a_flistp, PIN_FLD_ACCOUNT_OBJ, 0, &ebuf); if (!PIN_POID_IS_NULL(acct_pdp)) { /* * Advisory (or add confirm?) */ fprintf(stdout, "Deleting Account:\t"); pin_poid_print(acct_pdp, 0, &ebuf); fprintf(stdout, "\n"); /* * Put the real account poid on the flist * (The account_obj field will just be ignored) */ vp = (void *)acct_pdp; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, vp, &ebuf); /* * Delete the account. */ opcode = PCM_OP_CUST_DELETE_ACCT; PCM_OP(ctxp, opcode, 0, a_flistp, &r_flistp, &ebuf); /* * Did we delete or not? */ if (PIN_ERR_IS_ERR(&ebuf)) { fprintf(stdout, "Account Deletion Error Occurred.\n"); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_delete_acct error", &ebuf); } else { fprintf(stdout, "Account Deleted.\n"); } } else { /* * FIND error. */ fprintf(stdout, "Unable to locate Account.\n"); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_act_find error", &ebuf); } /* * Close the PCM context. */ PCM_CONTEXT_CLOSE(ctxp, 0, &ebuf); /* * Clean up. */ /* Free local memory. */ PIN_FLIST_DESTROY(flistp, NULL); PIN_FLIST_DESTROY(a_flistp, NULL); PIN_FLIST_DESTROY(r_flistp, NULL); /* No errors. */ return(0); }
/******************************************************************* * MAIN *******************************************************************/ int main( int argc, char *argv[]) { pcm_context_t *ctxp = NULL; pin_errbuf_t ebuf; int64 database; char logfile[256]; char *c_ptr = (char *)NULL; char *program; int32 err; /*********************************************************** * Clear the error buffer (for safety). ***********************************************************/ PIN_ERR_CLEAR_ERR(&ebuf); /*********************************************************** * Logging initialization ***********************************************************/ program = basename(argv[0]); PIN_ERR_SET_PROGRAM(program); PIN_ERR_SET_LEVEL(PIN_ERR_LEVEL_WARNING); strcpy(logfile, "default.pinlog"); pin_conf(program, "logfile", PIN_FLDT_STR, (caddr_t *)&(c_ptr), &err); if (c_ptr != (char *)NULL) { pin_strlcpy(logfile, c_ptr, sizeof(logfile)); pin_free(c_ptr); c_ptr = (char *)NULL; } PIN_ERR_SET_LOGFILE(logfile); /*********************************************************** * Open the database context ***********************************************************/ PCM_CONNECT(&ctxp, &database, &ebuf); /*********************************************************** * Simple Read Object Search. ***********************************************************/ sample_read_obj_search(ctxp, database, &ebuf); /*********************************************************** * Create the service. ***********************************************************/ sample_read_flds_search(ctxp, database, &ebuf); /*********************************************************** * Step search sample. ***********************************************************/ sample_step_search(ctxp, database, &ebuf); /*********************************************************** * See if all went well. ***********************************************************/ if (PIN_ERR_IS_ERR(&ebuf)) { fprintf(stderr, "\nTest Failed, See Log File\n\n"); } else { fprintf(stderr, "\nTest Suceeded\n\n"); } /*********************************************************** * Close the database channel (a formality since we exit). ***********************************************************/ PCM_CONTEXT_CLOSE(ctxp, 0, &ebuf); return(0); }
int pinmux_enable_setting(struct pinctrl_setting const *setting) { struct pinctrl_dev *pctldev = setting->pctldev; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinmux_ops *ops = pctldev->desc->pmxops; int ret; const unsigned *pins; unsigned num_pins; int i; struct pin_desc *desc; ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, &num_pins); if (ret) { /* errors only affect debug data, so just warn */ dev_warn(pctldev->dev, "could not get pins for group selector %d\n", setting->data.mux.group); num_pins = 0; } /* Try to allocate all pins in this group, one by one */ for (i = 0; i < num_pins; i++) { ret = pin_request(pctldev, pins[i], setting->dev_name, NULL); if (ret) { dev_err(pctldev->dev, "could not request pin %d on device %s\n", pins[i], pinctrl_dev_get_name(pctldev)); goto err_pin_request; } } /* Now that we have acquired the pins, encode the mux setting */ for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } desc->mux_setting = &(setting->data.mux); } ret = ops->enable(pctldev, setting->data.mux.func, setting->data.mux.group); if (ret) goto err_enable; return 0; err_enable: for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc) desc->mux_setting = NULL; } err_pin_request: /* On error release all taken pins */ while (--i >= 0) pin_free(pctldev, pins[i], NULL); return ret; }
int pinmux_enable_setting(struct pinctrl_setting const *setting) { struct pinctrl_dev *pctldev = setting->pctldev; const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; const struct pinmux_ops *ops = pctldev->desc->pmxops; int ret; const unsigned *pins; unsigned num_pins; int i; struct pin_desc *desc; ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, &num_pins); if (ret) { dev_warn(pctldev->dev, "could not get pins for group selector %d\n", setting->data.mux.group); num_pins = 0; } for (i = 0; i < num_pins; i++) { ret = pin_request(pctldev, pins[i], setting->dev_name, NULL); if (ret) { dev_err(pctldev->dev, "could not request pin %d on device %s\n", pins[i], pinctrl_dev_get_name(pctldev)); goto err_pin_request; } } for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } desc->mux_setting = &(setting->data.mux); } ret = ops->enable(pctldev, setting->data.mux.func, setting->data.mux.group); if (ret) goto err_enable; return 0; err_enable: for (i = 0; i < num_pins; i++) { desc = pin_desc_get(pctldev, pins[i]); if (desc) desc->mux_setting = NULL; } err_pin_request: while (--i >= 0) pin_free(pctldev, pins[i], NULL); return ret; }