static void bus_remove_attrs(struct bus_type *bus) { int i; if (bus->bus_attrs) { for (i = 0; attr_name(bus->bus_attrs[i]); i++) bus_remove_file(bus, &bus->bus_attrs[i]); } }
static void device_remove_attrs(struct bus_type *bus, struct device *dev) { int i; if (bus->dev_attrs) { for (i = 0; attr_name(bus->dev_attrs[i]); i++) device_remove_file(dev, &bus->dev_attrs[i]); } }
static void pm8941_remove_attributes(struct pm8941_flash_data *data, struct device_attribute *attrs) { int i; struct device *dev = &data->spmi_dev->dev; for (i = 0; attr_name(attrs[i]); i++) device_remove_file(dev, &attrs[i]); }
static void driver_remove_attrs(struct bus_type * bus, struct device_driver * drv) { int i; if (bus->drv_attrs) { for (i = 0; attr_name(bus->drv_attrs[i]); i++) driver_remove_file(drv, &bus->drv_attrs[i]); } }
//acquire all NOT NULL attributes of a node void SXmlNode::GetAttributeList(std::map<std::string, std::string>& attr_list){ if(!_node) return; xmlAttr* attribute = _node->properties; while(attribute && attribute->name && attribute->children) { xmlChar* value = xmlNodeListGetString(_node->doc, attribute->children, 1); std::string attr_name((const char*) attribute->name); std::string attr_value((const char*) value); if(!attr_name.empty() && !attr_value.empty()) attr_list[attr_name] = attr_value; xmlFree(value); attribute = attribute->next; } }
void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) { // Icon we're adding SGUIIcon icon; CStr name; XMBAttributeList attributes = Element.GetAttributes(); for (int i=0; i<attributes.Count; ++i) { XMBAttribute attr = attributes.Item(i); CStr attr_name (pFile->GetAttributeString(attr.Name)); CStr attr_value (attr.Value); if (attr_value == "null") continue; if (attr_name == "name") name = attr_value; else if (attr_name == "sprite") icon.m_SpriteName = attr_value; else if (attr_name == "size") { CSize size; if (!GUI<CSize>::ParseString(attr_value.FromUTF8(), size)) LOGERROR(L"Error parsing '%hs' (\"%hs\") inside <icon>.", attr_name.c_str(), attr_value.c_str()); else icon.m_Size = size; } else if (attr_name == "cell_id") { int cell_id; if (!GUI<int>::ParseString(attr_value.FromUTF8(), cell_id)) LOGERROR(L"GUI: Error parsing '%hs' (\"%hs\") inside <icon>.", attr_name.c_str(), attr_value.c_str()); else icon.m_CellID = cell_id; } else { debug_warn(L"Invalid data - DTD shouldn't allow this"); } } m_Icons[name] = icon; }
void CGUI::Xeromyces_ReadTooltip(XMBElement Element, CXeromyces* pFile) { IGUIObject* object = new CTooltip; for (XMBAttribute attr : Element.GetAttributes()) { CStr attr_name(pFile->GetAttributeString(attr.Name)); CStr attr_value(attr.Value); if (attr_name == "name") object->SetName("__tooltip_" + attr_value); else object->SetSetting(attr_name, attr_value.FromUTF8()); } AddObject(object); }
static int device_add_attrs(struct bus_type *bus, struct device *dev) { int error = 0; int i; if (!bus->dev_attrs) return 0; for (i = 0; attr_name(bus->dev_attrs[i]); i++) { error = device_create_file(dev, &bus->dev_attrs[i]); if (error) { while (--i >= 0) device_remove_file(dev, &bus->dev_attrs[i]); break; } } return error; }
static int bus_add_attrs(struct bus_type * bus) { int error = 0; int i; if (bus->bus_attrs) { for (i = 0; attr_name(bus->bus_attrs[i]); i++) { if ((error = bus_create_file(bus,&bus->bus_attrs[i]))) goto Err; } } Done: return error; Err: while (--i >= 0) bus_remove_file(bus,&bus->bus_attrs[i]); goto Done; }
static int device_add_attrs(struct bus_type * bus, struct device * dev) { int error = 0; int i; if (bus->dev_attrs) { for (i = 0; attr_name(bus->dev_attrs[i]); i++) { error = device_create_file(dev,&bus->dev_attrs[i]); if (error) goto Err; } } Done: return error; Err: while (--i >= 0) device_remove_file(dev,&bus->dev_attrs[i]); goto Done; }
static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv) { int error = 0; int i; if (bus->drv_attrs) { for (i = 0; attr_name(bus->drv_attrs[i]); i++) { error = driver_create_file(drv, &bus->drv_attrs[i]); if (error) goto err; } } done: return error; err: while (--i >= 0) driver_remove_file(drv, &bus->drv_attrs[i]); goto done; }
void CGUI::Xeromyces_ReadStyle(XMBElement Element, CXeromyces* pFile) { SGUIStyle style; CStr name; for (XMBAttribute attr : Element.GetAttributes()) { CStr attr_name(pFile->GetAttributeString(attr.Name)); // The "name" setting is actually the name of the style // and not a new default if (attr_name == "name") name = attr.Value; else style.m_SettingsDefaults[attr_name] = attr.Value.FromUTF8(); } m_Styles[name] = style; }
void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImageEffects& effects) { for (XMBAttribute attr : Element.GetAttributes()) { CStr attr_name(pFile->GetAttributeString(attr.Name)); CStrW attr_value(attr.Value.FromUTF8()); if (attr_name == "add_color") { CColor color; if (!GUI<int>::ParseColor(attr_value, color, 0)) LOGERROR("GUI: Error parsing '%s' (\"%s\")", attr_name, utf8_from_wstring(attr_value)); else effects.m_AddColor = color; } else if (attr_name == "grayscale") effects.m_Greyscale = true; else debug_warn(L"Invalid data - DTD shouldn't allow this"); } }
void CGUI::Xeromyces_ReadIcon(XMBElement Element, CXeromyces* pFile) { SGUIIcon icon; CStr name; for (XMBAttribute attr : Element.GetAttributes()) { CStr attr_name(pFile->GetAttributeString(attr.Name)); CStr attr_value(attr.Value); if (attr_value == "null") continue; if (attr_name == "name") name = attr_value; else if (attr_name == "sprite") icon.m_SpriteName = attr_value; else if (attr_name == "size") { CSize size; if (!GUI<CSize>::ParseString(attr_value.FromUTF8(), size)) LOGERROR("Error parsing '%s' (\"%s\") inside <icon>.", attr_name, attr_value); else icon.m_Size = size; } else if (attr_name == "cell_id") { int cell_id; if (!GUI<int>::ParseString(attr_value.FromUTF8(), cell_id)) LOGERROR("GUI: Error parsing '%s' (\"%s\") inside <icon>.", attr_name, attr_value); else icon.m_CellID = cell_id; } else debug_warn(L"Invalid data - DTD shouldn't allow this"); } m_Icons[name] = icon; }
static int jz_dmic_platfrom_probe(struct platform_device *pdev) { struct jz_dmic *jz_dmic; struct resource *res = NULL; int i = 0, ret; jz_dmic = devm_kzalloc(&pdev->dev, sizeof(struct jz_dmic), GFP_KERNEL); if (!jz_dmic) return -ENOMEM; jz_dmic->dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENOENT; if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),pdev->name)) return -EBUSY; jz_dmic->res_start = res->start; jz_dmic->res_size = resource_size(res); jz_dmic->vaddr_base = devm_ioremap_nocache(&pdev->dev, jz_dmic->res_start, jz_dmic->res_size); if (!jz_dmic->vaddr_base) { dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); return -ENOMEM; } jz_dmic->dmic_mode = 0; jz_dmic->rx_dma_data.dma_addr = (dma_addr_t)jz_dmic->res_start + DMICDR; jz_dmic->vcc_dmic = regulator_get(&pdev->dev,"dmic_1v8"); platform_set_drvdata(pdev, (void *)jz_dmic); for (; i < ARRAY_SIZE(jz_dmic_sysfs_attrs); i++) { ret = device_create_file(&pdev->dev, &jz_dmic_sysfs_attrs[i]); if (ret) dev_warn(&pdev->dev,"attribute %s create failed %x", attr_name(jz_dmic_sysfs_attrs[i]), ret); } jz_dmic->clk_gate_dmic = clk_get(&pdev->dev, "dmic"); if (IS_ERR_OR_NULL(jz_dmic->clk_gate_dmic)) { ret = PTR_ERR(jz_dmic->clk_gate_dmic); jz_dmic->clk_gate_dmic = NULL; dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); return ret; } jz_dmic->clk_pwc_dmic = clk_get(&pdev->dev, "pwc_dmic"); if (IS_ERR_OR_NULL(jz_dmic->clk_pwc_dmic)) { ret = PTR_ERR(jz_dmic->clk_pwc_dmic); jz_dmic->clk_pwc_dmic = NULL; dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); return ret; } clk_enable(jz_dmic->clk_pwc_dmic); ret = snd_soc_register_component(&pdev->dev, &jz_dmic_component, &jz_dmic_dai, 1); if (ret) goto err_register_cpu_dai; dev_dbg(&pdev->dev, "dmic platform probe success\n"); return ret; err_register_cpu_dai: platform_set_drvdata(pdev, NULL); return ret; }
int XMLFile::LoadFromXmlReader(IXmlReader *reader) { XmlNodeType type; int depth = 0; LPCWSTR text, value; HRESULT hr; list<XMLNode*> stack; stack.push_back(root); while (reader->Read(&type) == NOERROR) { switch (type) { case XmlNodeType_Element: { BOOL is_empty = reader->IsEmptyElement(); XMLNode *parent = stack.back(); XMLNode *current = new XMLNode(); stack.push_back(current); // add a new node parent->AddNode(current); hr = reader->GetLocalName(&text, NULL); if (FAILED(hr)) return hr; current->name = CString(text); // load attributes while (true) { hr = reader->MoveToNextAttribute(); if (hr != NOERROR) break; // read attribute name and value name hr = reader->GetLocalName(&text, NULL); if (FAILED(hr)) return hr; hr = reader->GetValue(&value, NULL); if (FAILED(hr)) return hr; CString attr_name(text); CString attr_value(value); current->AddField(attr_name, attr_value); } if (is_empty) { stack.pop_back(); } } break; case XmlNodeType_EndElement: { stack.pop_back(); } break; } } return 0; }
/** Parse the 'detailed' Anime fields from HTML * * */ std::shared_ptr<Anime> AnimeSerializer::deserialize_details(const std::string& xml) const { typedef std::unique_ptr<xmlChar, XmlCharDeleter> xmlStringUPtr; auto res = std::make_shared<Anime>(); std::unique_ptr<char[]> cstr(new char[xml.size()]); std::memcpy(cstr.get(), xml.c_str(), xml.size()); std::unique_ptr<xmlDoc, XmlDocDeleter> doc(htmlReadMemory(cstr.get(), xml.size(), "http://myanimelist.net/", nullptr, HTML_PARSE_RECOVER | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | HTML_PARSE_NONET)); std::unique_ptr<xmlTextReader, xmlTextReaderDeleter> reader(xmlReaderWalker(doc.get())); if (!reader) { std::cerr << "Error: Couldn't create XML reader" << std::endl; std::cerr << "XML follows: " << xml << std::endl; return nullptr; } enum { PRIORITY, STORAGE, REWATCHVALUE, DISCUSS, SELECTOR_NONE } selector = SELECTOR_NONE; enum { TAGS, COMMENTS, NONE } textarea = NONE; std::string textbuf; int ret = 1; for( ret = xmlTextReaderRead(reader.get()); ret == 1; ret = xmlTextReaderRead(reader.get()) ) { const std::string name = xmlchar_to_str(xmlTextReaderConstName (reader.get())); if (name == "input") { xmlStringUPtr type(xmlTextReaderGetAttribute(reader.get(), "type"_xml)); xmlStringUPtr attr_name(xmlTextReaderGetAttribute(reader.get(), "name"_xml)); xmlStringUPtr attr_value(xmlTextReaderGetAttribute(reader.get(), "value"_xml)); if (type) { if (xmlStrEqual(type.get(), "text"_xml) || xmlStrEqual(type.get(), "checkbox"_xml)) { if (xmlStrEqual(attr_name.get(), "fansub_group"_xml)) res->set_fansub_group(xmlchar_to_str(attr_value.get())); else if (xmlStrEqual(attr_name.get(), "list_downloaded_eps"_xml)) res->set_downloaded_items(xmlchar_to_str(attr_value.get())); else if (xmlStrEqual(attr_name.get(), "list_times_watched"_xml)) res->set_times_consumed(xmlchar_to_str(attr_value.get())); else if (xmlStrEqual(attr_name.get(), "storageVal"_xml)) res->set_storage_value(xmlchar_to_str(attr_value.get())); } } } else if (name == "textarea" && xmlTextReaderNodeType(reader.get()) == XML_READER_TYPE_ELEMENT) { xmlStringUPtr attr_name(xmlTextReaderGetAttribute(reader.get(), "name"_xml)); if (xmlStrEqual(attr_name.get(), "tags"_xml)) textarea = TAGS; else if (xmlStrEqual(attr_name.get(), "list_comments"_xml)) textarea = COMMENTS; else textarea = NONE; textbuf.clear(); } else if (name == "textarea" && xmlTextReaderNodeType(reader.get()) == XML_READER_TYPE_END_ELEMENT) { if (textarea != NONE) { switch (textarea) { case TAGS: /* Not a 'detailed' field */ break; case COMMENTS: res->set_comments(std::string(textbuf)); break; case NONE: default: break; } textarea = NONE; } } else if (name == "#text" && textarea != NONE) { textbuf.append(xmlchar_to_str(xmlTextReaderConstValue(reader.get()))); } else if (name == "select" && xmlTextReaderNodeType(reader.get()) == XML_READER_TYPE_ELEMENT) { xmlStringUPtr attr_name(xmlTextReaderGetAttribute(reader.get(), "name"_xml)); if (xmlStrEqual(attr_name.get(), "priority"_xml)) selector = PRIORITY; if (xmlStrEqual(attr_name.get(), "storage"_xml)) selector = STORAGE; if (xmlStrEqual(attr_name.get(), "list_rewatch_value"_xml)) selector = REWATCHVALUE; if (xmlStrEqual(attr_name.get(), "discuss"_xml)) selector = DISCUSS; } else if (name == "select" && xmlTextReaderNodeType(reader.get()) == XML_READER_TYPE_END_ELEMENT) { selector = SELECTOR_NONE; } else if (name == "option" && xmlTextReaderNodeType(reader.get()) == XML_READER_TYPE_ELEMENT) { xmlStringUPtr value(xmlTextReaderGetAttribute(reader.get(), "value"_xml)); if (xmlTextReaderMoveToAttribute(reader.get(), "selected"_xml) == 1) { switch (selector) { case PRIORITY: res->set_priority(xmlchar_to_str(value.get())); break; case STORAGE: res->set_storage_value(xmlchar_to_str(value.get())); break; case REWATCHVALUE: res->set_reconsume_value(xmlchar_to_str(value.get())); break; case DISCUSS: res->set_enable_discussion(xmlchar_to_str(value.get())); break; case SELECTOR_NONE: default: break; } } } } if (ret != 0) return nullptr; // Some sort of parsing error return res; }
void CGUI::Xeromyces_ReadImage(XMBElement Element, CXeromyces* pFile, CGUISprite &parent) { // Image object we're adding SGUIImage* Image = new SGUIImage; // Set defaults to "0 0 100% 100%" Image->m_TextureSize = CClientArea(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100)); Image->m_Size = CClientArea(CRect(0, 0, 0, 0), CRect(0, 0, 100, 100)); // TODO Gee: Setup defaults here (or maybe they are in the SGUIImage ctor) // // Read Attributes // // Now we can iterate all attributes and store XMBAttributeList attributes = Element.GetAttributes(); for (int i=0; i<attributes.Count; ++i) { XMBAttribute attr = attributes.Item(i); CStr attr_name (pFile->GetAttributeString(attr.Name)); CStrW attr_value (attr.Value.FromUTF8()); if (attr_name == "texture") { Image->m_TextureName = VfsPath("art/textures/ui") / attr_value; } else if (attr_name == "size") { CClientArea ca; if (!GUI<CClientArea>::ParseString(attr_value, ca)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_Size = ca; } else if (attr_name == "texture_size") { CClientArea ca; if (!GUI<CClientArea>::ParseString(attr_value, ca)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_TextureSize = ca; } else if (attr_name == "real_texture_placement") { CRect rect; if (!GUI<CRect>::ParseString(attr_value, rect)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_TexturePlacementInFile = rect; } else if (attr_name == "cell_size") { CSize size; if (!GUI<CSize>::ParseString(attr_value, size)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_CellSize = size; } else if (attr_name == "fixed_h_aspect_ratio") { float val; if (!GUI<float>::ParseString(attr_value, val)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_FixedHAspectRatio = val; } else if (attr_name == "round_coordinates") { bool b; if (!GUI<bool>::ParseString(attr_value, b)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_RoundCoordinates = b; } else if (attr_name == "wrap_mode") { if (attr_value == L"repeat") Image->m_WrapMode = GL_REPEAT; else if (attr_value == L"mirrored_repeat") Image->m_WrapMode = GL_MIRRORED_REPEAT; else if (attr_value == L"clamp_to_edge") Image->m_WrapMode = GL_CLAMP_TO_EDGE; else LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); } else if (attr_name == "z_level") { float z_level; if (!GUI<float>::ParseString(attr_value, z_level)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_DeltaZ = z_level/100.f; } else if (attr_name == "backcolor") { CColor color; if (!GUI<CColor>::ParseString(attr_value, color)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_BackColor = color; } else if (attr_name == "bordercolor") { CColor color; if (!GUI<CColor>::ParseString(attr_value, color)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_BorderColor = color; } else if (attr_name == "border") { bool b; if (!GUI<bool>::ParseString(attr_value, b)) LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str()); else Image->m_Border = b; } else { debug_warn(L"Invalid data - DTD shouldn't allow this"); } } // Look for effects XMBElementList children = Element.GetChildNodes(); for (int i=0; i<children.Count; ++i) { XMBElement child = children.Item(i); CStr ElementName (pFile->GetElementString(child.GetNodeName())); if (ElementName == "effect") { if (Image->m_Effects) { LOGERROR(L"GUI <image> must not have more than one <effect>"); } else { Image->m_Effects = new SGUIImageEffects; Xeromyces_ReadEffects(child, pFile, *Image->m_Effects); } } else { debug_warn(L"Invalid data - DTD shouldn't allow this"); } } // // Input // parent.AddImage(Image); }
std::vector<std::string> XAttrManager::get_xattr_list() throw (XAttrManagerException) { std::vector<std::string> result; int size = listxattr(_filename.c_str(), NULL, 0); // Assume at first that the length of every element will be at most 30 chars size = size*30; char* buffer = new char[size]; int num_elems; num_elems = listxattr(_filename.c_str(), buffer, size); while ((num_elems == -1) && (errno == ERANGE)) { delete[] buffer; size = size*2; buffer = new char[size]; num_elems = listxattr(_filename.c_str(), buffer, size); } // num_elems == -1 && errno != ERANGE if (num_elems == -1) { delete[] buffer; throw XAttrManagerException(Glib::locale_to_utf8(strerror(errno))); } for (int begin = 0, current = 0; current < num_elems; current++) { if (buffer[current] == '\0') { // Get the value std::string attr_name(&buffer[begin]); // Some filesystems give too small results if (attr_name.size() > 5) { std::string prefix = attr_name.substr(0, 5); std::string postfix = attr_name.substr(5); // Check the prefix, we only want user_xattr if (prefix == "user.") { bool is_empty = false; try { std::string attribute_value = get_attribute_value(postfix); } catch (XAttrManagerException e) { is_empty = true; } if (!is_empty) { result.push_back(postfix); } } } begin = current + 1; } } delete[] buffer; return result; }
static bool parse_sdp_attribute(AmSdp* sdp_msg, char*& s, char*& next_line) { DBG("parse_sdp_attribute: s=%s\n",s); if(sdp_msg->media.empty()){ ERROR("While parsing media options: no actual media !\n"); return true; } SdpMedia& media = sdp_msg->media.back(); char* sep=0; for( sep=s; *sep!='\0' && *sep!=':'; sep++ ); if( *sep == ':' ){ // attribute definition: 'attribute:value' string attr_name(s,int(sep-s)); char* old_s = s; s = sep + 1; if(attr_name == "rtpmap"){ //fmt: "<payload type> <encoding name>/<clock rate>[/<encoding parameters>]" unsigned int payload_type=0,clock_rate=0; string encoding_name, params; bool ret = str2i(s,payload_type) || parse_string_tok(s,encoding_name,'/') || str2i(s,clock_rate,'/'); if(ret){ ERROR("while parsing 'a=%s'\n",old_s); return true; } parse_string_tok(s,params,'\0'); DBG("sdp attribute: pt=%u; enc=%s; cr=%u\n", payload_type,encoding_name.c_str(),clock_rate); vector<SdpPayload>::iterator pl_it; for( pl_it=media.payloads.begin(); (pl_it != media.payloads.end()) && (pl_it->payload_type != int(payload_type)); ++pl_it); if(pl_it != media.payloads.end()){ *pl_it = SdpPayload( int(payload_type), encoding_name, int(clock_rate)); } return ret; } else if (attr_name == "fmtp") { // fmt: "<payload type> parameters" (?) // z.b. a=fmtp:101 0-15 unsigned int payload_type=0; string params; bool ret = str2i(s, payload_type) || parse_string_tok(s, params, '\0'); vector<SdpPayload>::iterator pl_it; for( pl_it=media.payloads.begin(); (pl_it != media.payloads.end()) && (pl_it->payload_type != int(payload_type)); ++pl_it); if(pl_it != media.payloads.end()) pl_it->sdp_format_parameters = params; return ret; } else if(attr_name == "direction"){ if(!strncmp(s,"active",6/*sizeof("active")*/)) media.dir = SdpMedia::DirActive; else if(!strncmp(s,"passive",7/*sizeof("passive")*/)) media.dir = SdpMedia::DirPassive; else if(!strncmp(s,"both",4/*sizeof("both")*/)) media.dir = SdpMedia::DirBoth; else DBG("unknown value for a=direction:%s",s); } else { DBG("unknown attribute definition '%s'\n",old_s); } } else { // flag: 'flag_name' DBG("flag definition is not yet supported (%s)\n",s); } return false; }
static int jz_pcm_platfrom_probe(struct platform_device *pdev) { struct jz_pcm *jz_pcm; struct resource *res = NULL; int i = 0, ret; jz_pcm = devm_kzalloc(&pdev->dev, sizeof(struct jz_pcm), GFP_KERNEL); if (!jz_pcm) return -ENOMEM; jz_pcm->dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENOENT; if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name)) return -EBUSY; jz_pcm->res_start = res->start; jz_pcm->res_size = resource_size(res); jz_pcm->vaddr_base = devm_ioremap_nocache(&pdev->dev, jz_pcm->res_start, jz_pcm->res_size); if (!jz_pcm->vaddr_base) { dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); return -ENOMEM; } jz_pcm->clk_gate = clk_get(&pdev->dev, "pcm"); if (IS_ERR_OR_NULL(jz_pcm->clk_gate)) { ret = PTR_ERR(jz_pcm->clk_gate); dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); jz_pcm->clk_gate = NULL; return ret; } jz_pcm->clk = clk_get(&pdev->dev, "cgu_pcm"); if (IS_ERR_OR_NULL(jz_pcm->clk)) { ret = PTR_ERR(jz_pcm->clk); dev_err(&pdev->dev, "Failed to get clock: %d\n", ret); goto err_get_clk; } platform_set_drvdata(pdev, (void *)jz_pcm); jz_pcm->pcm_mode = 0; jz_pcm->tx_dma_data.dma_addr = (dma_addr_t)jz_pcm->res_start + PCMDP; jz_pcm->rx_dma_data.dma_addr = (dma_addr_t)jz_pcm->res_start + PCMDP; platform_set_drvdata(pdev, (void *)jz_pcm); for (; i < ARRAY_SIZE(jz_pcm_sysfs_attrs); i++) { ret = device_create_file(&pdev->dev, &jz_pcm_sysfs_attrs[i]); if (ret) dev_warn(&pdev->dev,"attribute %s create failed %x", attr_name(jz_pcm_sysfs_attrs[i]), ret); } ret = snd_soc_register_component(&pdev->dev, &jz_pcm_component, &jz_pcm_dai, 1); if (ret) goto err_register_cpu_dai; dev_info(&pdev->dev, "pcm platform probe success\n"); return ret; err_register_cpu_dai: platform_set_drvdata(pdev, NULL); clk_put(jz_pcm->clk); jz_pcm->clk = NULL; err_get_clk: clk_put(jz_pcm->clk_gate); jz_pcm->clk_gate = NULL; return ret; }